summaryrefslogtreecommitdiff
path: root/fs/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'fs/utils.ts')
-rw-r--r--fs/utils.ts17
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/utils.ts b/fs/utils.ts
index dd7ee5fa4..410e45909 100644
--- a/fs/utils.ts
+++ b/fs/utils.ts
@@ -21,3 +21,20 @@ export function isSubdir(
return acc && destArray[i] === current;
}, true);
}
+
+export enum PathType {
+ file = "file",
+ dir = "dir",
+ symlink = "symlink"
+}
+
+/* Get a human readable file type string */
+export function getFileInfoType(fileInfo: Deno.FileInfo): PathType | null {
+ return fileInfo.isFile()
+ ? PathType.file
+ : fileInfo.isDirectory()
+ ? PathType.dir
+ : fileInfo.isSymlink()
+ ? PathType.symlink
+ : null;
+}