fs-helper

A helper library to provide provide additonal functions for commonly performed file system operations.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
fs-helper
020.1.38 years ago8 years agoMinified + gzip package size for fs-helper in KB

Readme

fs-helper

Overview

This is a node module created in order help provide additonal functions for commonly performed file system operations.

Methods

getDirPathsRecursivelyByNameSync(currentdirectory, subdirectorynames, subdirectoriesfound)

Description

This function takes in the top level directory to search, an array of directory names that are the desired name to be located. There is also an optional parameter "subdirectoriesfound", which is used for recursive calls to this function.
Then it recursively searches sub-directories for directory names that are contained in the "subdirectory
names". If a directory is found that exists in "subdirectorynames" it is added to the "subdirectoriesfound" array.
This returns an array of the paths to each subdirectory with the matching directory path that was found.

Example Usage

Directory Structure:
/Users/username/node project/
|directories
    |
example directory
        |file.txt
    |
not example directory
        |file.txt
|
other directories
    |example directory
        |
file.txt
    |not example directory
        |
file.txt
var subdir_paths = fsHelper.getDirPathsRecursivelyByNameSync('/Users/username/node project/', ['example directory']);

The result of this operation is that subdirpaths will contain the strings:
  • /Users/username/node project/directories/example directory
  • /Users/username/node project/other directories/example directory