diff options
author | Hirotaka Tagawa / wafuwafu13 <jaruwafu@gmail.com> | 2023-05-24 20:18:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-24 21:18:13 +0200 |
commit | 114ec3c1f71b40bd4bba473b0187e7c664ed1755 (patch) | |
tree | 7633e26d36133acf29b81de02418f7c7cfd2a847 /ext/fs/30_fs.js | |
parent | 072e2b2fa236dd50040a210a425ff50ae39b0198 (diff) |
feat(ext/fs): add isBlockDevice, isCharDevice, isFifo, isSocket to FileInfo (#19008)
`isFile`, `isDirectory`, `isSymlink` are defined in `Deno.FileInfo`, but
`isBlockDevice`, `isCharacterDevice`, `isFIFO`, `isSocket` are not
defined.
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/fs/30_fs.js')
-rw-r--r-- | ext/fs/30_fs.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/ext/fs/30_fs.js b/ext/fs/30_fs.js index dbe064ab8..f14fcd5d1 100644 --- a/ext/fs/30_fs.js +++ b/ext/fs/30_fs.js @@ -245,6 +245,7 @@ async function rename(oldpath, newpath) { // high u32 | low u32 // // 4. ?u64 converts a zero u64 value to JS null on Windows. +// ?bool converts a false bool value to JS null on Windows. function createByteStruct(types) { // types can be "date", "bool" or "u64". let offset = 0; @@ -273,7 +274,15 @@ function createByteStruct(types) { }] + view[${offset + 3}] * 2**32),`; offset += 2; } else { - str += `${name}: !!(view[${offset}] + view[${offset + 1}] * 2**32),`; + if (!optional) { + str += `${name}: !!(view[${offset}] + view[${offset + 1}] * 2**32),`; + } else { + str += `${name}: (unix ? !!((view[${offset}] + view[${ + offset + 1 + }] * 2**32)) : !!((view[${offset}] + view[${ + offset + 1 + }] * 2**32)) || null),`; + } } offset += 2; } @@ -299,6 +308,10 @@ const { 0: statStruct, 1: statBuf } = createByteStruct({ rdev: "?u64", blksize: "?u64", blocks: "?u64", + isBlockDevice: "?bool", + isCharDevice: "?bool", + isFifo: "?bool", + isSocket: "?bool", }); function parseFileInfo(response) { @@ -322,6 +335,10 @@ function parseFileInfo(response) { rdev: unix ? response.rdev : null, blksize: unix ? response.blksize : null, blocks: unix ? response.blocks : null, + isBlockDevice: unix ? response.isBlockDevice : null, + isCharDevice: unix ? response.isCharDevice : null, + isFifo: unix ? response.isFifo : null, + isSocket: unix ? response.isSocket : null, }; } |