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.
This commit is contained in:
Bert Belder 2020-04-29 22:00:31 +02:00 committed by GitHub
parent 721a4ad59d
commit 3e6ea62841
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 193 additions and 206 deletions

View file

@ -4,19 +4,14 @@ import { unitTest, assert, assertEquals } from "./test_util.ts";
function assertSameContent(files: Deno.DirEntry[]): void {
let counter = 0;
for (const file of files) {
if (file.name === "subdir") {
assert(file.isDirectory);
counter++;
}
if (file.name === "002_hello.ts") {
assertEquals(file.mode!, Deno.statSync(`cli/tests/${file.name}`).mode!);
for (const entry of files) {
if (entry.name === "subdir") {
assert(entry.isDirectory);
counter++;
}
}
assertEquals(counter, 2);
assertEquals(counter, 1);
}
unitTest({ perms: { read: true } }, function readdirSyncSuccess(): void {