From 48a0b7f98f568bb5c3a15b487459569e38e4c671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 15 Mar 2023 21:35:13 -0400 Subject: feat(fs): support FileInfo.dev on Windows (#18073) This commit adds support for retrieving `dev` information when stating files on Windows. Additionally `Deno.FileInfo` interfaces was changed to always return 0 for fields that we don't retrieve information for on Windows. Closes https://github.com/denoland/deno/issues/18053 --------- Co-authored-by: David Sherret --- cli/tests/unit/stat_test.ts | 20 ++++++++++---------- cli/tsc/dts/lib.deno.ns.d.ts | 36 +++++++++++++++++------------------- 2 files changed, 27 insertions(+), 29 deletions(-) (limited to 'cli') diff --git a/cli/tests/unit/stat_test.ts b/cli/tests/unit/stat_test.ts index 50149cae6..572e54e25 100644 --- a/cli/tests/unit/stat_test.ts +++ b/cli/tests/unit/stat_test.ts @@ -291,22 +291,22 @@ Deno.test( ignore: Deno.build.os !== "windows", permissions: { read: true, write: true }, }, - function statNoUnixFields() { + function statUnixFieldsOnWindows() { const enc = new TextEncoder(); const data = enc.encode("Hello"); const tempDir = Deno.makeTempDirSync(); const filename = tempDir + "/test.txt"; Deno.writeFileSync(filename, data, { mode: 0o666 }); const s = Deno.statSync(filename); - assert(s.dev === null); - assert(s.ino === null); - assert(s.mode === null); - assert(s.nlink === null); - assert(s.uid === null); - assert(s.gid === null); - assert(s.rdev === null); - assert(s.blksize === null); - assert(s.blocks === null); + assert(s.dev !== 0); + assert(s.ino === 0); + assert(s.mode === 0); + assert(s.nlink === 0); + assert(s.uid === 0); + assert(s.gid === 0); + assert(s.rdev === 0); + assert(s.blksize === 0); + assert(s.blocks === 0); }, ); diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 1ad67ac88..472c147d0 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -3078,43 +3078,41 @@ declare namespace Deno { * field from `stat` on Mac/BSD and `ftCreationTime` on Windows. This may * not be available on all platforms. */ birthtime: Date | null; - /** ID of the device containing the file. - * - * _Linux/Mac OS only._ */ - dev: number | null; + /** ID of the device containing the file. */ + dev: number; /** Inode number. * - * _Linux/Mac OS only._ */ - ino: number | null; + * _Linux/Mac OS only, always returns 0 on Windows_ */ + ino: number; /** **UNSTABLE**: Match behavior with Go on Windows for `mode`. * * The underlying raw `st_mode` bits that contain the standard Unix * permissions for this file/directory. */ - mode: number | null; + mode: number; /** Number of hard links pointing to this file. * - * _Linux/Mac OS only._ */ - nlink: number | null; + * _Linux/Mac OS only, always returns 0 on Windows_ */ + nlink: number; /** User ID of the owner of this file. * - * _Linux/Mac OS only._ */ - uid: number | null; + * _Linux/Mac OS only, always returns 0 on Windows_ */ + uid: number; /** Group ID of the owner of this file. * - * _Linux/Mac OS only._ */ - gid: number | null; + * _Linux/Mac OS only, always returns 0 on Windows_ */ + gid: number; /** Device ID of this file. * - * _Linux/Mac OS only._ */ - rdev: number | null; + * _Linux/Mac OS only, always returns 0 on Windows_ */ + rdev: number; /** Blocksize for filesystem I/O. * - * _Linux/Mac OS only._ */ - blksize: number | null; + * _Linux/Mac OS only, always returns 0 on Windows_ */ + blksize: number; /** Number of blocks allocated to the file, in 512-byte units. * - * _Linux/Mac OS only._ */ - blocks: number | null; + * _Linux/Mac OS only, always returns 0 on Windows_ */ + blocks: number; } /** Resolves to the absolute normalized path, with symbolic links resolved. -- cgit v1.2.3