Useful functionalities, while working with file system.
- Copyright:
-
- Rapp Project EU 2015
- Source:
Methods
-
<inner> appendLine(str, dest)
-
Append a text into new line into destination file.
Parameters:
Name Type Description str
String Text string to append to file. dest
String Destination file path. - Source:
Returns:
- Success index on appendLine operation- Type
- boolean
-
<inner> copyFile.(file, dest)
-
Copies file from-To. Uses read/write streams and pipes.
Parameters:
Name Type Description file
File (given with either relative or absolute path to copy dest
Destination to copy the file. - Source:
Returns:
- Success index of the copy-file operation. True if file was succesfully copied, false otherwise.- Type
- boolean
-
<inner> createDirRecur(dirPath)
-
Create directory recursively --> a/b/c/d
Parameters:
Name Type Description dirPath
String Directory system path. - Source:
-
<inner> fileSize(_fileURL)
-
Getting File Size without Reading Entire File.
Parameters:
Name Type Description _fileURL
String File System Url. - Source:
Returns:
- Size of the file in bytes.- Type
- number
-
<inner> isDirectory(_path)
-
Check if a path is a directory
Parameters:
Name Type Description _path
String System path. - Source:
Returns:
- True if is directory, false otherwise.- Type
- boolean
-
<inner> lsSync(_dir)
-
brief Reads the contents of a given directory path.
Parameters:
Name Type Description _dir
String Directory path. Works both with relative and absolute paths. - Source:
Returns:
- Array that holds the contents of the directory.- Type
- Array
-
<inner> parentDir(_path)
-
Returns the parent directory name of a path.
Parameters:
Name Type Description _path
String System path. - Source:
Returns:
- The parent directory. In case of error a zero 0 value will be returned.- Type
- String
-
<inner> readFileSync(_file, _encoding)
-
Node.js readFileSync function wrapper
Parameters:
Name Type Description _file
File to be read, specified by path. _encoding
Encoding type of returned data readen from the specified file. Can be one of the following: "buffer" OR undefined Raw data from buffer. "string/ascii" Ascii encoded string. "string/binary" Binary encoded string. - Source:
Returns:
-
file - Custom file object.
- Type
- Object
-
file.data - Data payload.
- Type
- String
-
file.encoding - Data encoding.
- Type
- String
-
file.basename - File basename.
- Type
- String
-
file.absolutePaht - File absolute system path.
- Type
- String
-
file.size - File size. Has the following parameters:
- bytes
- kilobytes
- Type
- Object
-
<inner> renameFile(fileOld, fileNew)
-
Rename file. Can also be used as a funcitonality to copy files.
Parameters:
Name Type Description fileOld
Source file path. fileNew
Destination file path. - Source:
Returns:
- Success index of the rename-file operation. True if file was succesfully renamed, false otherwise.- Type
- boolean
-
<inner> rmFile(filepath)
-
Parameters:
Name Type Description filepath
String The file system path - Source:
-
<inner> rmFileSync(filepath)
-
Parameters:
Name Type Description filepath
String The file system path - Source:
-
<inner> text2File(_data, _filePath)
-
Writes ascii encoded strings in a give file. DEPRECATED!!!
Parameters:
Name Type Description _data
String | Buffer Data to be written. Can be both a buffer or string. _filePath
String Destination file path. - Source:
Returns:
Undefined. -
<inner> writeFileSync(_dest, _data)
-
Node.js writeFileSync method wrapper
Parameters:
Name Type Description _dest
Destination file name to write the data, specified by path. _data
Data to be written. - Source:
Returns:
- Success index on this operation.- Type
- boolean