Module: fileOperations

Contains all of the functions required to do file operations on a physical/virtual hard drive and/or mounted volume. Including loading files, saving files, reloading files, resaving files, copying files, moving files, copying folders including copying folders recursively, zipping files and saving sip-packages as part of a deployment/release process.

Author:
  • Seth Hollingsead
Source:

Requires

Methods

(inner) appendMessageToFile(inputData, inputMetaData) → {boolean}

Opens a file and appends a message to the file, then closes the file.

Parameters:
Name Type Description
inputData string

The fully qualified path and file name for the file that should be opened, appended and saved.

inputMetaData string

The message that should be appended to the specified file.

Author:
  • Seth Hollingsead
Source:
Returns:

A True or False to indicate if the append happened successfully or not.

Type
boolean

(inner) buildReleasePackage(inputData, inputMetaData) → {boolean}

Add all the files from the source folder into a zip file and give a name to the file for the current date-time and release version, saving to the destination folder.

Parameters:
Name Type Description
inputData string

The folder that should be packaged up for the release zip file.

inputMetaData string

The folder where the zip file release package should be saved.

Author:
  • Seth Hollingsead
Source:
Returns:

A True or False value to indicate if the release package process is successful or not.

Type
boolean

(inner) cleanRootPath(inputData, inputMetaData) → {string}

Takes the application root path and cleans it to give a real root path. or top-level folder path for the application.

Parameters:
Name Type Description
inputData string

Not used for this business rule.

inputMetaData string

Not used for this business rule.

Source:
Returns:

The real rot path or top-level path for the application.

Type
string

(inner) copyAllFilesAndFoldersFromFolderToFolder(inputData, inputMetaData) → {boolean}

Copies all of the files and folders recursively from the source folder to the destination folder.

Parameters:
Name Type Description
inputData array.<string>

An array containing the source and destination paths. Example: inputData[0] = source path inputData[1] = destination path

inputMetaData array.<array.<string>>

Two array's of strings that are exclusions and inclusions, file filters that should be avoided during the copy process, the inclusion array over-rides the exclusion array. Example: filterArray[0] = exclusion array filterArray[1] = inclusion array

Author:
  • Seth Hollingsead
Source:
Returns:

A True or False value to indicate if the full copy process is successful or not.

Type
boolean

(inner) copyFileSync(inputData, inputMetaData) → {boolean}

Reads the files from the source and copies them to the target, ignoring any files that match with any of the contents of the exclusionArray.

Parameters:
Name Type Description
inputData array.<string>

An array containing the source and destination paths. Example: inputData[0] = source path inputData[1] = destination path

inputMetaData array.<array.<string>>

Two array's of strings that are exclusions and inclusions, file filters that should be avoided during the copy process, the inclusions array over-rides the exclusion array. Example: inputMetaData[0] = exclusionArray inputMetaData[1] = inclusionArray

Author:
  • Simon Zyx
Source:
Returns:

A True or False to indicate if the copy operation was successful or not.

Type
boolean

(inner) copyFolderRecursiveSync(inputData, inputMetaData) → {boolean}

Copies a folder and all of its files and sub-folders and sub-files recursively.

Parameters:
Name Type Description
inputData array.<string>

An array containing the source and destination paths. Example: inputData[0] = source path inputData[1] = destination path

inputMetaData array.<array.<string>>

Two array's of strings that are exclusions and inclusions, file filters that should be avoided during the copy process, the inclusion array over-rides the exclusion array. Example: inputMetaData[0] = exclusionArray inputMetaData[1] = inclusionArray

Author:
  • Simon Zyx
Source:
Returns:

A True or False value to indicate fi the copy operation was a success or not.

Type
boolean

(inner) createZipArchive(inputData, inputMetaData) → {boolean}

Creates a new zip archive of the files listed in the input array, and saves the file to the specified file path and name.

Parameters:
Name Type Description
inputData array.<string>

All the folders and paths to include in the zip archive.

inputMetaData string

The full path and file name to the destination where the zip file should be saved.

Author:
  • Seth Hollingsead
Source:
Returns:

A True or False value to indicate if the zip file was created successfully or not.

