-
Notifications
You must be signed in to change notification settings - Fork 0
This class represents methods for working with the virtual file system.
Everything inside the class is static, which guarantees a single virtual system in all applications.
All class attributes are private, so information about them will be provided for project development.
private static tree: Record<string, any> = {};The tree is a key part of the virtual file system and is an object, the keys of which must be strings, and the values must be strings (which means that there is a file on the given path) or the same objects (which means that there is a directory on the given path).
private static home: string = '';Home - the path of the home folder, at startup the terminal is located in the home folder.
public static _parsePath(path: string): string[]Removes '../' from the path, replacing with the parent directory.
public static getFolder(path: string): Record<string, any> {Returns the files and directories within the given path.
private static _getFolderWithoutLast(path: string): [Record<string, any>, string]Wrapper over getFolder, used to get a folder by path and file name.
public static readFile(path: string): string | 'Uncorrected path'Tries to give information along the path, if it doesn't work, then returns "Uncorrected path".
public static write(path: string, data: string | {})Creates or modifies a file or folder at the given path.
public static remove(path: string, recursion?: boolean)Deletes a file or folder at the given path. To delete a folder, the recursion flag must be true.
public static export(): stringReturns the file system as a JSON string.
public static import(data: { [key: string]: any } | string, home?: string)Sets the filesystem according to the passed object or JSON string. When passing the home parameter, the home attribute is set to the passed.