About Deno 1.34 API changes - Deno.FileInfo
Deno 1.34 was released in May 26, 2023
I implemented Deno API changes - Deno.FileInfo
https://deno.com/blog/v1.34#denofileinfo
The Deno.FileInfo interface now includes the following new fields:
- Deno.FileInfo.isBlockDevice
- Deno.FileInfo.isCharDevice
- Deno.FileInfo.isFifo
- Deno.FileInfo.isSocket
The fields are available on Linux and macOS. On Windows, they are always null.Thank you to Hirotaka Tagawa for the contribution.
PR is #19008
github.com
Versions prior to 1.34 don't have isBlockDevice, isCharDevice, isFifo, isSocket information in FileInfo
Example =>
$ touch file_test $ deno --version deno 1.33.2 (release, aarch64-apple-darwin) v8 11.4.183.1 typescript 5.0.3 > Deno.statSync('/Users/wafuwafu13/desktop/file_test') { isFile: true, isDirectory: false, isSymlink: false, size: 0, mtime: 2023-05-25T20:38:52.075Z, atime: 2023-05-25T20:38:52.075Z, birthtime: 2023-05-25T20:38:52.075Z, dev: 16777232, ino: 56604379, mode: 33188, nlink: 1, uid: 501, gid: 20, rdev: 0, blksize: 4096, blocks: 0 }
In version 1.34 have isBlockDevice, isCharDevice, isFifo, isSocket information in FileInfo
Example =>
$ deno --version deno 1.34.0 (release, aarch64-apple-darwin) v8 11.5.150.1 typescript 5.0.4 > Deno.statSync('/Users/wafuwafu13/desktop/file_test') { isFile: true, isDirectory: false, isSymlink: false, size: 0, mtime: 2023-05-25T20:38:52.075Z, atime: 2023-05-25T20:38:52.075Z, birthtime: 2023-05-25T20:38:52.075Z, dev: 16777232, ino: 56604379, mode: 33188, nlink: 1, uid: 501, gid: 20, rdev: 0, blksize: 4096, blocks: 0, isBlockDevice: false, isCharDevice: false, isFifo: false, isSocket: false }
Example of isBlockDevice: true
=>
> Deno.statSync('/dev/disk0') { isFile: false, isDirectory: false, isSymlink: false, size: 0, mtime: 2023-05-24T20:27:08.000Z, atime: 2023-05-24T20:27:08.000Z, birthtime: 1970-01-01T00:00:00.000Z, dev: 89290492, ino: 623, mode: 24992, nlink: 1, uid: 0, gid: 5, rdev: 16777216, blksize: 2048, blocks: 0, isBlockDevice: true, isCharDevice: false, isFifo: false, isSocket: false }
Example of isCharDevice: true
=>
> Deno.statSync('/dev/tty') { isFile: false, isDirectory: false, isSymlink: false, size: 0, mtime: 2023-05-24T20:27:08.000Z, atime: 2023-05-24T20:27:08.000Z, birthtime: 1970-01-01T00:00:00.000Z, dev: 89290492, ino: 334, mode: 8630, nlink: 1, uid: 0, gid: 0, rdev: 33554432, blksize: 65536, blocks: 0, isBlockDevice: false, isCharDevice: true, isFifo: false, isSocket: false }
Example of isFifo: true
=>
$ mkfifo fifo_test > Deno.statSync('/Users/wafuwafu13/desktop/fifo_test') { isFile: false, isDirectory: false, isSymlink: false, size: 0, mtime: 2023-05-25T20:37:24.714Z, atime: 2023-05-25T20:37:24.714Z, birthtime: 2023-05-25T20:37:24.714Z, dev: 16777232, ino: 56604333, mode: 4516, nlink: 1, uid: 501, gid: 20, rdev: 0, blksize: 4096, blocks: 0, isBlockDevice: false, isCharDevice: false, isFifo: true, isSocket: false }
Example of isSocket: true
=>
> Deno.statSync('/var/run/filesystemui.socket') { isFile: false, isDirectory: false, isSymlink: false, size: 0, mtime: 2023-05-24T20:27:25.710Z, atime: 2023-05-24T20:27:25.710Z, birthtime: 2023-05-24T20:27:25.710Z, dev: 16777232, ino: 56514866, mode: 49572, nlink: 1, uid: 501, gid: 0, rdev: 0, blksize: 4096, blocks: 0, isBlockDevice: false, isCharDevice: false, isFifo: false, isSocket: true }
🦕