Type
boolean

(inner) getCsvData(inputData, inputMetaData) → {object}

Loads the specified file and parses it into JSON objects.

Parameters:
Name Type Description
inputData string

The path and file name of the CSV file that should be loaded and parsed into JSON objects.

inputMetaData string

Not used for this business rule.

Author:
  • Seth Hollingsead
Source:
Returns:

The JSON object as it was loaded from the file with minimal to no additional processin.

Type
object

(inner) getDirectoryList(inputData, inputMetaData) → {array.<string>}

Scans the specified path and returns the list of folders at that level. Does not scan recursively.

Parameters:
Name Type Description
inputData string

The path that should be scanned for getting a folder list at that folder level.

inputMetaData string

Not used for this business rule.

Author:
  • Seth Hollingsead
Source:
Returns:

The list of folders found at the specified path.

Type
array.<string>

(inner) getJsonData(inputData, inputMetaData) → {object}

Loads the specified file and parses it into a JSON object(s).

Parameters:
Name Type Description
inputData string

The path and file name of the JSON file that should be loaded and parsed into JSON objects.

inputMetaData string

Not used for this business rule.

Author:
  • Seth Hollingsead
Source:
Returns:

The JSON object as it was loaded from the file with minimal to no additional processing.

Type
object

(inner) getXmlData(inputData, inputMetaData) → {object}

Loads the specified file and parses it into JSON objects, all strings.

Parameters:
Name Type Description
inputData string

The path and file name of the XML file that should be loaded and parsed into JSON objects.

inputMetaData string

Not used for this business rule.

Author:
  • Seth Hollingsead
Source:
Returns:

A parsed JSON object containing all of the data, meta-data, objects, values and attributes that were stored in the specified XML file.

Type
object

(inner) readDirectoryContents(inputData, inputMetaData) → {object}

This function acts as a wrapper for calling readDirectorySynchronously since that function is recursive. Also that function doesn't technically return anything, it works with a global variable that needs to be reset after the work is done with it. So these are the things that this wrapper function can do.

Parameters:
Name Type Description
inputData string

The path that needs to be scanned.

inputMetaData string

Not used for this business rule.

Author:
  • Seth Hollingsead
Source:
Returns:

An object containing any array of all the files in the folder and all sub-folders.

Type
object

(inner) readDirectorySynchronously(inputData, inputMetaData) → {object}

Recursively parses through all the sub-folders in a given path and loads all of the files contained in each sub-folder into a map.

Parameters:
Name Type Description
inputData string

The system path that should be scanned recursively for files.

inputMetaData string

Not used for this business rule.

Author:
  • wn050
Source:
Returns:

A map of all the files contained in all levels of the specified path in all the folders and sub-folders.

Type
object

(inner) scanDirectoryContents(inputData, inputMetaData) → {array.<string>}

This function also acts as a wrapper for calling readDirectorySynchronously since that function is recursive. The difference between this function and the readDirectoryContents is that this function has an optional limit on the number of files to return. Really this is used for scanning large volumes of data such as the entire C-Drive. This way the user can control the number of files that are returned by the system. The user might only want 10,000 files or just the first million files found. etc...

Parameters:
Name Type Description
inputData string

The path that should be scanned for files including all sub-folders and all sub-files.

inputMetaData array.<boolean, integer>

An array that contains a boolean flag for enable the limit and an integer for what the limit should be: inputMetaData[0] = enableLimit - True or False to indicate if the boolean imit should be enabled or not. inputMetaData[1] = filesLimit - The number of files that should be limited when scanning, if the enableLimit is set to True.

Author:
  • Seth Hollingsead
Source:
Returns:

An array of all the files in the folder up to the limit if specified.

Type
array.<string>

(inner) writeJsonData(inputData, inputMetaData) → {boolean}

Writes out JSON data to the specified file and path location, it will automatically over-write any existing file.

Parameters:
Name Type Description
inputData string

The path and file name for the file that should have data written to it.

inputMetaData object

The data that should be written to the specified file.

Author:
  • Seth Hollingsead
Source:
Returns:

True of False to indicate if the file was written out successfully or not.

Type
boolean