Get file system type using node js

I am working on a project in node js and I need to get the file system type on disk, i.e. I want to know if it is FAT or NTFS, etc. Is there a way to do this using node js? Any help is appreciated. Thank.

+4
source share
2 answers

Since you did not specify the target operating system, you can use this command under Windows:

fsutil fsinfo volumeinfo <disk letter here>:

to show simillar output to this:

H:\>fsutil fsinfo volumeinfo c:

Volume Name :
Volume Serial Number : 0x4c31bcb3
Max Component Length : 255
File System Name : NTFS
Supports Case-sensitive filenames
Preserves Case of filenames
Supports Unicode in filenames
Preserves & Enforces ACL's
Supports file-based Compression
Supports Disk Quotas
Supports Sparse files
Supports Reparse Points
Supports Object Identifiers
Supports Encrypted File System
Supports Named Streams

You only need to parse the output of the command correctly. I would recommend that you store the file system names in an array and search for each command in the output, excluding the first line. This way you can be sure which file system is being used by the target machine.

, :

const { exec } = require('child_process');
exec('fsutil fsinfo volumeinfo c:', (err, stdout, stderr) => {
  if (err) {
    // node couldn't execute the command
    return;
  }

  // the *entire* stdout and stderr (buffered)
  console.log(`stdout: ${stdout}`);
});

, , . , , .

, ?

+3

github.com/resin-io-modules/drivelist

const drivelist = require('drivelist');



drivelist.list((error, drives) => {
  if (error) {
    throw error;
  }

  console.log(drives);
});
-1

Source: https://habr.com/ru/post/1687896/


All Articles