Answers for "fs isdirectory"

3

fs check if dir is dir

fs.lstatSync(path_string).isDirectory()
Posted by: Guest on June-05-2021
0

node isfile or isdirectory

const fs = require("fs");

let path = "/path/to/something";

fs.lstat(path, (err, stats) => {

    if(err)
        return console.log(err); //Handle error

    console.log(`Is file: ${stats.isFile()}`);
    console.log(`Is directory: ${stats.isDirectory()}`);
    console.log(`Is symbolic link: ${stats.isSymbolicLink()}`);
    console.log(`Is FIFO: ${stats.isFIFO()}`);
    console.log(`Is socket: ${stats.isSocket()}`);
    console.log(`Is character device: ${stats.isCharacterDevice()}`);
    console.log(`Is block device: ${stats.isBlockDevice()}`);
});
Posted by: Guest on July-05-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language