SyNode file-system routines. We try to implement here the same interface as in NodeJS fs

 var fs = require('fs');
 var content = fs.readFileSync('c:\\a.txt', 'utf-8);

Members

# ReadStream static

Fake class for nodeJS compatibility

Methods

# appendFileSync (fileNameString, dataArrayBuffer | Object | String, optionsoptObject) static

Append data to a file, creating the file if it not yet exists Actually implement {UBWriter#write}

Arguments:
  • fileName: String

    Full absolute file path

  • data: ArrayBuffer| Object| String

    Data to write. Object are stringified before write

  • options: Object
    • encodingString

      Encode data to encoding before write. Default to utf-8 in case data is String or bin in case data is ArrayBuffer. Possible values: "utf-8"|"ucs2"|"bin"|"base64"|"base64toBin". base64toBin applicable only if data is Buffer alike

# existsSync (path) → Boolean static

Check path exists (can be file, folder or symlync)

Arguments:
  • path:

# isDir (path) → Boolean static

Check specified path is folder (or symlynk to folder)

Arguments:
  • path:

# isFile (path) → Boolean static

Check specified path is file (or symlynk to file)

Arguments:
  • path:

# loadFile (fileNameString, forceUFT8optBoolean) → String static

Reads the entire contents of a TEXT file. If BOM found - decode text file to string using BOM If BOM not found - use forceUFT8 parameter.

Arguments:
  • fileName: String
  • forceUFT8: Boolean

    If no BOM found and forceUFT8 is True (default) - we expect file in UTF8 format, else in ascii

# mkdirSync (pathString, modeoptNumber) static

Create all missing folders in the given path. Only absolute path supported. Throw error in case of fail

Arguments:
  • path: String

    path for creation.

  • mode: Number

    Ignored under Windows

# realpathSync () static

Synchronous realpath(3). Returns the resolved path (resolve symlinks, junctions on Windows, /../)

# renameSync (oldPathString, newPathString) static

Move (rename) file.

Arguments:

# rmdirSync (pathString) static

Delete non-empty directory. See removeDir for details

Arguments:

# writeFileSync (fileNameString, dataArrayBuffer | Object | String, optionsoptObject) static

Write to file Actually implements UBWriter#write

Arguments:
  • fileName: String

    Full absolute file path

  • data: ArrayBuffer| Object| String

    Data to write. If Object - it stringify before write

  • options: Object
    • encodingString

      Encode data to encoding before write. Default to utf-8 in case data is String or bin in case data is ArrayBuffer. One of "utf-8"|"ucs2"|"bin"|"base64"|"base64toBin". base64toBin applicable only if data is Buffer alike

# readdirSync (pathString) → Array.<String> inner

Read file names from directory (include folder names). Return array of file names. In case directory not exists - throw error

Arguments:

# readFileSync (fileNameString, optionsoptObject) → String | ArrayBuffer inner

Reads the entire contents of a file. If options.encoding == 'bin', then the ArrayBuffer is returned. If no options is specified at all - result is String as in fs.loadFile

Arguments:
  • fileName: String

    Absolute path to file

  • options: Object
    • encodingString | Null

      Default to null. Possible values: 'bin'|'ascii'|'utf-8'

# statSync (fileName) → Boolean | Object inner

Get file statistics. Will throw in case file or folder does not exists.

Arguments:
  • fileName:

# unlinkSync () inner

Delete file.