-
<async> exists(filename [, followSymlinks])
-
Check if filename exists
Parameters:
Name |
Type |
Argument |
Default |
Description |
filename |
string
|
|
|
File path |
followSymlinks |
boolean
|
<optional>
|
true
|
Check the file symlink points to |
Returns:
Resolves to boolean
-
Type
-
Promise
-
<async> read(fd)
-
Read file descriptor
Parameters:
Name |
Type |
Description |
fd |
number
|
File descriptor |
Returns:
Resolves to file contents as Buffer
-
Type
-
Promise
-
<async> write(fd, buffer)
-
Write to file descriptor
Parameters:
Name |
Type |
Description |
fd |
number
|
File descriptor |
buffer |
Buffer
|
New contents of the file |
Returns:
Resolves to true on success
-
Type
-
Promise
-
<async> lockReadBuffer(filename)
-
Lock a file (shared) and read it returning as a Buffer. Maximum file size is Buffer.kMaxLength bytes.
File must exist.
Parameters:
Name |
Type |
Description |
filename |
string
|
File path and name |
Returns:
Resolves to Buffer of file contents
-
Type
-
Promise
-
<async> lockRead(filename)
-
Do .lockReadBuffer() and return it as UTF8 string
Parameters:
Name |
Type |
Description |
filename |
string
|
File path and name |
Returns:
Resolves to file contents
-
Type
-
Promise
-
<async> lockWriteBuffer(filename, buffer [, params])
-
Lock a file (exclusively) and write to it
Parameters:
Name |
Type |
Argument |
Description |
filename |
string
|
|
File path and name |
buffer |
Buffer
|
|
New file contents |
params |
object
|
<optional>
|
File parameters (not changed if omitted)
Properties
Name |
Type |
Argument |
Default |
Description |
mode |
number
|
<optional>
|
null
|
Mode |
uid |
number
|
<optional>
|
null
|
UID |
gid |
number
|
<optional>
|
null
|
GID |
|
Returns:
Resolves to true on success
-
Type
-
Promise
-
<async> lockWrite(filename, contents [, params])
-
Convert string to a Buffer and do a .lockWriteBuffer()
Parameters:
Name |
Type |
Argument |
Description |
filename |
string
|
|
File path and name |
contents |
string
|
|
New file contents |
params |
object
|
<optional>
|
File parameters (not changed if omitted)
Properties
Name |
Type |
Argument |
Default |
Description |
mode |
number
|
<optional>
|
null
|
Mode |
uid |
number
|
<optional>
|
null
|
UID |
gid |
number
|
<optional>
|
null
|
GID |
|
Returns:
Resolves to true on success
-
Type
-
Promise
-
<async> lockUpdateBuffer(filename, cb [, params])
-
Lock a file (exclusively) and update it using Buffer
Parameters:
Name |
Type |
Argument |
Description |
filename |
string
|
|
File path and name |
cb |
BufferFileUpdater
|
|
Buffer updater callback |
params |
object
|
<optional>
|
File parameters (not changed if omitted)
Properties
Name |
Type |
Argument |
Default |
Description |
mode |
number
|
<optional>
|
null
|
Mode |
uid |
number
|
<optional>
|
null
|
UID |
gid |
number
|
<optional>
|
null
|
GID |
|
Returns:
Resolves to true on success
-
Type
-
Promise
-
<async> lockUpdate(filename, cb [, params])
-
Lock a file (exclusively) and update it using string
Parameters:
Name |
Type |
Argument |
Description |
filename |
string
|
|
File path and name |
cb |
StringFileUpdater
|
|
String updater callback |
params |
object
|
<optional>
|
File parameters (not changed if omitted)
Properties
Name |
Type |
Argument |
Default |
Description |
mode |
number
|
<optional>
|
null
|
Mode |
uid |
number
|
<optional>
|
null
|
UID |
gid |
number
|
<optional>
|
null
|
GID |
|
Returns:
Resolves to true on success
-
Type
-
Promise
-
<async> createDirectory(filename [, params])
-
Create a directory (recursively)
Parameters:
Name |
Type |
Argument |
Description |
filename |
string
|
|
Absolute path of the directory |
params |
object
|
<optional>
|
File parameters (not changed if omitted)
Properties
Name |
Type |
Argument |
Default |
Description |
mode |
number
|
<optional>
|
null
|
Mode |
uid |
number
|
<optional>
|
null
|
UID |
gid |
number
|
<optional>
|
null
|
GID |
|
Returns:
Resolves to true on success
-
Type
-
Promise
-
<async> createFile(filename [, params])
-
Create a file (its base dir must exist)
Parameters:
Name |
Type |
Argument |
Description |
filename |
string
|
|
Absolute path of the file |
params |
object
|
<optional>
|
File parameters (not changed if omitted)
Properties
Name |
Type |
Argument |
Default |
Description |
mode |
number
|
<optional>
|
null
|
Mode |
uid |
number
|
<optional>
|
null
|
UID |
gid |
number
|
<optional>
|
null
|
GID |
|
Returns:
Resolves to true on success
-
Type
-
Promise
-
<async> remove(filename)
-
Remove a file or directory recursively
Parameters:
Name |
Type |
Description |
filename |
string
|
Absolute path of a file or directory |
Returns:
Resolves to true on success
-
Type
-
Promise
-
<async> process(filename [, cbFile] [, cbDir])
-
Execute a callback for the filename if it is a file. If it is a directory then execute it for every file in that
directory recursively.
Execution is chained, if any of the callback invocations rejects then the entire process is rejected.
Parameters:
Name |
Type |
Argument |
Description |
filename |
string
|
|
Absolute path to the file or directory |
cbFile |
ProcessFileCallback
|
<optional>
|
The file callback. If resolves to false processing is terminated |
cbDir |
ProcessDirCallback
|
<optional>
|
The directory callback. Should resolve to true if this subdirectory
needs processing |
Returns:
Resolves to true on success if filename exists or to false if it does not
-
Type
-
Promise