Home > @infiniteobjects/core-library-node > FileSystem
The FileSystem API provides a complete set of recommended operations for interacting with the file system.
Signature:
export declare class FileSystem
We recommend to use this instead of the native fs API, because fs is a minimal set of low-level primitives that must be mapped for each supported operating system.
| Method | Modifiers | Description |
|---|---|---|
| copyFile(sourcePath, destinationPath) | static |
Copy a File |
| deleteFile(filePath) | static |
Asynchronous unlink(2). |
| deleteFolder(patterns, options) | static |
Delete files and folders using globs, It also protects you against deleting the current working directory and above. - Think rm -rf. |
| ensureFolder(dirPath) | static |
Make a directory and its parents if needed |
| ensureFolderSync(dirPath) | static |
Sync version of ensureDirectory |
| exists(filePath) | static |
Returns true if the given path exists in the FileSystem. |
| findInFolder(patterns, options) | static |
Find files using globs. |
| findInFolderSync(patterns, options) | static |
Find files using globs synchronically. |
| readCsv(file) | static |
Read and parse a CSV file. It respects dot notation on the headers. |
| readFile(filePath) | static |
Asynchronously reads the entire UTF-8 contents of a file. |
| readFileAsBuffer(filePath) | static |
Asynchronously reads Buffer file. |
| readJson(filePath) | static |
Read and parse a JSON file, throws more helpful JSON errors. |
| readYaml(filePath, parseOptions) | static |
Read and parse a YAML file. |
| writeCsv(filepath, data) | static |
Stringify and write CSV to a file atomically, replacing the file if it already exists. |
| writeFile(filePath, data) | static |
Atomically writes data to a file, replacing the file if it already exists. |
| writeJson(filePath, data) | static |
Stringify and write JSON to a file atomically, replacing the file if it already exists. |
| writeYaml(filepath, data, options) | static |
Stringify and write YAML to a file atomically, replacing the file if it already exists. |