diff options
author | Bert Belder <bertbelder@gmail.com> | 2020-04-29 22:00:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 16:00:31 -0400 |
commit | 3e6ea6284178df0be4982d9775f47b47b14c6139 (patch) | |
tree | ed684ea536e32023e72004110556ad8285126676 /cli/js/ops/fs | |
parent | 721a4ad59d4a8bdd8470d6b98839137f14c84ba9 (diff) |
BREAKING: Include limited metadata in 'DirEntry' objects (#4941)
This change is to prevent needed a separate stat syscall for each file
when using readdir.
For consistency, this PR also modifies std's `WalkEntry` interface to
extend `DirEntry` with an additional `path` field.
Diffstat (limited to 'cli/js/ops/fs')
-rw-r--r-- | cli/js/ops/fs/read_dir.ts | 14 | ||||
-rw-r--r-- | cli/js/ops/fs/stat.ts | 2 |
2 files changed, 6 insertions, 10 deletions
diff --git a/cli/js/ops/fs/read_dir.ts b/cli/js/ops/fs/read_dir.ts index 29b8676ef..7d65fed48 100644 --- a/cli/js/ops/fs/read_dir.ts +++ b/cli/js/ops/fs/read_dir.ts @@ -1,21 +1,19 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { sendSync, sendAsync } from "../dispatch_json.ts"; -import { FileInfo, StatResponse, parseFileInfo } from "./stat.ts"; -export interface DirEntry extends FileInfo { +export interface DirEntry { name: string; + isFile: boolean; + isDirectory: boolean; + isSymlink: boolean; } interface ReadDirResponse { - entries: StatResponse[]; + entries: DirEntry[]; } function res(response: ReadDirResponse): DirEntry[] { - return response.entries.map( - (statRes: StatResponse): DirEntry => { - return { ...parseFileInfo(statRes), name: statRes.name! }; - } - ); + return response.entries; } export function readdirSync(path: string): Iterable<DirEntry> { diff --git a/cli/js/ops/fs/stat.ts b/cli/js/ops/fs/stat.ts index c3563a8c4..e8fd28218 100644 --- a/cli/js/ops/fs/stat.ts +++ b/cli/js/ops/fs/stat.ts @@ -29,8 +29,6 @@ export interface StatResponse { mtime: number | null; atime: number | null; birthtime: number | null; - // Null for stat(), but exists for readdir(). - name: string | null; // Unix only members dev: number; ino: number; |