summaryrefslogtreecommitdiff
path: root/cli/js/file_info.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/file_info.ts')
-rw-r--r--cli/js/file_info.ts68
1 files changed, 61 insertions, 7 deletions
diff --git a/cli/js/file_info.ts b/cli/js/file_info.ts
index 2f08658c7..f0ab5bf6c 100644
--- a/cli/js/file_info.ts
+++ b/cli/js/file_info.ts
@@ -1,5 +1,6 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { StatResponse } from "./stat.ts";
+import { build } from "./build.ts";
/** A FileInfo describes a file and is returned by `stat`, `lstat`,
* `statSync`, `lstatSync`.
@@ -22,13 +23,38 @@ export interface FileInfo {
* be available on all platforms.
*/
created: number | null;
+
+ /** The file or directory name. */
+ name: string | null;
+
+ /** ID of the device containing the file. Unix only. */
+ dev: number | null;
+
+ /** Inode number. Unix only. */
+ ino: number | null;
+
/** The underlying raw st_mode bits that contain the standard Unix permissions
* for this file/directory. TODO Match behavior with Go on windows for mode.
*/
mode: number | null;
- /** The file or directory name. */
- name: string | null;
+ /** Number of hard links pointing to this file. Unix only. */
+ nlink: number | null;
+
+ /** User ID of the owner of this file. Unix only. */
+ uid: number | null;
+
+ /** User ID of the owner of this file. Unix only. */
+ gid: number | null;
+
+ /** Device ID of this file. Unix only. */
+ rdev: number | null;
+
+ /** Blocksize for filesystem I/O. Unix only. */
+ blksize: number | null;
+
+ /** Number of blocks allocated to the file, in 512-byte units. Unix only. */
+ blocks: number | null;
/** Returns whether this is info for a regular file. This result is mutually
* exclusive to `FileInfo.isDirectory` and `FileInfo.isSymlink`.
@@ -54,17 +80,37 @@ export class FileInfoImpl implements FileInfo {
modified: number | null;
accessed: number | null;
created: number | null;
- mode: number | null;
name: string | null;
+ dev: number | null;
+ ino: number | null;
+ mode: number | null;
+ nlink: number | null;
+ uid: number | null;
+ gid: number | null;
+ rdev: number | null;
+ blksize: number | null;
+ blocks: number | null;
+
/* @internal */
constructor(private _res: StatResponse) {
+ const isUnix = build.os === "mac" || build.os === "linux";
const modified = this._res.modified;
const accessed = this._res.accessed;
const created = this._res.created;
- const hasMode = this._res.hasMode;
- const mode = this._res.mode; // negative for invalid mode (Windows)
const name = this._res.name;
+ // Unix only
+ const {
+ dev,
+ ino,
+ mode,
+ nlink,
+ uid,
+ gid,
+ rdev,
+ blksize,
+ blocks
+ } = this._res;
this._isFile = this._res.isFile;
this._isSymlink = this._res.isSymlink;
@@ -72,9 +118,17 @@ export class FileInfoImpl implements FileInfo {
this.modified = modified ? modified : null;
this.accessed = accessed ? accessed : null;
this.created = created ? created : null;
- // null on Windows
- this.mode = hasMode ? mode : null;
this.name = name ? name : null;
+ // Only non-null if on Unix
+ this.dev = isUnix ? dev : null;
+ this.ino = isUnix ? ino : null;
+ this.mode = isUnix ? mode : null;
+ this.nlink = isUnix ? nlink : null;
+ this.uid = isUnix ? uid : null;
+ this.gid = isUnix ? gid : null;
+ this.rdev = isUnix ? rdev : null;
+ this.blksize = isUnix ? blksize : null;
+ this.blocks = isUnix ? blocks : null;
}
isFile(): boolean {