Functions -
file
copy | Copy file/directory in old path to new path. If new path already exists, this replaces the file. |
createDir | Creates a new directory with the specified file name. If parentDirs flag is true, Creates a directory in specified path with any necessary parents. |
createFile | Creates a file in specified file path. Truncates if file already exists in the given path. |
exists | Reports whether file or directory exists for the given the path. |
getCurrentDirectory | Returns the current working directory. |
getFileInfo | Returns metadata information of the file specified in file path. |
readDir | Reads the directory and returns a list of files and directories # inside the specified directory |
remove | Removes the specified file or directory. If recursive flag is true, Removes the path and any children it contains. |
rename | Renames(Moves) old path to new path. If new path already exists and it is not a directory, this replaces the file. |
tempDir | Returns the default directory to use for temporary files. |
Copy file/directory in old path to new path. If new path already exists, this replaces the file.
Parameters
- sourcePath string
-
String value of old file path.
- destinationPath string
-
String value of new file path.
- replaceExisting boolean - false
-
Flag to allow replace if file already exists in destination path.
-
Return Type
(Error?) Returns an
Error
if failed to rename.
Creates a new directory with the specified file name. If parentDirs flag is true, Creates a directory in specified path with any necessary parents.
Parameters
- dir string
-
directory name.
- parentDirs boolean - false
-
Indicates whether the
createDir
should create non-existing parent directories.
-
Return Type
(string | Error) Returns absolute path value of the created directory or an
Error
if failed
Creates a file in specified file path. Truncates if file already exists in the given path.
Parameters
- path string
-
String value of file path.
-
Return Type
(string | Error) Returns absolute path value of the created file or an
Error
if failed
Reports whether file or directory exists for the given the path.
Parameters
- path string
-
String value of file path.
-
Return Type
(boolean) True if path is absolute, else false
Returns the current working directory.
-
Return Type
(string) Current working directory or an empty string if the current working directory cannot be determined
Returns metadata information of the file specified in file path.
Parameters
- path string
-
String value of the file path.
Reads the directory and returns a list of files and directories # inside the specified directory
Parameters
- path string
-
String value of directory path.
- maxDepth int - -1
-
The maximum number of directory levels to visit. -1 to indicate that all levels should be visited.
Removes the specified file or directory. If recursive flag is true, Removes the path and any children it contains.
Parameters
- path string
-
String value of file/directory path.
- recursive boolean - false
-
Indicates whether the
remove
should recursively remove all the file inside the given directory.
-
Return Type
(Error?) Returns an
Error
if failed to remove.
Renames(Moves) old path to new path. If new path already exists and it is not a directory, this replaces the file.
Parameters
- oldPath string
-
String value of old file path.
- newPath string
-
String value of new file path.
-
Return Type
(Error?) Returns an
Error
if failed to rename.