Files Class
Ported fileutils methods from Selleck
Item Index
Methods
copyAssets
-
from
-
dest
-
deleteFirst
-
callback
Copy the theme assets directory
Parameters:
-
from
PathThe source directory
-
dest
PathThe destination directory
-
deleteFirst
BooleanShould the directory be deleted if it exists
-
callback
FunctionThe callback to be executed
copyDirectory
-
source
-
dest
-
[overwrite=false]
-
callback
Copy a directory from one location to another
Parameters:
-
source
PathThe source directory
-
dest
PathThe destination directory
-
[overwrite=false]
Boolean optionalWhether or not to overwrite destination files if they already exist.
-
callback
FunctionThe callback to be executed when complete.
copyFile
-
source
-
dest
-
[overwrite=false]
-
callback
Copy a file from one location to another
Parameters:
-
source
PathThe source file
-
dest
PathThe destination file
-
[overwrite=false]
Boolean optionalWhether or not to overwrite destination files if they already exist.
-
callback
CallbackThe callback to be executed when complete.
-
err
ErrorThe Error returned from Node
-
copyPath
-
source
-
dest
-
[overwrite=false]
-
callback
If source is a file, copies it to dest. If it's a directory, recursively copies it and all files and directories it contains to dest.
Note that when attempting to copy a file into a directory, you should specify the full path to the new file (including the new filename). Otherwise, it will be interpreted as an attempt to copy the source file over the dest directory instead of into it.
Known issues:
- Doesn't preserve ownership or permissions on copied files/directories.
Parameters:
-
source
StringSource path.
-
dest
StringDestination path.
-
[overwrite=false]
Boolean optionalWhether or not to overwrite destination files if they already exist.
-
callback
CallbackThe callback to execute when completed.
-
err
Error
-
deletePath
-
path
If path is a file, deletes it. If path is a directory, recursively deletes it and all files and directories it contains.
This method is synchronous.
Parameters:
-
path
StringFile or directory to delete.
getJSON
-
filename
Helper method for getting JSON data from a local file
Parameters:
-
filename
PathThe filename to parse JSON from
Returns:
The JSON data
isDirectory
-
path
-
[link=false]
Check to see if this is a directory
Parameters:
-
path
PathThe path to check
-
[link=false]
Boolean optionalAlso validate a symlink
Returns:
True if it is a directory
isFile
-
path
-
[link=false]
Check to see if this is a File
Parameters:
-
path
PathThe path to check
-
[link=false]
Boolean optionalAlso validate a symlink
Returns:
True if it is a file
isSymbolicLink
-
path
Check to see if this is a SymLink
Parameters:
-
path
PathThe path to check
Returns:
True if it is a link
lstatSync
-
path
Like fs.lstatSync()
, but returns null
instead of throwing when path
doesn't exist. Will still throw on other types of errors.
Parameters:
-
path
StringPath to stat.
Returns:
fs.Stats
object, or null
if path doesn't exist.
statSync
-
path
Like fs.statSync()
, but returns null
instead of throwing when path
doesn't exist. Will still throw on other types of errors.
Parameters:
-
path
StringPath to stat.
Returns:
fs.Stats
object, or null
if path doesn't exist.
writeFile
-
file
-
data
-
callback
Helper method for writing files to disk. It wraps the NodeJS file API
Parameters:
-
file
PathThe filename to write to
-
data
StringThe data to write
-
callback
Callback multiple