Node - File System

> (World Wide) Web - (W3|WWW) > Javascript (Js|ECMAScript) > Node.js

1 - About

2 - API

3 - Management

3.1 - Exist

3.1.1 - Path

  • path (synchronous call)
const fs = require('fs')
fs.existsSync(path)
  • Path (Asynchronous)
const fs = require('fs')
fs.access(path, fs.F_OK, (err) => {
  if (err) {
    console.error(err)
    return
  }
  // File exit
})
Advertising

3.1.2 - Dir/File

let dirExists = fs.existsSync(dirPath) && fs.lstatSync(dirPath).isDirectory();
let fileExists = fs.existsSync(dirFile) && fs.lstatSync(dirFile).isFile();
web/javascript/node/fs.txt · Last modified: 2019/05/09 16:05 by gerardnico