Skip to content

Commit

Permalink
Merge pull request #769 from MatrixAI/feature-eng-363-implement-utili…
Browse files Browse the repository at this point in the history
…ty-that-generates-a-file-tree-from-a-path

Implementing file system pattern walker
  • Loading branch information
tegefaulkes authored Jul 17, 2024
2 parents 58d4f27 + 1496d2c commit 2a88416
Show file tree
Hide file tree
Showing 6 changed files with 823 additions and 26 deletions.
176 changes: 153 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
"prompts": "^2.4.1",
"resource-counter": "^1.2.4",
"sodium-native": "^3.4.1",
"threads": "^1.6.5"
"threads": "^1.6.5",
"minimatch": "^10.0.1"
},
"devDependencies": {
"@fast-check/jest": "^1.1.0",
Expand All @@ -116,6 +117,7 @@
"@types/pako": "^1.0.2",
"@types/prompts": "^2.0.13",
"@types/readable-stream": "^2.3.11",
"@types/minimatch": "^5.1.2",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"benny": "^3.7.1",
Expand Down
51 changes: 51 additions & 0 deletions src/vaults/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,49 @@ type VaultName = string;

type VaultActions = Partial<Record<VaultAction, null>>;

type FileTree = Array<TreeNode>;
type TreeNode = DirectoryNode | FileNode;
type FilePath = string;
type INode = number;
type CNode = number;

type StatEncoded = {
isSymbolicLink: boolean;
type: 'FILE' | 'DIRECTORY' | 'OTHER';
dev: number;
ino: number;
mode: number;
nlink: number;
uid: number;
gid: number;
rdev: number;
size: number;
blksize: number;
blocks: number;
atime: number;
mtime: number;
ctime: number;
birthtime: number;
};

type DirectoryNode = {
type: 'directory';
path: FilePath;
iNode: INode;
parent: INode;
children: Array<INode>;
stat?: StatEncoded;
};

type FileNode = {
type: 'file';
path: FilePath;
iNode: INode;
parent: INode;
cNode: CNode;
stat?: StatEncoded;
};

export { vaultActions };

export type {
Expand All @@ -148,6 +191,14 @@ export type {
FileSystemWritable,
VaultName,
VaultActions,
FileTree,
TreeNode,
FilePath,
INode,
CNode,
StatEncoded,
DirectoryNode,
FileNode,
};

export { tagLast, refs };
Loading

0 comments on commit 2a88416

Please sign in to comment.