smartfile/ts/smartfile.classes.virtualdirectory.ts

32 lines
955 B
TypeScript
Raw Normal View History

2020-10-02 13:26:53 +00:00
import { Smartfile } from './smartfile.classes.smartfile';
import * as plugins from './smartfile.plugins';
import * as fs from './smartfile.fs';
/**
* a virtual directory exposes a fs api
*/
export class VirtualDirectory {
private fileArray: Smartfile[] = [];
public static async fromFsDirPath(pathArg: string) {
const newVirtualDir = new VirtualDirectory();
newVirtualDir.addSmartfiles(await fs.fileTreeToObject(pathArg, '**/*'));
2020-10-02 13:29:40 +00:00
}
2020-10-02 13:26:53 +00:00
constructor() {}
public addSmartfiles(smartfileArrayArg: Smartfile[]) {
this.fileArray = this.fileArray.concat(smartfileArrayArg);
}
public async getFileByPath(pathArg: string) {
for (const smartfile of this.fileArray) {
if (smartfile.path === pathArg) {
return smartfile;
}
}
}
// TODO implement root shifting to get subdirectories as new virtual directories
// TODO implement root shifting to combine VirtualDirecotries in a parent virtual directory
2020-10-02 13:29:40 +00:00
}