# HG changeset patch # User Yaroslav Zhuravlev # Date 1530018787 -10800 # Node ID 001f2d905fd9ec9d796a9c1296e7f996ee8e2285 # Parent 56a8cfb422ae58305f1ff7d5d1b0b889069f6657 Documented fileSystem methods in njs. diff -r 56a8cfb422ae -r 001f2d905fd9 xml/en/docs/njs/njs_api.xml --- a/xml/en/docs/njs/njs_api.xml Tue Jun 26 10:31:33 2018 +0300 +++ b/xml/en/docs/njs/njs_api.xml Tue Jun 26 16:13:07 2018 +0300 @@ -622,6 +622,192 @@ + +
+ + +The File System module provides operations with files. +The module object is returned by require('fs'). + + +appendFileSync(filename, +data[, options]) + +Synchronously appends specified data +to a file with provided filename. +If the file does not exist, it will be created. +The options parameter is expected to be +an object with the following keys: + + +mode + +mode option, by default is 0o666 + + +flag + +file system flag, +by default is a + + + + + +readFileSync(filename[, +options]) + +Synchronously returns the contents of the file +with provided filename. +The options parameter holds +string that specifies encoding. +If not specified, a byte string is returned. +If utf8 encoding is specified, a Unicode string is returned. +Otherwise, options is expected to be +an object with the following keys: + + +encoding + +encoding, by default is not specified. +The encoding can be utf8 + + +flag + +file system flag, +by default is r + + + + +>> var fs = require('fs') +undefined +>> var file = fs.readFileSync('/file/path.tar.gz') +undefined +>> var gzipped = /^\x1f\x8b/.test(file); gzipped +true + + + +writeFileSync(filename, +data[, +options]) + +Synchronously writes data to a file +with provided filename. +If the file does not exist, it will be created, +if the file exists, it will be replaced. +The options parameter is expected to be +an object with the following keys: + +mode + +mode option, by default is 0o666 + + +flag + +file system flag, +by default is w + + + + +>> var fs = require('fs') +undefined +>> var file = fs.writeFileSync('hello.txt', 'Hello world') +undefined + + + + + + + +
+ + +The flag option can accept the following values: + + + + +a—open a file for appending. +The file is created if it does not exist + + + +ax—the same as a +but fails if the file already exists + + + +a+—open a file for reading and appending. +If the file does not exist, it will be created + + + +ax+—the same as a+ +but fails if the file already exists + + + +as—open a file for appending in synchronous mode. +If the file does not exist, it will be created + + + +as+—open a file for reading and appending +in synchronous mode. +If the file does not exist, it will be created + + + +r—open a file for reading. +An exception occurs if the file does not exist + + + +r+—open a file for reading and writing. +An exception occurs if the file does not exist + + + +rs+—open a file for reading and writing +in synchronous mode. +Instructs the operating system to bypass the local file system cache + + + +w—open a file for writing. +If the file does not exist, it will be created. +If the file exists, it will be replaced + + + +wx—the same as w +but fails if the file already exists + + + +w+—open a file for reading and writing. +If the file does not exist, it will be created. +If the file exists, it will be replaced + + + +wx+—the same as w+ +but fails if the file already exists + + + + + +
+ +
+ @@ -770,7 +956,6 @@ holds the subrequest arguments string. Otherwise, options is expected to be an object with the following keys: - args