file-system — Simplified file system
This module make file opertaion apis simple, you don't need to care the dir exits. and the api is same as node's filesystem. This is no exists time cost for this plugin.
var fs = ; fs;fs;fs
install
npm install file-system --save
API
.fs
file extend node fs origin methods, and overwrite some methods with next list chart
var file = ;var fs = ; filereadFile === fsreadFile // true
.mkdir
The api is same as node's mkdir
.mkdirSync
The api is same as node's mkdir
.writeFile
The api is same as node's writeFile
.writeFileSync
The api is same as node's writeFile
.fileMatch
The api equal file-match
.copyFile(srcpath, destpath, options)
Asynchronously copy a file into newpath
- {string}
srcpath
required - {string}
destpath
required - {object}
options
- {string}
options.encoding
[options.encoding=utf8] - {function}
options.done(err)
- {function}
options.process(content)
The process argument must return processed content
- {string}
fs;
.copyFileSync(srcpath, destpath, options)
The api same as copyFile, but it's synchronous
fs;fs
.recurse(dirpath, filter, callback)
Recurse into a directory, executing callback for each file and folder. if the filename is undefiend, the callback is for folder, otherwise for file.
- {string}
dirpath
required - {string|array|function}
filter
If the filter is function, executing callback for all files and folder - {function}
callback(filepath, filename, relative)
fs; fs; // Only using filesfs;
.recurseSync(dirpath, filter, callback)
The api is same as recurse, but it is synchronous
fs; fs;
.rmdirSync(dirpath)
Recurse into a directory, remove all of the files and folder in this directory.
fs;
.copySync(dirpath, destpath, options)
Recurse into a directory, copy all files into dest.
- {string}
dirpath
required - {string}
destpath
required - {object}
options
- {string|array}
options.filter
- {function}
options.process(contents, filepath, relative)
If custom the destpath, return object, otherwise return content - {string|array}
options.noProcess
- {string|array}
fs; fs; fs; fs; //Handler self filesfs;
.base64
Deprecated, move to base64
.base64Sync
Deprecated, move to base64Sync