Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Secure file system operations. #11

Open
zero-plusplus opened this issue Sep 13, 2021 · 0 comments
Open

Secure file system operations. #11

zero-plusplus opened this issue Sep 13, 2021 · 0 comments
Labels
draft Draft of new features

Comments

@zero-plusplus
Copy link
Owner

Provides an easy/secure way to use file operations.

Overwriting or deleting files/folders should be handled with care, but mistakes do happen.
To solve this problem, a permission-based system that specifies the target of the operation first is adopted.

Permission

bee.FileSystem takes an enumeration of file paths where operations are allowed.
Its instance can only operate on allowed file paths, operations on other file paths are disabled.

bee.glob will be explained next.

fileSystem := bee.FileSystem(bee.glob("C:\example\**\*"))
fileSystem.createDir("C:\example\test")         ; => success
fileSystem.createDir("C:\another-example\test") ; => failure

Enumeration

Provides bee.glob as a mechanism to simplify the enumeration of files. It has the same format as the Unix glob.

bee.glob returns bee.Enumerable of #8.

; C:\example
;   - lib
;     - nest
;       - C.ahk
;     - A.ahk
;     - B.ahk
;   - MainScript.ahk
bee.glob("C:\example\lib\**\*.ahk").toArray() ; => [ "C:\example\lib\nest\C.ahk", "C:\example\lib\A.ahk", "C:\example\lib\B.ahk" ]

Path

Provides path of Node.js-like static methods to simplify file path manipulation.

bee.path.resolve("C:", "example") ; => "C:\example"
bee.path.isAbsolute("C:\example") ; => true
bee.path.isAbsolute(".\example") ; => false
bee.path.exists("C:\example") ; => true
@zero-plusplus zero-plusplus added the draft Draft of new features label Sep 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
draft Draft of new features
Projects
None yet
Development

No branches or pull requests

1 participant