dirutils () documon/src/dirutils.js 12
xpath documon.dirutils
file documon/src/dirutils.js

A collection of utilities for manipulating directories syncronously.

Methods
copydir (from, to) documon/src/dirutils.js 193

Copies the entire folder's heirarchy folder from one location to another. If the other location doesn't exists, it will be constructed.

Parameters
from
string

The source folder

to
string

The destination folder (get's created if not exist)

emptydir (who, dryRun) documon/src/dirutils.js 224

Recursively empties a folder of all it's contents (and all the sub-folder's contents), but leaves the source folder.

Parameters
who
string

The source folder

dryRun
boolean

Prevents actual deletion, but still allows the return list to display what "will" be deleted.

Returns array

An array containing a list of paths to files and folders that we're deleted (or will be deleted when dryrun is true)

exists (who) documon/src/dirutils.js 283

Checks to see if a folder exists.

Parameters
who
string

The path to the folder.

Returns boolean

duh duh

makedir (dest) documon/src/dirutils.js 43

Creates a folder at the specified location. The sub-folder heirarchy is
constructed as needed.

For example if a folder exists here:

 /path/to/folder

… but the following sub-folders don't exists:

/path/to/folder/sub/one/two/three

… Then the "sub/one/two/three" tree will be constructed inside "/path/to/folder")

Parameters
dest
string path/to/make

The destination folder to create

readdir (from, filter, recursive, store) documon/src/dirutils.js 144

Read a folder and returns an object containing all of the files and
folder in arrays.

Parameters
from
string

The path to the folder to read.

filter
function

A custom filter funciton.

recursive
boolean

Should we retrieve sub-folders too?

store
object

Used internally to store recursive findings.
Note that you may also provide this argument and readdir will populate your
existing files/folder list. But is recommended to leave this argument alone.

Returns object

An object containing a list of "files" and "folders"
(as properties of the returned list), where each is an array.

Example
 var contents = readdir("/path/to/folder", null, true);
 // yeids contents {
//      files : [
//                  "/path/to/folder/1.foo",
//                  "/path/to/folder/2.bar",
//                  "/path/to/folder/3.png",
//                  "/path/to/folder/sub1/1.foo",
//                  "/path/to/folder/sub2/2.bar",
//                  "/path/to/folder/sub3/3.png"
//              ],
//      dirs : [
//                  "/path/to/folder/sub1",
//                  "/path/to/folder/sub2",
//                  "/path/to/folder/sub3"
// 
//              ]
// }
readExt (from, exts, recursive) documon/src/dirutils.js 79

Collects files from a folder based on the specified extension (or
extensions). Can be used to search recursively through all sub-folders, and can
search multiple extensions.

Provided as shortcut for readdir with your own
extension-checking filter.

Parameters
from
string

The path to search

exts
string | array optional

The extension to look for (e.g. "jpg"). To
search for multiple extensions, use an array e.g. ["jpg", "png", "gif"]

recursive
boolean optional

Find all matching files in all
sub-folders.

Returns array

The resulting array contains only files that mathc the
specified extension(s).

removedir (who, dryRun) documon/src/dirutils.js 261

Recursively removes a folder and all of it's sub-folders as well.

Parameters
who
string

The path to the folder

dryRun
boolean

Prevents actual deletion, but still allows the return to return the list of items that "will" be deleted.

Returns array

An array of all the items that were deleted (or "will be" deleted if dryrun is true.