The following shows fs module APIs available for each platform.
| Linux (Ubuntu) |
Raspbian (Raspberry Pi) |
Nuttx (STM32F4-Discovery) |
|
|---|---|---|---|
| fs.close | O | O | O |
| fs.closeSync | O | O | O |
| fs.open | O | O | O |
| fs.openSync | O | O | O |
| fs.read | O | O | O |
| fs.readSync | O | O | O |
| fs.readDir | O | O | X |
| fs.readDirSync | O | O | X |
| fs.readFile | O | O | O |
| fs.readFileSync | O | O | O |
| fs.rename | O | O | O |
| fs.renameSync | O | O | O |
| fs.stat | O | O | O |
| fs.statSync | O | O | O |
| fs.fstat | O | O | O |
| fs.fstatSync | O | O | O |
| fs.write | O | O | O |
| fs.writeSync | O | O | O |
| fs.writeFile | O | O | O |
| fs.writeFileSync | O | O | O |
| fs.unlink | O | O | O |
| fs.unlinkSync | O | O | O |
※ On nuttx path should be passed with a form of absolute path.
fd: Int- file descriptor.callback: Function(err)err: Error
Closes the file of fd asynchronously.
fd: Int- file descriptor.
Closes the file of fd synchronously.
path: String- file path to be opened.flags: String- open flags.mode: Number, Default:0666- permission mode.callback: Function(err, fd)err: Error-Errorobject if there was something wrong, otherwisenull.fd: Number- file descriptor.
path: String- file path to be opened.flags: String- open flags.mode: Number, Default:0666- permission mode.
fd: Int- file descriptor.buffer: Buffer- buffer that the data will be written to.offset: Number- offset of the buffer where to start writing.length: Number- number of bytes to read.position: Number- specifying where to start read data from the file, ifnull, read from current position.callback: Function(err, bytesRead, buffer)err: ErrorbytesRead: Numberbuffer: Buffer
fd: Int- file descriptor.buffer: Buffer- buffer that the data will be written to.offset: Number- offset of the buffer where to start writing.length: Number- number of bytes to read.position: Number- specifying where to start read data from the file, ifnull, read from current position.
path: String- file path to be opened.options: Object- options for the operation.encoding: String, Default:null- encoding of the file.flag: String, Default:r- file open flag.callback: Function(err, data)- callback function.err: Errordata: Buffer
Reads entire file asynchronously.
path: String- file path to be opened.options: Object- options for the operation.encoding: String, Default:null- encoding of the file.flag: String, Default:r- file open flag.
Reads entire file synchronously.
oldPath: String- old file pathnewPath: String- new file pathcallback: Function(err)- callback function.err: Error
Renames oldPath to newPath asynchronously.
oldPath: String- old file pathnewPath: String- new file path
Renames oldPath to newPath synchronously.
path: String- file path to be stated- callback: Function(err, stat)` - callback function.
err: Errorstat: Object
path: String- file path to be stated
fd: Number- file descriptor to be stated- callback: Function(err, stat)` - callback function.
err: Errorstat: Object
fd: Number- file descriptor to be stated
fs.Stats class is a object returned from fs.stat(),fs.fstat() and their synchronous counterparts.
Returns true if stated file is a directory
Returns true if stated file is a file
fd: Int- file descriptor.buffer: Buffer- buffer that the data will be written from.offset: Number- offset of the buffer where from start reading.length: Number- number of bytes to write.position: Number- specifying where to start write data to the file, ifnull, read from current position.- callback: Function(err, bytesWrite)` - callback function.
err: ErrorbyteWrite: Int
fd: Int- file descriptor.buffer: Buffer- buffer that the data will be written from.offset: Number- offset of the buffer where from start reading.length: Number- number of bytes to write.position: Number- specifying where to start write data to the file, ifnull, read from current position.
path: String- file path that thedatawill be writtendata: Buffer- buffer that contains dataoptions: Object- options for the operationcallback: Function(err)- callback functionerr: Error
Writes entire data to the file specified by path asynchronously.
path: String- file path that thedatawill be writtendata: Buffer- buffer that contains dataoptions: Object- options for the operation
Writes entire data to the file specified by path synchronously.
path: String- file path to be removedcallback: Function(err)err: Error
Removes the file specified by path asynchronously.
path: String- file path to be removed
Removes the file specified by path synchronously.