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');Members
ReadStream
static
Fake class for nodeJS compatibility
Methods
isFile(path) → Boolean
static
Check specified path is file (or symlynk to file)
Arguments:
-
path
isDir(path) → Boolean
static
Check specified path is folder (or symlynk to folder)
Arguments:
-
path
loadFile(fileName, forceUFT8opt) → 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
readFileSync(fileName, optionsopt) → String|ArrayBuffer
static
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:
mkdirSync(path, modeopt)
static
Create all missing folders in the given path. Only absolute path supported. Throw error in case of fail
Arguments:
readdirSync(path) → Array.<String>
inner
Read file names from directory (include folder names).
Return array of file names. In case directory not exists - throw error
Arguments:
-
path (String)
statSync(fileName) → Boolean|Object
inner
Get file statistics. Return false in case file or folder dose not exists.
Arguments:
-
fileName
writeFileSync(fileName, data, optionsopt)
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)
Properties
-
[encoding] (String)  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".
appendFileSync(fileName, data, optionsopt)
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)
Properties
-
[encoding] (String)  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".
existsSync(path) → Boolean
static
Check path exists (can be file, folder or symlync)
Arguments:
-
path
unlinkSync()
inner
Delete file.
rmdirSync(path)
static
Delete non-empty directory. See removeDir for details
Arguments:
-
path (String)  path to remove
renameSync(oldPath, newPath)
static
Move (rename) file.
Arguments:
isFile(path) → Boolean static
Check specified path is file (or symlynk to file)
Arguments:
-
path
isDir(path) → Boolean static
Check specified path is folder (or symlynk to folder)
Arguments:
-
path
loadFile(fileName, forceUFT8opt) → 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
readFileSync(fileName, optionsopt) → String|ArrayBuffer static
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:
mkdirSync(path, modeopt) static
Create all missing folders in the given path. Only absolute path supported. Throw error in case of fail
Arguments:
readdirSync(path) → Array.<String> inner
Read file names from directory (include folder names).
Return array of file names. In case directory not exists - throw error
Arguments:
-
path(String)
statSync(fileName) → Boolean|Object inner
Get file statistics. Return false in case file or folder dose not exists.
Arguments:
-
fileName
writeFileSync(fileName, data, optionsopt) 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)Properties
-
[encoding](String) Encode data toencodingbefore write. Default toutf-8in case data is String orbinin case data is ArrayBuffer. One of "utf-8"|"ucs2"|"bin"|"base64".
-
appendFileSync(fileName, data, optionsopt) 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.Objectare stringified before write -
[options](Object)Properties
-
[encoding](String) Encode data toencodingbefore write. Default toutf-8in case data is String orbinin case data is ArrayBuffer. Possible values: "utf-8"|"ucs2"|"bin"|"base64".
-
existsSync(path) → Boolean static
Check
path exists (can be file, folder or symlync)
Arguments:
-
path
unlinkSync() inner
Delete file.
rmdirSync(path) static
Delete non-empty directory. See
removeDir for details
Arguments:
-
path(String) path to remove
renameSync(oldPath, newPath) static
Move (rename) file.