-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core-kernel): filesystem abstraction
- Loading branch information
Brian Faust
committed
Aug 22, 2019
1 parent
85b6b60
commit 0f7e589
Showing
15 changed files
with
449 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
packages/core-kernel/src/contracts/core-kernel/filesystem.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { IApplication } from "./application"; | ||
|
||
export interface IFilesystem { | ||
/** | ||
* Create a new instance of the filesystem. | ||
* | ||
* @param {IApplication} app | ||
* @returns {Promise<IFilesystem>} | ||
* @memberof IFilesystem | ||
*/ | ||
make(app: IApplication): Promise<IFilesystem>; | ||
|
||
/** | ||
* Determine if a file exists. | ||
* | ||
* @param {string} path | ||
* @returns {Promise<boolean>} | ||
* @memberof IFilesystem | ||
*/ | ||
exists(path: string): Promise<boolean>; | ||
|
||
/** | ||
* Get the contents of a file. | ||
* | ||
* @param {string} path | ||
* @returns {Promise<Buffer>} | ||
* @memberof IFilesystem | ||
*/ | ||
get(path: string): Promise<Buffer>; | ||
|
||
/** | ||
* Write the contents of a file. | ||
* | ||
* @param {string} path | ||
* @param {string} contents | ||
* @returns {Promise<boolean>} | ||
* @memberof IFilesystem | ||
*/ | ||
put(path: string, contents: string): Promise<boolean>; | ||
|
||
/** | ||
* Delete the file at a given path. | ||
* | ||
* @param {string} path | ||
* @returns {Promise<boolean>} | ||
* @memberof IFilesystem | ||
*/ | ||
delete(path: string): Promise<boolean>; | ||
|
||
/** | ||
* Copy a file to a new location. | ||
* | ||
* @param {string} from | ||
* @param {string} to | ||
* @returns {Promise<boolean>} | ||
* @memberof IFilesystem | ||
*/ | ||
copy(from: string, to: string): Promise<boolean>; | ||
|
||
/** | ||
* Move a file to a new location. | ||
* | ||
* @param {string} from | ||
* @param {string} to | ||
* @returns {Promise<boolean>} | ||
* @memberof IFilesystem | ||
*/ | ||
move(from: string, to: string): Promise<boolean>; | ||
|
||
/** | ||
* Get the file size of a given file. | ||
* | ||
* @param {string} path | ||
* @returns {Promise<number>} | ||
* @memberof IFilesystem | ||
*/ | ||
size(path: string): Promise<number>; | ||
|
||
/** | ||
* Get the file's last modification time. | ||
* | ||
* @param {string} path | ||
* @returns {Promise<number>} | ||
* @memberof IFilesystem | ||
*/ | ||
lastModified(path: string): Promise<number>; | ||
|
||
/** | ||
* Get an array of all files in a directory. | ||
* | ||
* @param {string} directory | ||
* @returns {Promise<string[]>} | ||
* @memberof IFilesystem | ||
*/ | ||
files(directory: string): Promise<string[]>; | ||
|
||
/** | ||
* Get all of the directories within a given directory. | ||
* | ||
* @param {string} directory | ||
* @returns {Promise<string[]>} | ||
* @memberof IFilesystem | ||
*/ | ||
directories(directory: string): Promise<string[]>; | ||
|
||
/** | ||
* Create a directory. | ||
* | ||
* @param {*} path | ||
* @returns {Promise<boolean>} | ||
* @memberof IFilesystem | ||
*/ | ||
makeDirectory(path): Promise<boolean>; | ||
|
||
/** | ||
* Recursively delete a directory. | ||
* | ||
* @param {string} directory | ||
* @returns {Promise<boolean>} | ||
* @memberof IFilesystem | ||
*/ | ||
deleteDirectory(directory: string): Promise<boolean>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.