pathfileops

package module
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2019 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package 'pathfileops' provides software types and methods used in the management, organization and control of disk files and directories.

This package incorporates three primary types:

  1. FileHelper - A series of generalized file maintenance utilities

  2. DirMgr - Directory Manager: Designed for the creation, management and control of directory paths.

  3. FileMgr - File Manager: Designed for the creation, management and control of disk files.

In addition, the following are used to manage collections of 'DirMgr' and 'FileMgr' types.

  1. DirMgrCollection - Processes and manages collections of type 'DirMgr'

  2. FileMgrCollection - Processes and manages collections of type 'FileMgr'

  3. FileOpsCollection - Manages collections of operations performed on disk files and directories.

The source code repository for this package is located at:

https://github.com/MikeAustin71/pathfileopsgo

Index

Constants

This section is empty.

Variables

View Source
var FOpenMode = FileOpenMode(0)

FOpenMode - This public global variable allows easy access to the enumerations of the FileOpenMode using the dot operator.

Example:

  FileOpenMode(0).ModeAppend()
  FileOpenMode(0).ModeCreate()
  FileOpenMode(0).ModeExclusive()
View Source
var FOpenType = FileOpenType(0)

FOpenType - This public global variable allows easy access to the enumerations of the FileOpenType using the dot operator.

Example:

   FOpenType.TypeReadOnly()
   FOpenType.TypeWriteOnly()
   FOpenType.TypeReadWrite()
View Source
var FileOpCode = FileOperationCode(0)

FileOp - global variable of type FileOperationCode. Provides alternate, easier access to FileOperationCode enumeration values.

Usage:

FileOpCode.None()
FileOpCode.CopySourceToDestinationByIo()
View Source
var OsFilePermCode = OsFilePermissionCode(0)

OsFilePermCode - public global variable of type OsFilePermissionCode. Provides alternative, easier access to OsFilePermissionCode enumeration values.

Usage:

OsFilePermCode.ModeNone()
OsFilePermCode.ModeDir()

Functions

This section is empty.

Types

type DeleteDirFilesStats

type DeleteDirFilesStats struct {
	TotalFilesProcessed        uint64
	FilesDeleted               uint64
	FilesDeletedBytes          uint64
	FilesRemaining             uint64
	FilesRemainingBytes        uint64
	TotalSubDirectories        uint64
	TotalDirsScanned           uint64
	NumOfDirsWhereFilesDeleted uint64
	DirectoriesDeleted         uint64
}

type DirMgr

type DirMgr struct {
	// contains filtered or unexported fields
}

DirMgr - This type and its associated methods are used to manage directories, directory trees and directory permissions.

Dependencies:

Type 'DirMgr' depend on types, 'FileHelper' and 'FileMgr' which are contained in source code files, 'filehelper.go' and 'filemanager.go' located in this directory.

func (DirMgr) ConsolidateErrors

func (dMgr DirMgr) ConsolidateErrors(errors []error) error

ConsolidateErrors - Consolidates an array of errors into a single error.

func (*DirMgr) CopyDirectory

func (dMgr *DirMgr) CopyDirectory(
	targetDMgr DirMgr,
	fileSelectCriteria FileSelectionCriteria,
	copyEmptyDirectory bool) (dirCopyStats DirectoryCopyStats, errs []error)

CopyDirectory - Copies files from the directory identified by by DirMgr to a target directory. The files to be copied are selected according to file selection criteria specified by input parameter, 'fileSelectCriteria'.

The selected files are copied by a Copy IO operation. For information on the Copy IO procedure see FileHelper{}.CopyFileByIo() method and reference:

https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

NOTE: This method ONLY copies files from the current directory identified by 'DirMgr'. It does NOT copy files from subdirectories.

If the target directory does not exist and files are located matching the file selection criteria, this method will attempt to create the target directory. However, if no files meet the file selection criteria as defined by input parameter,'fileSelectCriteria', this method will NOT attempt to create the target directory.

This method is optimized to support the copy of large numbers of files.

------------------------------------------------------------------------------

Input Parameters:

targetDMgr   DirMgr - An instance of 'DirMgr' initialized with the directory
                      path of the target directory to which selected files
                      will be copied. If the target directory does not exist,
                      this method will attempt to create it.

fileSelectCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be copied
  to the directory identified by input parameter, 'targetDir'.

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and copied to the target directory.

Example:
  fsc := FileSelectCriterionMode{}

  In this example, 'fsc' is NOT initialized. Therefore,
  all of the selection criterion are 'Inactive'. Consequently,
  all of the files encountered in the target directory during
  the search operation will be selected and copied to the
  target directory.

---------------------------------------------------------------------------

Input Parameters (Continued):

copyEmptyDirectory bool - If set to 'true' the target directory will be
                          created regardless of whether any files are
                          copied to that directory. Remember that files
                          are only copied to the target directory if
                          they meet file selection criteria specified
                          by input parameter 'fileSelectCriteria'.

---------------------------------------------------------------------------

Return Value:

dirCopyStats DirectoryCopyStats - This type is used to return data on the
                                  copy operation.

errs     []error  - An array of errors is returned. If the method completes
                    successfully with no errors, a ZERO-length array is
                    is returned.

                    If errors are encountered they are stored in the error
                    array and returned to the caller.

func (*DirMgr) CopyDirectoryTree

func (dMgr *DirMgr) CopyDirectoryTree(
	targetDMgr DirMgr,
	copyEmptyDirectories bool,
	fileSelectCriteria FileSelectionCriteria) (dTreeCopyStats DirTreeCopyStats, errs []error)

CopyDirectoryTree - Copies all selected files in the directory tree to a specified target directory tree. If the target directory tree does not exist, this method will attempt to create it. See the details of target directory tree creation under input parameter 'copyEmptyDirectories'.

If input parameter 'copyEmptyDirectories' is set to 'true', the entire directory tree will be created and may contain empty directories. If set to false, target directory tree elements will only be created if files meet the selection criteria and are subsequently copied to those target directory tree paths.

Files eligible for copy to the target directory tree are selected on the basis of file selection criteria specified by input parameter, 'fileSelectCriteria'.

------------------------------------------------------------------------------

Input Parameters:

targetDMgr         DirMgr - An instance of 'DirMgr' initialized with the directory
                            path of the target directory to which selected files
                            will be copied. If the target directory does not exist,
                            this method will attempt to create it.

copyEmptyDirectories bool - If a target directory tree path does not previously exist,
                            the default behavior is to create that directory ONLY if
                            files matching the file selection criteria are identified
                            for that directory. If no files match the file selection
                            criteria, the default is to NOT create the target directory
                            path.

                            If the parameter 'copyEmptyDirectories' is set to 'true' all
                            target directory tree paths will be created regardless of
                            whether files are copied to those directories.

fileSelectCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be copied
  to the directory identified by input parameter, 'targetDir'.

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and returned as 'Found Files'.

Example:
  fsc := FileSelectCriterionMode{}

  In this example, 'fsc' is NOT initialized. Therefore,
  all of the selection criterion are 'Inactive'. Consequently,
  all of the files encountered in the target directory during
  the search operation will be selected and copy to target
  directory.

---------------------------------------------------------------------------

Return Value:

errs     []error  - An array of errors is returned. If the method completes
                    successfully with no errors, a ZERO-length array is
                    is returned.

                    If errors are encountered they are stored in the error
                    array and returned to the caller.

func (*DirMgr) CopyIn

func (dMgr *DirMgr) CopyIn(dMgrIn *DirMgr)

CopyIn - Receives a pointer to an incoming DirMgr object as an input parameter and copies the values from the incoming object to the current DirMgr object. When the copy operation is completed, the current DirMgr object is a duplicate of the incoming DirMgr object.

func (*DirMgr) CopyOut

func (dMgr *DirMgr) CopyOut() DirMgr

CopyOut - Makes a duplicate copy of the current DirMgr values and returns them in a new DirMgr object.

func (*DirMgr) CopySubDirectoryTree

func (dMgr *DirMgr) CopySubDirectoryTree(
	targetDMgr DirMgr,
	copyEmptyDirectories bool,
	fileSelectCriteria FileSelectionCriteria) (dTreeCopyStats DirTreeCopyStats, errs []error)

CopySubDirectoryTree - Treating the directory identified by the current 'DirMgr' instance as the parent directory, this method copies all sub-directories and the files contained in those sub-directories to the target directory specified by input parameter, 'targetDir'. Essentially, the entire directory tree with the sole exception of the top level parent directory is copied to target directory.

The files copied must match the selection criteria specified by input parameter 'fileSelectCriteria'.

If the target directory does not exist, and valid matching files are identified for that directory, this method will attempt to create the target directory. Conversely, if no files matching the file selection criteria are found, that corresponding target directory will NOT be created.

func (*DirMgr) DeleteAll

func (dMgr *DirMgr) DeleteAll() error

DeleteAll - BE CAREFUL!!! - This method will remove the directory identified by this DirMgr instance. It will also delete all child directories and files in the directory tree.

Example:

Run DeleteAll on Directory: "../pathfilego/003_filehelper/testdestdir/destdir"

All files and all subdirectories will be deleted.

Only the parent path will remain: "../pathfilego/003_filehelper/testdestdir"

func (*DirMgr) DeleteAllFilesInDir

func (dMgr *DirMgr) DeleteAllFilesInDir() (deleteDirStats DeleteDirFilesStats, errs []error)

DeleteAllFilesInDir - Deletes all the files in the current directory. ONLY files in the current directory are deleted. Sub-directories are NOT deleted and files in sub-directories are NOT deleted.

Reference: https://stackoverflow.com/questions/33450980/golang-remove-all-contents-of-a-directory

---------------------------------------------------------------------------

Return Value:

errs     []error  - An array of errors is returned. If the method completes
                    successfully with no errors, a ZERO-length array is
                    is returned.

                    If errors are encountered they are stored in the error
                    array and returned to the caller.

func (*DirMgr) DeleteAllSubDirectories

func (dMgr *DirMgr) DeleteAllSubDirectories() (errs []error)

DeleteAllSubDirectories - The directory identified by the current DirMgr instance is treated as the parent directory. This method will then proceed to delete all directories and files which are are subsidiary to this parent directory. Essentially, all sub- directories which are subordinate to the the DirMgr directory will be deleted along with their constituent files.

Example:
 Parent Directory:
  DirMgr = d:\parentdirectory
  files    d:\parentdirectory\file1.txt
           d:\parentdirectory\file2.txt

 Sub-Directories:
           d:\parentdirectory\dir01
           d:\parentdirectory\dir02
           d:\parentdirectory\dir03

After Executing DirMgr.DeleteAllSubDirectories() all sub-directories and
any files they contain will be deleted. The only directory which remains
is the parent directory and any files contained within the parent directory.

  DirMgr = d:\parentdirectory
  files    d:\parentdirectory\file1.txt
           d:\parentdirectory\file2.txt

func (*DirMgr) DeleteDirectoryTreeFiles

func (dMgr *DirMgr) DeleteDirectoryTreeFiles(
	deleteFileSelectionCriteria FileSelectionCriteria) (deleteDirStats DeleteDirFilesStats, errs []error)

DeleteDirectoryTreeFiles - Deletes files in the directory tree. The parent directory for this tree is the directory specified by the current 'DirMgr' instance. Files eligible for deletion must match the file selection criteria specified by input parameter 'deleteFileSelectionCriteria'. The file deletion operation will search the parent directory ('DirMgr') and all sub-directories screening for files which match the file selection criteria.

The file deletion operation is conducted in three steps:

  1. The criteria for selecting files to be deleted is created using input parameter 'deleteFileSelectionCriteria'.

  2. A file search is conducted which includes the DirMgr parent directory and all sub-directories in the tree.

  3. Files processed during the directory tree search are compared to the file selection criteria specified by 'deleteFileSelectionCriteria'. Those files which match the selection criteria are then deleted.

This method is similar to method 'DirMgr.DeleteWalkDirFiles()'. However, this method returns less data and is designed to work with very large numbers of files and directories.

Note: As a result of this operation, files within directory tree folders may be deleted, but the folders or directory elements will NEVER be deleted.

------------------------------------------------------------------------------

Input Parameters:

deleteFileSelectionCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be deleted.

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file modification
                                  date times in order to determine whether the file is
                                  older than the 'FilesOlderThan' file selection criterion.
                                  If the file modification date time is older than the
                                  'FilesOlderThan' date time, that file is considered a
                                  'match'	for this file selection criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and deleted.

Example:
  fsc := FileSelectCriterionMode{}

  In this example, 'fsc' is NOT initialized. Therefore,
  all of the selection criterion are 'Inactive'. Consequently,
  all of the files encountered in the target directory tree
  during the search operation will be selected and deleted.

---------------------------------------------------------------------------

Return Value:

deleteDirStats DeleteDirFilesStats - Statistics generated by the delete operation
                                     performed on the current directory identified
                                     by DirMgr.

errs                      []error  - An array of errors is returned. If the method
                                     completes successfully with no errors, a
                                     ZERO-length array is returned.

                                     If errors are encountered they are stored in
                                     the error array and returned to the caller.

func (*DirMgr) DeleteFilesByNamePattern

func (dMgr *DirMgr) DeleteFilesByNamePattern(
	fileSearchPattern string) (deleteDirStats DeleteDirFilesStats, errs []error)

DeleteFilesByNamePattern - Receives a string defining a pattern to use in searching file names for all files in the directory identified by the current DirMgr instance.

* BE CAREFUL!! * If a file name matches the pattern specified by input parameter, 'fileSearchPattern', it will be deleted.

Only files in the directory identified by the current DirMgr instance will be subject to deletion. Files in sub-directories or parent directories will NOT be deleted or altered in any way.

If the 'fileSearchPattern' is improperly formatted, an error will be returned.

If the directory path identified by the current DirMgr instance does NOT exist, an error will be returned.

------------------------------------------------------------------------

Example 'filePatterns'

*.*              will match  all files in directory
*.html           will match  anyfilename.html
a*               will match  appleJack.txt
j????row.txt     will match  j1x34row.txt
data[0-9]*       will match  data123.csv

Reference For Matching Details:
  https://golang.org/pkg/path/filepath/#Match

func (*DirMgr) DeleteFilesBySelectionCriteria

func (dMgr *DirMgr) DeleteFilesBySelectionCriteria(
	deleteFileSelectionCriteria FileSelectionCriteria) (deleteDirStats DeleteDirFilesStats, errs []error)

DeleteFilesBySelectionCriteria - Deletes selected files from the directory identified by the current 'DirMgr' instance.

Files in sub-directories are not deleted or altered in any way. ONLY files in the directory identified by the current 'DirMgr' instance are deleted.

The file deletion operation consists of three steps:

  1. The criteria for selecting files to be deleted is created using input parameter 'deleteFileSelectionCriteria'.

  2. A file search is conducted which is limited ONLY to the DirMg directory. Files in sub-directory tree ARE NEVER DELETED.

  3. Files processed during the directory search are compared to the file selection criteria specified by 'deleteFileSelectionCriteria'. Those files which match the selection criteria are then deleted.

------------------------------------------------------------------------------

Input Parameters:

deleteFileSelectionCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file selection
  criteria. Files in the DirMgr directory, matching this criteria, will be
  deleted.

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file modification
                                  date times in order to determine whether the file is
                                  older than the 'FilesOlderThan' file selection criterion.
                                  If the file modification date time is older than the
                                  'FilesOlderThan' date time, that file is considered a
                                  'match'	for this file selection criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and deleted.

Example:
  fsc := FileSelectCriterionMode{}

  In this example, 'fsc' is NOT initialized. Therefore,
  all of the selection criterion are 'Inactive'. Consequently,
  all of the files encountered in the target directory tree
  during the search operation will be selected and deleted.

---------------------------------------------------------------------------

Return Value:

errs     []error  - An array of errors is returned. If the method completes
                    successfully with no errors, a ZERO-length array is
                    is returned.

                    If errors are encountered they are stored in the error
                    array and returned to the caller.

func (*DirMgr) DeleteSubDirectoryTreeFiles

func (dMgr *DirMgr) DeleteSubDirectoryTreeFiles(
	deleteFileSelectionCriteria FileSelectionCriteria) (deleteDirStats DeleteDirFilesStats, errs []error)

DeleteSubDirectoryTreeFiles - Deletes sub-directory files. For this operation, the current 'DirMgr' is classified as the top level or parent directory. Files in this parent directory will NEVER BE DELETED.

!!! BE CAREFUL !!! This method deletes files in sub-directories!

Files eligible for deletion must match the file selection criteria specified by input parameter 'deleteFileSelectionCriteria'. The file deletion operation will exclude the parent directory ('DirMgr') and confine the file search to the sub-directories underneath the parent directory. The file search will screen for files which match the file selection criteria in the sub-directory tree.

The file deletion operation is conducted in three steps:

  1. The criteria for selecting files to be deleted is created using input parameter 'deleteFileSelectionCriteria'.

  2. A file search is conducted which excludes the DirMgr parent directory and focuses exclusively on all sub-directories in the tree.

  3. Files processed during the sub-directory tree search are compared to the file selection criteria specified by 'deleteFileSelectionCriteria'. Those files which match the selection criteria are then deleted.

Note: As a result of this operation, files within sub-directory tree folders may be deleted, but the folders or directory elements themselves will NEVER be deleted.

------------------------------------------------------------------------------

Input Parameters:

deleteFileSelectionCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be deleted.

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file modification
                                  date times in order to determine whether the file is
                                  older than the 'FilesOlderThan' file selection criterion.
                                  If the file modification date time is older than the
                                  'FilesOlderThan' date time, that file is considered a
                                  'match'	for this file selection criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and deleted.

Example:
  fsc := FileSelectCriterionMode{}

  In this example, 'fsc' is NOT initialized. Therefore,
  all of the selection criterion are 'Inactive'. Consequently,
  all of the files encountered in the target directory tree
  during the search operation will be selected and deleted.

---------------------------------------------------------------------------

Return Value:

deleteDirStats DeleteDirFilesStats - Statistics generated by the delete operation
                                     performed on the current directory identified
                                     by DirMgr.

errs                      []error  - An array of errors is returned. If the method
                                     completes successfully with no errors, a
                                     ZERO-length array is returned.

                                     If errors are encountered they are stored in
                                     the error array and returned to the caller.

func (*DirMgr) DeleteWalkDirFiles

func (dMgr *DirMgr) DeleteWalkDirFiles(
	deleteFileSelectionCriteria FileSelectionCriteria) (DirectoryDeleteFileInfo, error)

DeleteWalkDirFiles - !!! BE CAREFUL !!! This method deletes files in a specified directory tree.

This method searches for files residing in the directory tree identified by the current DirMgr object which is treated as the parent directory. This method 'walks the directory tree' locating all files in the directory tree which match the file selection criteria submitted as method input parameter, 'deleteFileSelectionCriteria'.

This method will delete files in the entire directory tree including the parent directory and its sub-directory tree.

If a file matches the File Selection Criteria, it is DELETED. By the way, if ALL the file selection criterion are set to zero values or 'Inactive', then ALL FILES IN THE DIRECTORY ARE DELETED!!!

A record of file deletions is included in the returned DirectoryDeleteFileInfo structure (DirectoryDeleteFileInfo.DeletedFiles).

------------------------------------------------------------------------

Input Parameter:

deleteFileSelectionCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be deleted.

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed will be selected and DELETED.

Example:
        fsc := FileSelectCriterionMode{}

        In this example, 'fsc' is NOT initialized. Therefore,
        all of the selection criterion are 'Inactive'. Consequently,
        all of the files encountered during the search operation
        will be SELECTED FOR DELETION!

------------------------------------------------------------------------

Return Values:

DirectoryDeleteFileInfo -

        type DirectoryDeleteFileInfo struct {
          StartPath                string
          dirMgrs                  []DirMgr
          FoundFiles               []FileWalkInfo
          ErrReturns               []string
          DeleteFileSelectCriteria FileSelectionCriteria
          DeletedFiles             []FileWalkInfo
        }

        If successful, files matching the file selection criteria
        specified in input parameter 'deleteFileSelectionCriteria'
        will be DELETED and returned in a 'DirectoryDeleteFileInfo'
        structure field, 'DirectoryDeleteFileInfo.DeletedFiles.'

        Note: It is a good idea to check the returned field
              DirectoryDeleteFileInfo.ErrReturns to determine if any
              system errors were encountered during file processing.

error - If a program execution error is encountered during processing, it will
        returned as an 'error' type. Also, see the comment on
        DirectoryDeleteFileInfo.ErrReturns, above.

func (*DirMgr) DoesAbsolutePathExist

func (dMgr *DirMgr) DoesAbsolutePathExist() bool

DoesAbsolutePathExist - Performs two operations. First the method determine whether the directory path indicated by the DirMgr.absolutePath field actually does exist on disk and returns a 'true' or 'false' boolean value accordingly. In addition, it also updates the DirMgr field 'DirMgr.doesAbsolutePathExist'.

func (*DirMgr) DoesDirectoryExist

func (dMgr *DirMgr) DoesDirectoryExist() (doesPathExist, doesAbsolutePathExist bool)

DoesDirectoryExist - Returns two boolean values indicating whether or not the Directory path exists and whether or not the Directory absolute path exists.

func (*DirMgr) DoesPathExist

func (dMgr *DirMgr) DoesPathExist() bool

DoesPathExist - Performs two operations. First the method determine whether the directory path indicated by the DirMgr.path field actually does exist on disk and returns a 'true' or 'false' boolean value accordingly. In addition it also updates the DirMgr field DirMgr.doesPathExist field.

func (*DirMgr) DoesThisDirectoryExist

func (dMgr *DirMgr) DoesThisDirectoryExist() (directoryDoesExist bool, nonPathError error)

DoesThisDirectoryExist - Returns a boolean value of true if the directory identified by the current DirMgr instance does in fact exist.

If, during the process of verifying the existence of the current directory, an error is encountered it will be a non-path error. Non-Path errors are most commonly associated with 'access-denied' situations. However, there may be other reasons for triggering Non-Path errors.

If a Non-Path error is encountered, an appropriate error message is returned along with a boolean value of 'false'.

func (*DirMgr) Empty

func (dMgr *DirMgr) Empty()

Empty - Returns all DirMgr field values to their uninitialized or original zero values.

func (*DirMgr) Equal

func (dMgr *DirMgr) Equal(dMgr2 *DirMgr) bool

Equal - Compares two DirMgr objects to determine if they are equal.

func (*DirMgr) EqualAbsPaths

func (dMgr *DirMgr) EqualAbsPaths(dMgr2 *DirMgr) bool

EqualAbsPaths - compares the absolute paths for the current directory manager and the input directory manager ('dMgr2'). If the two absolute paths are equal, the method returns 'true'. If the two absolute paths are NOT equal, the method returns 'false'. The comparison is NOT case sensitive. In other words, both paths are converted to lower case before making the comparision.

If either the current DirMgr ('dMgr') or the input parameter 'dMgr2' are uninitialized, a value of 'false' is returned.

func (*DirMgr) EqualPaths

func (dMgr *DirMgr) EqualPaths(dMgr2 *DirMgr) bool

EqualPaths - Compares two DirMgr objects to determine if their paths are equal. Both Directory Path and absolute path must be equivalent.

If the compared paths are equal, the method returns 'true'. If the paths are NOT equal, the method returns 'false'. The comparisons are NOT case sensitive. In other words, all paths are converted to lower case before making the comparisons.

If either the current DirMgr ('dMgr') or the input parameter 'dMgr2' are uninitialized, a value of 'false' is returned.

func (*DirMgr) ExecuteDirectoryFileOps

func (dMgr *DirMgr) ExecuteDirectoryFileOps(
	fileSelectCriteria FileSelectionCriteria,
	fileOps []FileOperationCode,
	targetBaseDir DirMgr) (errs []error)

ExecuteDirectoryFileOps - Performs a a file operation on specified 'selected' files in the current directory ONLY. This function does NOT perform operations on the sub directories (a.k.a. the directory tree).

To perform file operations on the entire Directory Tree, see Function 'ExecuteDirectoryTreeOps()', above.

The types of File Operations performed are generally classified as 'file copy' and 'file deletion' operations. The precise file operation applied is defined by the type, 'FileOperationCode' which provides a series of constants used to identify the specific file operation applied.

Input parameter, 'fileOps' is an array of type 'FileOperationCode' elements. Multiple file operations can be applied to a single file. For instance, a 'copy source to destination' operation can be followed by a 'delete source file' operation.

The 'selected' files are identified by input parameter 'fileSelectCriteria' of type 'FileSelectionCriteria'. This file selection criteria is compared against all files in the directory (NOT the Directory Tree) identified by the current 'DirMgr' instance. When a match is found, that file is treated as a 'selected' source file and designated file operations are performed on that file.

The results or final output from file operations utilizes the final input parameter, 'targetBaseDir' of type DirMgr. File operations are applied to selected source files and generated output is created in the 'targetBaseDir'. For example 'copy' or 'move' file operations will transfer source files to 'targetBaseDir'. ------------------------------------------------------------------------

IMPORTANT:

This method performs File Operations ONLY on the directory identified by the current DirMgr instance.

------------------------------------------------------------------------

Input Parameters:

fileSelectCriteria FileSelectionCriteria

  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be identified
  as 'Selected Files'. The specified File Operations (fileOps) will be
  performed on these selected files.

  type FileSelectionCriteria struct {
     FileNamePatterns    []string     // An array of strings containing File Name Patterns
     FilesOlderThan      time.Time    // Match files with older modification date times
     FilesNewerThan      time.Time    // Match files with newer modification date times
     SelectByFileMode   FilePermissionConfig  // Match by file mode (os.FileMode).
     SelectCriterionMode FileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and returned as 'Found Files'.

     Example:

           fsc := FileSelectCriterionMode{}

           In this example, 'fsc' is NOT initialized. Therefore,
           all of the selection criterion are 'Inactive'. Consequently,
           all of the files encountered in the target directory during
           the search operation will be selected and returned as
           'Found Files'.

fileOps []FileOperationCode - An array of file operations to be performed
                              on each selected file. Selected files are
                              identified by matching the file selection
                              criteria specified by input parameter,
                              'fileSelectCriteria'. See above.

        The FileOperationCode type consists of the following
        constants.

        FileOperationCode(0).MoveSourceFileToDestinationFile() FileOperationCode = iota
          Moves the source file to the destination file and
          then deletes the original source file

        FileOperationCode(0).DeleteDestinationFile()
          Deletes the Destination file if it exists

        FileOperationCode(0).DeleteSourceFile()
          Deletes the Source file if it exists

        FileOperationCode(0).DeleteSourceAndDestinationFiles
          Deletes both the Source and Destination files
          if they exist.

        FileOperationCode(0).CopySourceToDestinationByHardLinkByIo()
          Copies the Source File to the Destination
          using two copy attempts. The first copy is
          by Hard Link. If the first copy attempt fails,
          a second copy attempt is initiated/ by creating
          a new file and copying the contents by 'io.Copy'.
          An error is returned only if both copy attempts
          fail. The source file is unaffected.

          See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

        FileOperationCode(0).CopySourceToDestinationByIoByHardLink()
          Copies the Source File to the Destination
          using two copy attempts. The first copy is
          by 'io.Copy' which creates a new file and copies
          the contents to the new file. If the first attempt
          fails, a second copy attempt is initiated using
          'copy by hard link'. An error is returned only
          if both copy attempts fail. The source file is
          unaffected.

          See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

        FileOperationCode(0).CopySourceToDestinationByHardLink()
          Copies the Source File to the Destination
          using one copy mode. The only copy attempt
          utilizes 'Copy by Hard Link'. If this fails
          an error is returned.  The source file is
          unaffected.

        FileOperationCode(0).CopySourceToDestinationByIo()
          Copies the Source File to the Destination
          using only one copy mode. The only copy
          attempt is initiated using 'Copy by IO' or
          'io.Copy'.  If this fails an error is returned.
          The source file is unaffected.

        FileOperationCode(0).CreateSourceDir()
          Creates the Source Directory

        FileOperationCode(0).CreateSourceDirAndFile()
          Creates the Source Directory and File

        FileOperationCode(0).CreateSourceFile()
          Creates the Source File

        FileOperationCode(0).CreateDestinationDir()
          Creates the Destination Directory

        FileOperationCode(0).CreateDestinationDirAndFile()
          Creates the Destination Directory and File

        FileOperationCode(0).CreateDestinationFile()
          Creates the Destination File

------------------------------------------------------------------------

Input parameters (continued)

targetBaseDir - The file selection criteria, 'fileSelectCriteria', and
                the File Operations, 'fileOps' are applied to files in
                the target base directory. This input parameter is of
                type 'DirMgr'.

------------------------------------------------------------------------

Return Value:

[] error -  This function will return an array of errors containing error messages
            generated during the performance of specified File Operations on the
            designated directory. If the error array returned is empty or has
            a zero length, it signals that no errors were encountered and all operations
            completed successfully.

func (*DirMgr) ExecuteDirectoryTreeOps

func (dMgr *DirMgr) ExecuteDirectoryTreeOps(
	fileSelectCriteria FileSelectionCriteria,
	fileOps []FileOperationCode,
	targetBaseDir DirMgr) (errs []error)

ExecuteDirectoryTreeOps - Performs File Operations on specified 'selected' files in the directory tree identified by the current 'DirMgr' instance. The 'DirMgr' path therefore serves as the parent directory for file operations performed on the directory tree.

If you wish to perform File Operations ONLY on the current directory and NOT THE ENTIRE DIRECTORY TREE, see Function "ExecuteDirectoryFileOps(), above.

The types of File Operations performed are generally classified as 'file copy' and 'file deletion' operations. The precise file operation applied is defined by the the type, 'FileOperationCode' which provides a series of constants, or enumerations, used to identify the specific file operation applied. Input parameter, 'fileOps' is an array of type 'FileOperationCode' elements. Multiple file operations can be applied to a single file. For instance, a 'copy source to destination' operation can be followed by a 'delete source file' operation.

The 'selected' files are identified by input parameter 'fileSelectCriteria' of type 'FileSelectionCriteria'. This file selection criteria is compared against all files in the current directory tree identified by the current 'DirMgr' instance. When a match is found, that file is treated as a 'selected' file and designated file operations are performed on that file.

------------------------------------------------------------------------

IMPORTANT:

This method performs File Operations on THE ENTIRE DIRECTORY TREE identified by this DirMgr instance.

------------------------------------------------------------------------

Input Parameters:

fileSelectCriteria FileSelectionCriteria

  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be identified
  as 'Selected Files'. The specified File Operations (fileOps) will be
  performed on these selected files.

  type FileSelectionCriteria struct {
    FileNamePatterns     []string	    // An array of strings containing File Name Patterns
    FilesOlderThan       time.Time    // Match files with older modification date times
    FilesNewerThan       time.Time    // Match files with newer modification date times
    SelectByFileMode     FilePermissionConfig  // Match file mode (os.FileMode).
                                      //   is set to 'false'.
    SelectCriterionMode  FileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and returned as 'Found Files'.

Example:
     fsc := FileSelectCriterionMode{}

     In this example, 'fsc' is NOT initialized. Therefore,
     all of the selection criterion are 'Inactive'. Consequently,
     all of the files encountered in the target directory during
     the search operaiton will be selected and returned as
     'Found Files'.

---------------------------------------------------------------------------

fileOps []FileOperationCode - An array of file operations to be performed
                              on each selected file. Selected files are
                              identified by matching the file selection
                              criteria specified by input parameter,
                              'fileSelectCriteria'. See above.

  The FileOperationCode type consists of the following
  constants.

  FileOperationCode(0).None()
    No Action

  FileOperationCode(0).MoveSourceFileToDestinationFile()
    Moves the source file to the destination file and
    then deletes the original source file

  FileOperationCode(0).DeleteDestinationFile()
    Deletes the Destination file if it exists

  FileOperationCode(0).DeleteSourceFile()
    Deletes the Source file if it exists

  FileOperationCode(0).DeleteSourceAndDestinationFiles
    Deletes both the Source and Destination files
    if they exist.

  FileOperationCode(0).CopySourceToDestinationByHardLinkByIo()
    Copies the Source File to the Destination
    using two copy attempts. The first copy is
    by Hard Link. If the first copy attempt fails,
    a second copy attempt is initiated/ by creating
    a new file and copying the contents by 'io.Copy'.
    An error is returned only if both copy attempts
    fail. The source file is unaffected.

    See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

  FileOperationCode(0).CopySourceToDestinationByIoByHardLink()
    Copies the Source File to the Destination
    using two copy attempts. The first copy is
    by 'io.Copy' which creates a new file and copies
    the contents to the new file. If the first attempt
    fails, a second copy attempt is initiated using
    'copy by hard link'. An error is returned only
    if both copy attempts fail. The source file is
    unaffected.

    See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

  FileOperationCode(0).CopySourceToDestinationByHardLink()
    Copies the Source File to the Destination
    using one copy mode. The only copy attempt
    utilizes 'Copy by Hard Link'. If this fails
    an error is returned.  The source file is
    unaffected.

  FileOperationCode(0).CopySourceToDestinationByIo()
    Copies the Source File to the Destination
    using only one copy mode. The only copy
    attempt is initiated using 'Copy by IO' or
    'io.Copy'.  If this fails an error is returned.
    The source file is unaffected.

  FileOperationCode(0).CreateSourceDir()
    Creates the Source Directory

  FileOperationCode(0).CreateSourceDirAndFile()
    Creates the Source Directory and File

  FileOperationCode(0).CreateSourceFile()
    Creates the Source File

  FileOperationCode(0).CreateDestinationDir()
    Creates the Destination Directory

  FileOperationCode(0).CreateDestinationDirAndFile()
    Creates the Destination Directory and File

  FileOperationCode(0).CreateDestinationFile()
    Creates the Destination File

------------------------------------------------------------------------

Input parameters (continued)

targetBaseDir - The file selection criteria, 'fileSelectCriteria', and

the File Operations, 'fileOps' are applied to files in
the target base directory. This input parameter is of
type 'DirMgr'.

---------------------------------------------------------------------------

Return Values:

[]error -  This function will return an array of strings containing error messages
           generated during the performance of specified File Operations on the
           designated directory tree. If the string array returned is empty or has
           a zero length, it signals that no errors were encountered and all operations
           completed successfully.

func (*DirMgr) FindDirectoryTreeFiles

func (dMgr *DirMgr) FindDirectoryTreeFiles(
	fileSelectionCriteria FileSelectionCriteria) (dTreeInfo DirectoryTreeInfo, errs []error)

FindDirectoryTreeFiles - This method returns file information on files residing in a specific directory tree identified by the current DirMgr instance. The directory identified by 'DirMgr' is treated as the the parent directory for the search.

In addition to file information, this method also returns data on the directory tree being searched including the parent directory and all sub-directories in the tree.

This method 'walks the directory tree' locating all files in the directory tree which match the file selection criteria submitted as input parameter, 'fileSelectCriteria'.

All directories including the top level parent directory ('DirMgr') are searched. This differs from method 'DirMgr.FindWalkSubDirFiles()' which only searches the sub-directory tree.

If a file matches the File Selection Criteria, it is included in the returned field, 'DirectoryTreeInfo.FoundFiles'. If ALL the file selection criterion are set to zero values or 'Inactive', then ALL FILES in the directory are selected and returned in the field, 'DirectoryTreeInfo.FoundFiles'.

All directories searched will be included in the returned collection 'DirectoryTreeInfo.Directories'. This returned 'DirectoryTreeInfo.Directories' collection will always include the top level parent directory identified by 'DirMgr'.

------------------------------------------------------------------------

Input Parameters:

fileSelectCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be returned as
  'Found Files'.

  type FileSelectionCriteria struct {
    FileNamePatterns     []string     // An array of strings containing File Name Patterns
    FilesOlderThan       time.Time    // Match files with older modification date times
    FilesNewerThan       time.Time    // Match files with newer modification date times
    SelectByFileMode     FilePermissionConfig  // Match file mode (os.FileMode).
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and returned as 'Found Files'.

Example:
     fsc := FileSelectionCriteria{} // fsc is NOT initialized

     In this example, all of the selection criterion are
     'Inactive' and therefore all of the files encountered
     in the target directory will be selected and returned
     as 'Found Files'.

------------------------------------------------------------------------

Return Values:

dTreeInfo - DirectoryTreeInfo structure	-
          type DirectoryTreeInfo struct {
            StartPath             string                // The starting path or directory for the file
                                                        // search

            Directories           DirMgrCollection      // Directory Managers found during directory tree
                                                        // search.

                                                        // This collection will ALWAYS return the parent
                                                        // directory ('DirMgr') as the first entry in the
                                                        // collection.

            FoundFiles            FileMgrCollection     // Found Files matching file selection criteria
            ErrReturns            []error               // Internal System errors encountered
            FileSelectCriteria    FileSelectionCriteria // The File Selection Criteria submitted as an
                                                        // input parameter to this method.
           }

        If successful, files matching the file selection criteria input
        parameter shown above will be returned in a 'DirectoryTreeInfo'
        object. The field 'DirectoryTreeInfo.FoundFiles' contains information
        on all the files in the specified directory tree which match the file selection
        criteria.

        Note: It is a good idea to check the returned field 'DirectoryTreeInfo.ErrReturns'
              to determine if any internal system errors were encountered while processing
              the directory tree.

error - If a program execution error is encountered during processing, it will
        be returned as an 'error' type. Also, see the comment on
        'DirectoryTreeInfo.ErrReturns', above.

func (*DirMgr) FindFilesByNamePattern

func (dMgr *DirMgr) FindFilesByNamePattern(fileSearchPattern string) (FileMgrCollection, error)

FindFilesByNamePattern - searches the current directory using a name pattern file search criteria.

Regardless of the search pattern used, this method will never return sub-directories of the target search directory.

Again, the file search will always be limited to the directory identified by the current DirMgr instance. No sub-directories will be searched.

If the 'fileSearchPattern' is an empty string or improperly formatted, an error will be returned.

------------------------------------------------------------------------

Input parameter

fileSearchPattern  string -  The fileSearchPattern is string containing
                             parameters used to select target files in
                             directory identified by the 'DirMgr' type.

                             Example 'fileSearchPattern' strings

                             *.*             will match all files in directory.
                             *.html          will match  anyfilename.html
                             a*              will match  appleJack.txt
                             j????row.txt    will match  j1x34row.txt
                             data[0-9]*      will match 	data123.csv

                             Reference For File Pattern Matching Details:
                               https://golang.org/pkg/path/filepath/#Match

---------------------------------------------------------------------------

Return Values:

FileMgrCollection - If this method completes successfully without error, the
                    returned FileMgrCollection type will contain an array of
                    FileMgr types identifying each of the files matched by
                    input parameter, 'fileSearchPattern'.

error             - If this method completes successfully, this return value
                    will be set to 'nil'. Otherwise, a valid error message will
                    be encapsulated in the returned type 'error'.

func (*DirMgr) FindFilesBySelectCriteria

func (dMgr *DirMgr) FindFilesBySelectCriteria(
	fileSelectCriteria FileSelectionCriteria) (FileMgrCollection, error)

FindFilesBySelectCriteria - Conducts a file search in the directory identified by the current DirMgr instance. The file search is limited to that directory ONLY. No sub-directories will be searched.

Files matching the "FileSectionCriteria" instance passed as an input parameter will be used to screen available files. Any files matching the file selection criteria will be returned in a 'FileMgrCollection'.

Only matched files will be returned. No sub-directory names will ever be included.

The use of a 'FileSelectionCriteria' structure allows for very flexible and granular file searches.

------------------------------------------------------------------------

Input Parameter:

fileSelectCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be returned as
  'Found Files'.

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and returned as 'Found Files'.

Example:
  fsc := FileSelectCriterionMode{}

  In this example, 'fsc' is NOT initialized. Therefore,
  all of the selection criterion are 'Inactive'. Consequently,
  all of the files encountered in the target directory during
  the search operation will be selected and returned as
  'Found Files'.

---------------------------------------------------------------------------

Return Values:

FileMgrCollection - If this method completes successfully without error, the
                    returned FileMgrCollection type will contain an array of
                    FileMgr types identifying each of the files matched by
                    input parameter, 'fileSelectCriteria'.

error             - If this method completes successfully, this return value
                    will be set to 'nil'. Otherwise, a valid error message will
                    be encapsulated in the returned type 'error'.

func (*DirMgr) FindWalkDirFiles

func (dMgr *DirMgr) FindWalkDirFiles(
	fileSelectCriteria FileSelectionCriteria) (DirectoryTreeInfo, error)

FindWalkDirFiles - This method returns file information on files residing in a specific directory tree identified by the current DirMgr instance. The directory identified by 'DirMgr' is treated as the the parent directory for the search.

In addition to file information, this method also returns data on the directory tree being searched including the parent directory and all sub-directories in the tree.

This method 'walks the directory tree' locating all files in the directory tree which match the file selection criteria submitted as input parameter, 'fileSelectCriteria'.

All directories including the top level parent directory ('DirMgr') are searched. This differs from method 'DirMgr.FindWalkSubDirFiles()' which only searches the sub-directory tree.

If a file matches the File Selection Criteria, it is included in the returned field, 'DirectoryTreeInfo.FoundFiles'. If ALL the file selection criterion are set to zero values or 'Inactive', then ALL FILES in the directory are selected and returned in the field, 'DirectoryTreeInfo.FoundFiles'.

All directories searched will be included in the returned collection 'DirectoryTreeInfo.Directories'. This returned 'DirectoryTreeInfo.Directories' collection will always include the top level parent directory identified by 'DirMgr'.

------------------------------------------------------------------------

Input Parameters:

fileSelectCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be returned as
  'Found Files'.

  type FileSelectionCriteria struct {
    FileNamePatterns     []string     // An array of strings containing File Name Patterns
    FilesOlderThan       time.Time    // Match files with older modification date times
    FilesNewerThan       time.Time    // Match files with newer modification date times
    SelectByFileMode     FilePermissionConfig  // Match file mode (os.FileMode).
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and returned as 'Found Files'.

Example:
     fsc := FileSelectionCriteria{} // fsc is NOT initialized

     In this example, all of the selection criterion are
     'Inactive' and therefore all of the files encountered
     in the target directory will be selected and returned
     as 'Found Files'.

------------------------------------------------------------------------

Return Values:

DirectoryTreeInfo structure	-
        type DirectoryTreeInfo struct {
          StartPath             string                // The starting path or directory for the file search
          Directories           DirMgrCollection      // Directory Managers found during directory tree search.
                                                      // This collection will ALWAYS return the parent directory
                                                      // ('DirMgr') as the first entry in the collection.
          FoundFiles            FileMgrCollection     // Found Files matching file selection criteria
          ErrReturns            []error               // Internal System errors encountered
          FileSelectCriteria    FileSelectionCriteria // The File Selection Criteria submitted as an
                                                      // input parameter to this method.
        }

        If successful, files matching the file selection criteria input
        parameter shown above will be returned in a 'DirectoryTreeInfo'
        object. The field 'DirectoryTreeInfo.FoundFiles' contains information
        on all the files in the specified directory tree which match the file selection
        criteria.

        Note: It is a good idea to check the returned field 'DirectoryTreeInfo.ErrReturns'
              to determine if any internal system errors were encountered while processing
              the directory tree.

error - If a program execution error is encountered during processing, it will
        be returned as an 'error' type. Also, see the comment on
        'DirectoryTreeInfo.ErrReturns', above.

func (*DirMgr) FindWalkSubDirFiles

func (dMgr *DirMgr) FindWalkSubDirFiles(
	fileSelectCriteria FileSelectionCriteria) (dTreeInfo DirectoryTreeInfo, err error)

FindWalkSubDirFiles - This method returns file information on files residing in a sub-directory tree identified by the current DirMgr instance. As such, this method will NOT search the top level directory, parent directory identified by the current DirMgr instance. However, all directories subsidiary to the parent directory ('DirMgr') will be searched.

This method 'walks the directory tree' locating all files in the sub-directory tree which match the file selection criteria submitted as input parameter, 'fileSelectCriteria'.

If a file matches the File Selection Criteria, it is included in the returned field, 'DirectoryTreeInfo.FoundFiles'. If ALL the file selection criterion are set to zero values or 'Inactive', then ALL FILES in the suc-directory tree are selected and returned in the field, 'DirectoryTreeInfo.FoundFiles'.

All directories searched will be included in the returned collection 'DirectoryTreeInfo.Directories'. If the parent directory has NO sub-directories, this returned collection will be empty.

------------------------------------------------------------------------

Input Parameters:

fileSelectCriteria FileSelectionCriteria
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be returned as
  'Found Files'.

  type FileSelectionCriteria struct {
    FileNamePatterns     []string     // An array of strings containing File Name Patterns
    FilesOlderThan       time.Time    // Match files with older modification date times
    FilesNewerThan       time.Time    // Match files with newer modification date times
    SelectByFileMode     FilePermissionConfig  // Match file mode (os.FileMode).
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                                  FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and returned as 'Found Files'.

Example:
     fsc := FileSelectionCriteria{} // fsc is NOT initialized

     In this example, all of the selection criterion are
     'Inactive' and therefore all of the files encountered
     in the target directory will be selected and returned
     as 'Found Files'.

------------------------------------------------------------------------

Return Values:

DirectoryTreeInfo structure	-
        type DirectoryTreeInfo struct {
          StartPath             string                // The starting path or directory for the file search
          Directories           DirMgrCollection      // Directory Managers found during directory tree
                                                      // search. Note: The top level parent directory will
                                                      // NEVER be included.
          FoundFiles            FileMgrCollection     // Found Files matching file selection criteria
          ErrReturns            []error               // Internal System errors encountered
          FileSelectCriteria    FileSelectionCriteria // The File Selection Criteria submitted as an
                                                      // input parameter to this method.
        }

        If successful, files matching the file selection criteria input
        parameter shown above will be returned in a 'DirectoryTreeInfo'
        object. The field 'DirectoryTreeInfo.FoundFiles' contains information
        on all the files in the specified sub-directory tree which match the file
        selection criteria.

        Note: It is a good idea to check the returned field 'DirectoryTreeInfo.ErrReturns'
              to determine if any internal system errors were encountered while processing
              the directory tree.

error - If a program execution error is encountered during processing, it will
        be returned as an 'error' type. Also, see the comment on
        'DirectoryTreeInfo.ErrReturns', above.

func (*DirMgr) GetAbsolutePath

func (dMgr *DirMgr) GetAbsolutePath() string

GetAbsolutePath - Returns a string containing the absolute path for the current Directory Manager instance. This string returned by this method will NOT have a trailing path separator.

See companion method GetAbsolutePathLc() to acquire a lower case version of absolute path.

func (*DirMgr) GetAbsolutePathElements

func (dMgr *DirMgr) GetAbsolutePathElements() (pathElements []string)

GetAbsolutePathElements - Returns all of the directories and drive specifications as an array of strings.

Example

Path = "D:\ADir\BDir\CDir\EDir"

Returned pathElements string array:

pathElements[0] = "D:"
pathElements[1] = "ADir"
pathElements[2] = "BDir"
pathElements[3] = "CDir"
pathElements[4] = "DDir"
pathElements[4] = "EDir"

func (*DirMgr) GetAbsolutePathLc

func (dMgr *DirMgr) GetAbsolutePathLc() string

This string returned by this method will NOT have a trailing path separator. It will consist of all lower case characters.

See the companion method GetAbsolutePath() to return an absolute path string with upper and lower case characters.

func (*DirMgr) GetAbsolutePathWithSeparator

func (dMgr *DirMgr) GetAbsolutePathWithSeparator() string

GetAbsolutePathWithSeparator - Returns the current DirMgr.absolutePath with a trailing os.PathSeparator character. The path string may consist of upper and lower case characters.

See the companion method GetAbsolutePathWithSeparatorLc() which returns a path string consisting of all lower case characters.

func (*DirMgr) GetAbsolutePathWithSeparatorLc

func (dMgr *DirMgr) GetAbsolutePathWithSeparatorLc() string

GetAbsolutePathWithSeparatorLc - Returns the current DirMgr.absolutePath with a trailing os.PathSeparator character. The path string will consists of all lower case characters.

See the companion method GetAbsolutePathWithSeparator() which returns a path string consisting of upper and lower case characters.

func (*DirMgr) GetDirPermissionCodes

func (dMgr *DirMgr) GetDirPermissionCodes() (FilePermissionConfig, error)

GetDirPermissionCodes - If the current directory exists on disk, this method will return the Directory Permission Codes encapsulated in a type 'FilePermissionConfig'.

If the current Directory does NOT exist, this method will return an error.

func (*DirMgr) GetDirectoryName

func (dMgr *DirMgr) GetDirectoryName() string

GetDirectoryName - Returns a string containing the name of the directory without out the parent path.

func (*DirMgr) GetDirectoryStats

func (dMgr *DirMgr) GetDirectoryStats() (dirStats DirectoryStatsDto, errs []error)

GetDirectoryBytes - Returns the number of bytes in the current directory identified by the 'DirMgr' instance. This method only returns bytes in the current directory

func (*DirMgr) GetDirectoryTree

func (dMgr *DirMgr) GetDirectoryTree() (dirMgrs DirMgrCollection, errs []error)

GetDirectoryTree - Returns a DirMgrCollection containing all the sub-directories in the path of the parent directory identified by the current DirMgr instance.

The returned DirMgrCollection will always contain the parent directory at the top of the array (index=0). Therefore, if no errors are encountered, the returned DirMgrCollection will always consist of at least one directory. If sub-directories are found, then the returned DirMgrCollection will contain more than one directory.

func (*DirMgr) GetDirectoryTreeStats

func (dMgr *DirMgr) GetDirectoryTreeStats() (dirStats DirectoryStatsDto, errs []error)

GetDirectoryTreeBytes - Returns all the bytes in a directory tree. The parent directory for the search is identified by the current DirMgr instance.

func (*DirMgr) GetFileInfoPlus

func (dMgr *DirMgr) GetFileInfoPlus() (FileInfoPlus, error)

GetFileInfoPlus - Returns a FileInfoPlus instance detailing file system information on the directory identified by the current Directory Manager instance.

func (*DirMgr) GetNumberOfAbsPathElements

func (dMgr *DirMgr) GetNumberOfAbsPathElements() int

GetNumberOfAbsPathElements - Returns the number of elements or path components in the absolute path of the current Directory Manager instance.

func (*DirMgr) GetOriginalPath

func (dMgr *DirMgr) GetOriginalPath() string

GetOriginalPath - Returns the original path used to initialize this Directory Manager instance.

func (*DirMgr) GetParentDirMgr

func (dMgr *DirMgr) GetParentDirMgr() (dirMgrOut DirMgr, hasParent bool, err error)

GetParentDirMgr - Returns a new Directory Manager instance which represents the the parent path for the current Directory Manager. The current Directory Manager absolute path is used in extracting the parent Directory Manager.

Return Values:

dirMgr   DirMgr - If successful, this methods returns a Directory Manager
                  which is a parent of the current Directory Manager.

hasParent  bool - If 'true', it signals that the current Directory Manager
                  has a valid parent directory. If 'false', it signals that
                  the current Directory Manager represents a top level directory
                  which has no parent directory. In that case a copy of the
                  current Directory will be returned.

err       error - If an error is encountered this error type will be populated
                  with an appropriate error message. Otherwise, a value of 'nil'
                  will be returned.

                  If 'hasParent' is 'false', no error will be returned.

func (*DirMgr) GetParentPath

func (dMgr *DirMgr) GetParentPath() string

GetParentPath - Returns a string containing the parent path for the current Directory Manager instance. The Parent Path string will NOT contain a trailing path separator.

func (*DirMgr) GetPath

func (dMgr *DirMgr) GetPath() string

GetPath - Returns the path used to configure this Directory Manager Instance. It will NOT contain a trailing path separator. It may or may not be an absolute path.

func (*DirMgr) GetPathWithSeparator

func (dMgr *DirMgr) GetPathWithSeparator() string

GetPathWithSeparator - Returns the current DirMgr.absolutePath with a trailing os.PathSeparator character.

func (*DirMgr) GetVolumeName

func (dMgr *DirMgr) GetVolumeName() string

GetVolumeName - Returns a string containing the volume name of the directory identified by the current Directory Manager instance.

func (*DirMgr) IsDirMgrValid

func (dMgr *DirMgr) IsDirMgrValid(errPrefixStr string) error

IsDirMgrValid - This method examines the current DirMgr object to determine whether it has been properly configured. If the current DirMgr object is valid, the method returns 'nil' for no errors.

Otherwise, if the DirMgr object is INVALID, an error is returned.

func (*DirMgr) IsInitialized

func (dMgr *DirMgr) IsInitialized() bool

IsInitialized - Returns a boolean value indicating whether the Directory Manager instance is initialized.

func (*DirMgr) IsParentPathPopulated

func (dMgr *DirMgr) IsParentPathPopulated() bool

IsParentPathPopulated - Returns a boolean value indicating whether the parent path for this Directory Manager instance is populated.

func (*DirMgr) IsPathPopulated

func (dMgr *DirMgr) IsPathPopulated() bool

IsPathPopulated - Returns a boolean value indicating whether the current Directory Manager path string is populated.

func (*DirMgr) IsVolumeNamePopulated

func (dMgr *DirMgr) IsVolumeNamePopulated() bool

IsVolumeNamePopulated - Returns a boolean value indicating whether the Volume Name for the current Directory Manager instance is populated.

func (*DirMgr) MakeDir

func (dMgr *DirMgr) MakeDir() error

MakeDir - If the directory path identified by the current DirMgr object does not exist, this method will create that directory path. The permission specification used to create the directory is 'drwxrwxrwx' which is equivalent to octal value, '020000000777'

MakeDir creates a directory named path, along with any necessary parent directories.

If the directory creation fails, an error is returned.

func (*DirMgr) MakeDirWithPermission

func (dMgr *DirMgr) MakeDirWithPermission(fPermCfg FilePermissionConfig) error

MakeDir - If the directory path identified by the current DirMgr object does not exist, this method will create that directory path. The path will be created using permission specifications passed through input parameter 'fPermCfg'.

func (*DirMgr) MoveDirectory

func (dMgr *DirMgr) MoveDirectory(
	targetDMgr DirMgr,
	fileSelectCriteria FileSelectionCriteria) (dirMoveStats DirectoryMoveStats,
	errs []error)

MoveDirectory - Moves files from the source directory identified by DirMgr to a target directory. The 'move' operation is accomplished in three steps. First, the files to be copied are selected according to file selection criteria specified by input parameter,'fileSelectCriteria'. Second, the selected files are copied to target directory identified by the input parameter, 'targetDir'. Finally, after verifying the copy, the files are deleted from the source directory (DirMgr).

If, at the conclusion of the 'move' operation, there are no files or sub-directories remaining in the source directory (DirMgr), the source directory will be delete.

The selected files are copied using Copy IO operation. For information on the Copy IO procedure see FileHelper{}.CopyFileByIo() method and reference:

https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

If the target directory does not previously exist, this method will attempt to create the target directory, provided, that files are selected for movement to that directory. If no files match the file selection criteria, the target directory will NOT be created.

NOTE: This method ONLY moves files from the current directory identified by 'DirMgr'. It does NOT move files from subdirectories.

This method is optimized to support the movement of large numbers of files.

------------------------------------------------------------------------------

IMPORTANT!!!! This method will delete files in the current DirMgr path! If all files have been moved out of the directory and there are no sub-Directories remaining, the DirMgr directory will likewise be deleted.

------------------------------------------------------------------------------

Input Parameters:

targetDMgr   DirMgr - An instance of 'DirMgr' initialized with the directory
                      path of the target directory to which selected files
                      will be moved. If the target directory does not exist,
                      this method will attempt to create it.

fileSelectCriteria FileSelectionCriteria -
  This input parameter should be configured with the desired file
  selection criteria. Files matching this criteria will be moved
  from the current DirMgr path to the directory identified by input
  parameter, 'targetDir'.

  type FileSelectionCriteria struct {
   FileNamePatterns    []string// An array of strings containing File Name Patterns
   FilesOlderThan      time.Time// Match files with older modification date times
   FilesNewerThan      time.Time// Match files with newer modification date times
   SelectByFileMode    FilePermissionConfig  // Match file mode (os.FileMode).
   SelectCriterionModeFileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
  }

  The FileSelectionCriteria type allows for configuration of single or multiple file
  selection criterion. The 'SelectCriterionMode' can be used to specify whether the
  file must match all, or any one, of the active file selection criterion.

  Elements of the FileSelectionCriteria are described below:

  FileNamePatterns    []string  - An array of strings which may define one or more
                                  search patterns. If a file name matches any one of the
                                  search pattern strings, it is deemed to be a 'match'
                                  for the search pattern criterion.

                                    Example Patterns:
                                     FileNamePatterns = []string{"*.log"}
                                     FileNamePatterns = []string{"current*.txt"}
                                     FileNamePatterns = []string{"*.txt", "*.log"}

                                  If this string array has zero length or if
                                  all the strings are empty strings, then this
                                  file search criterion is considered 'Inactive'
                                  or 'Not Set'.

  FilesOlderThan      time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file modification
                                  date time is older than the 'FilesOlderThan' date time,
                                  that file is considered a 'match'	for this file selection
                                  criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  FilesNewerThan      time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

  SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

  SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                              FileSelectMode.ANDSelect() - File selected if all active selection
                                    criteria are satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will not be judged as 'selected' unless all of
                                    the active selection criterion are satisfied. In other words, if
                                    three active search criterion are provided for 'FileNamePatterns',
                                    'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                    selected unless it has satisfied all three criterion in this example.

                              FileSelectMode.ORSelect() - File selected if any active selection
                                    criterion is satisfied.

                                    If this constant value is specified for the file selection mode,
                                    then a given file will be selected if any one of the active file
                                    selection criterion is satisfied. In other words, if three active
                                    search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                    and 'FilesNewerThan', then a file will be selected if it satisfies any
                                    one of the three criterion in this example.

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are 'Inactive' or 'Not Set' (set to their zero or default values), then all of the files processed in the directory tree will be selected and moved to the target directory.

Example:
  fsc := FileSelectCriterionMode{}

  In this example, 'fsc' is NOT initialized. Therefore,
  all of the selection criterion are 'Inactive'. Consequently,
  all of the files encountered in the target directory during
  the search operation will be selected and moved
  to the target directory.

---------------------------------------------------------------------------

Return Value:

numOfSrcFilesMoved     int - Contains the number of files actually moved to the target
                             directory.

numOfSrcFilesRemaining int - Returns the number of source files remaining in the current
                             directory after the move operation was completed.

numOfSubDirectories    int - Returns the number of sub-directories which exist in the
                             DirMgr parent directory.

dMgrDirWasDeleted     bool - Returns 'true' if the current directory ('DirMgr') was deleted.

errs              []error  - An array of errors is returned. If the method completes
                             successfully with no errors, a ZERO-length array is
                             is returned.

                             If errors are encountered they are stored in the error
                             array and returned to the caller.

func (*DirMgr) MoveDirectoryTree

func (dMgr *DirMgr) MoveDirectoryTree(
	targetDMgr DirMgr) (
	dirMoveStats DirectoryMoveStats,
	errs []error)

MoveDirectoryTree - Moves all sub-directories and files plus files in the parent DirMgr directory to a target directory tree specified by input parameter 'targetDMgr'. If successful, the parent directory DirMgr will be deleted along with the entire sub-directory tree.

--------------------------------------------------------------------

!!!! BE CAREFUL !!!! This method will delete the entire directory tree identified by DirMgr along with ALL the files in the DirMgr directory tree!

--------------------------------------------------------------------

Input Parameters:

targetDMgr   DirMgr - An instance of 'DirMgr' initialized with the directory
                      path of the target directory to which all source files
                      will be moved. If the target directory does not exist,
                      this method will attempt to create it.

---------------------------------------------------------------------------

Return Value:

errs     []error  - An array of errors is returned. If the method completes
                    successfully with no errors, a ZERO-length array is
                    is returned.

                    If errors are encountered they are stored in the error
                    array and returned to the caller.

func (*DirMgr) MoveSubDirectoryTree

func (dMgr *DirMgr) MoveSubDirectoryTree(targetDMgr DirMgr) (
	dirMoveStats DirectoryMoveStats, errs []error)

MoveSubDirectoryTree - Moves all sub-directories and their constituent files from the source or parent directory 'DirMgr' to a target directory tree specified by input parameter 'targetDMgr'. If successful, all sub-directories and files in the source directory tree will be deleted. The source or parent directory identified by 'DirMgr' and the files within 'DirMgr' will NOT be deleted.

--------------------------------------------------------------------

!!!! BE CAREFUL !!!! This method will delete the entire sub-directory tree. The source or parent directory 'DirMgr' and its constituent files will NOT be deleted.

--------------------------------------------------------------------

Input Parameters:

targetDMgr   DirMgr - An instance of 'DirMgr' initialized with the directory
                      path of the target directory to which all source files
                      will be moved. If the target directory does not exist,
                      this method will attempt to create it.

---------------------------------------------------------------------------

Return Value:

errs     []error  - An array of errors is returned. If the method completes
                    successfully with no errors, a ZERO-length array is
                    is returned.

                    If errors are encountered they are stored in the error
                    array and returned to the caller.

func (DirMgr) New

func (dMgr DirMgr) New(pathStr string) (DirMgr, error)

New - Returns a new DirMgr object and populates the the data fields.

------------------------------------------------------------------------

Input Parameters:

	pathStr string - A path string designating a path or directory.
	                 To reduce errors, the 'pathStr' should be terminated
	                 with an appropriate path separator ('/' or '\')
	                 Example 'pathStr': "C:\dirA\dirB\dirC\"

	Example Output After DirMgr Configuration:

    ----------------------------
    DirMgr Fields
    ----------------------------

                     isInitialized:  true
                      originalPath:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest\testoverwrite
                              path:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest\testoverwrite
                   IsPathPopulated:  true
                     doesPathExist:  true
                        parentPath:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest
             isParentPathPopulated:  true
                      relativePath:  testoverwrite
           isRelativePathPopulated:  true
                      absolutePath:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest\testoverwrite
           isAbsolutePathPopulated:  true
   isAbsolutePathDifferentFromPath:  false
             doesAbsolutePathExist:  true
                     directoryName:  testoverwrite
                        volumeName:  D:
                 isVolumePopulated:  true
                 actualDirFileInfo:
                        ========== File Info Data ==========
                          File Info IsDir():  true
                           File Info Name():  testoverwrite
                           File Info Size():  0
                        File Info ModTime():  2018-01-06 Sat 00:06:56.421236800 -0600 CST
                           File Info Mode():  drwxrwxrwx
                            File Info Sys():  &{16 {617269082 30594119} {2388100752 30639796} {2388100752 30639796} 0 0}
                                   Dir path:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest\testoverwrite

func (DirMgr) NewFromDirMgrFileInfo

func (dMgr DirMgr) NewFromDirMgrFileInfo(
	parentDirectory DirMgr, directoryFileInfo os.FileInfo) (DirMgr, error)

NewFromDirMgrFileInfo - Configures and returns a new 'DirMgr' instance based on two input parameters, 'directory' and 'fileNameExt'.

Input parameter 'directory' is of type 'DirMgr' and is treated as the parent directory. The final directory name is provided by the input parameter 'fileInfo' of type 'os.FileInfo'.

func (DirMgr) NewFromFileInfo

func (dMgr DirMgr) NewFromFileInfo(
	parentDirectoryPath string, info os.FileInfo) (DirMgr, error)

NewFromFileInfo - Returns a new DirMgr object based on two input parameters:

  • A parent directory path string
  • An os.FileInfo object containing the directory name.

func (DirMgr) NewFromFileMgr

func (dMgr DirMgr) NewFromFileMgr(fileMgr FileMgr) (DirMgr, error)

NewFromFileMgr - Configures and returns a new 'DirMgr' instance based on input parameter 'fileMgr' which is of type 'FileMgr'.

func (DirMgr) NewFromKnownPathDirectoryName

func (dMgr DirMgr) NewFromKnownPathDirectoryName(
	parentPathName string, directoryName string) (DirMgr, error)

NewFromKnownPathDirectoryName - Configures and returns a new 'DirMgr' instance using a parent path name and directory name. The parent path and directory name are combined to form the full path for the new 'DirMgr' instance.

This method will populate all internal field values with new values based on input parameters 'parentPathName' and 'directoryName'.

This method differs from similar methods in that it assumes the input parameters are known values and do not require the usual analysis and validation screening applied by other methods.

func (*DirMgr) ParseValidPathStr

func (dMgr *DirMgr) ParseValidPathStr(pathStr string) (ValidPathStrDto, error)

func (*DirMgr) SetDirMgr

func (dMgr *DirMgr) SetDirMgr(pathStr string) (isEmpty bool, err error)

SetDirMgr - Sets the DirMgr fields and path strings for the current DirMgr instance.

------------------------------------------------------------------------

Input Parameters:

pathStr string - A path string designating a path or directory.
                 To reduce errors, the 'pathStr' should be terminated
                 with an appropriate path separator ('/' or '\')
                 Example 'pathStr': "C:\dirA\dirB\dirC\"

Example Output After DirMgr Configuration:

 ----------------------------
 DirMgr Fields
 ----------------------------

                  isInitialized:  true
                   originalPath:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest\testoverwrite
                           path:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest\testoverwrite
                IsPathPopulated:  true
                  doesPathExist:  true
                     parentPath:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest
          isParentPathPopulated:  true
                   relativePath:  testoverwrite
        isRelativePathPopulated:  true
                   absolutePath:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest\testoverwrite
        isAbsolutePathPopulated:  true
isAbsolutePathDifferentFromPath:  false
          doesAbsolutePathExist:  true
                  directoryName:  testoverwrite
                     volumeName:  D:
              isVolumePopulated:  true
              actualDirFileInfo:
                     ========== File Info Data ==========
                       File Info IsDir():  true
                        File Info Name():  testoverwrite
                        File Info Size():  0
                     File Info ModTime():  2018-01-06 Sat 00:06:56.421236800 -0600 CST
                        File Info Mode():  drwxrwxrwx
                         File Info Sys():  &{16 {617269082 30594119} {2388100752 30639796} {2388100752 30639796} 0 0}
                                Dir path:  D:\go\work\src\MikeAustin71\pathfilego\003_filehelper\logTest\testoverwrite

---------------------------------------------------------------------------

Return Value:

isEmpty     bool - If the outcome of setting new values for DirMgr is an
                   'empty' DirMgr instance, this value will be set to 'true'.

err        error - If a program execution error is encountered during
                   processing, it will be returned as an 'error' type.

func (*DirMgr) SetDirMgrFromKnownPathDirName

func (dMgr *DirMgr) SetDirMgrFromKnownPathDirName(
	parentPathName, directoryName string) (isEmpty bool, err error)

SetDirMgrFromKnownPathDirectoryName - Configures the internal field values for the current DirMgr instance using a parent path name and a directory name. The parent path and directory name are combined to form the full path for the current 'DirMgr' instance.

This method will replace all previous field values with new values based on input parameters 'parentPathName' and 'directoryName'.

This method differs from other "Set" methods in that it assumes the input parameters are known values and do not require the usual analysis and validation screening applied by similar methods.

If more rigours input parameter validation is required, consider using method, DirMgr.SetDirMgr().

func (*DirMgr) SetDirMgrWithFileInfo

func (dMgr *DirMgr) SetDirMgrWithFileInfo(
	parentDirectoryPath string,
	info os.FileInfo) (err error)

SetDirMgrWithFileInfo - Sets the DirMgr fields and path strings for the current DirMgr object based on an input 'parentDirectoryPath' parameter and an os.FileInfo input parameter, 'info'.

------------------------------------------------------------------------------

Input Parameters:

parentDirectoryPath string - The parent directory path.

info           os.FileInfo - The os.FileInfo containing the directory name.

---------------------------------------------------------------------------

Return Value:

err        error - If a program execution error is encountered during
                   processing, it will be returned as an 'error' type.

func (*DirMgr) SetPermissions

func (dMgr *DirMgr) SetPermissions(permissionConfig FilePermissionConfig) (err error)

SetPermissions - Sets the read/write and execute permissions for the directory identified by the current DirMgr instance. Note the treatment of execute permissions may vary by operating system.

The permissions are configured based on input parameter 'permissionConfig' which is of type, 'FilePermissionConfig'. For an explanation of permission codes, see method 'FilePermissionConfig.New()'.

If the directory identified by the current DirMgr instance does not exist, an error will be returned.

func (*DirMgr) SubstituteBaseDir

func (dMgr *DirMgr) SubstituteBaseDir(
	baseDir DirMgr,
	substituteBaseDir DirMgr) (newDMgr DirMgr, err error)

SubstituteBaseDir - Substitute 'baseDir' segment of the current DirMgr with a new parent directory identified by input parameter 'substituteBaseDir'. This is useful in copying files to new directory trees.

type DirMgrCollection

type DirMgrCollection struct {
	// contains filtered or unexported fields
}

DirMgrCollection - A collection of Type DirMgr. The collection is used to aid in the management of groups of paths and directories.

Dependencies:

Type 'DirMgrCollection' depend on types, 'FileHelper' and 'FileMgr' which are contained in source code files: 'filehelper.go' and 'filemanager.go' located in this directory.

func (*DirMgrCollection) AddDirMgr

func (dMgrs *DirMgrCollection) AddDirMgr(dMgr DirMgr)

AddDirMgr - Adds a DirMgr object to the collection. Note that this method does not perform a validity check on input parameter, 'dMgr'.

It is recommended that dMgr.IsDirMgrValid() be called before adding the directory manager to the collection.

func (*DirMgrCollection) AddDirMgrByKnownPathDirName

func (dMgrs *DirMgrCollection) AddDirMgrByKnownPathDirName(parentPathName, dirName string) error

AddDirMgrByKnownPathDirName - Adds a Directory Manager (DirMgr) using know parent path and directory name. This method performs fewer string validations then similar methods.

func (*DirMgrCollection) AddDirMgrByPathNameStr

func (dMgrs *DirMgrCollection) AddDirMgrByPathNameStr(pathName string) error

AddDirMgrByPathNameStr - Adds a Directory Manager (DirMgr) to the collections based on a string input parameter, 'pathName'.

func (*DirMgrCollection) AddDirMgrCollection

func (dMgrs *DirMgrCollection) AddDirMgrCollection(dMgrs2 *DirMgrCollection)

AddDirMgrCollection - Adds another collection of File Manager (DirMgr) objects to the current collection.

func (*DirMgrCollection) AddFileInfo

func (dMgrs *DirMgrCollection) AddFileInfo(parentDirectoryPath string, info os.FileInfo) error

AddFileMgrByFileInfo - Adds a Directory Manager object to the collection based on input from a parent directory path string and an os.FileInfo object.

func (*DirMgrCollection) CopyOut

func (dMgrs *DirMgrCollection) CopyOut() (DirMgrCollection, error)

CopyOut - Returns an DirMgrCollection which is an exact duplicate of the current DirMgrCollection

func (*DirMgrCollection) DeleteAtIndex

func (dMgrs *DirMgrCollection) DeleteAtIndex(idx int) error

DeleteAtIndex - Deletes a member Directory Manager from the collection at the index specified by input parameter 'idx'.

If successful, at the completion of this method, the Directory Manager Collection array will have a length which is one less than the starting array length.

func (*DirMgrCollection) FindDirectories

func (dMgrs *DirMgrCollection) FindDirectories(
	fileSelectionCriteria FileSelectionCriteria) (DirMgrCollection, error)

FindDirectories - searches through the DirMgrCollection to find DirMgr objects matching specified search criteria.

func (*DirMgrCollection) GetDirMgrArray

func (dMgrs *DirMgrCollection) GetDirMgrArray() []DirMgr

GetDirMgrArray - Returns the entire Directory Manager Array managed by this collection.

------------------------------------------------------------------------

Input Parameter

None

------------------------------------------------------------------------

Return Values

[]DirMgr      - The array of of DirMgr instances maintained by this
                collection.

func (*DirMgrCollection) GetDirMgrAtIndex

func (dMgrs *DirMgrCollection) GetDirMgrAtIndex(idx int) (*DirMgr, error)

GetDirMgrAtIndex - If successful, this method returns a pointer to the DirMgr instance at the array index specified. The 'Peek' and 'Pop' methods below return DirMgr objects using a 'deep' copy and therefore offer better protection against data corruption.

func (*DirMgrCollection) GetNumOfDirs

func (dMgrs *DirMgrCollection) GetNumOfDirs() int

GetNumOfDirs - returns the number of directories contained in this Directory Manager Collection.

func (*DirMgrCollection) InsertDirMgrAtIndex

func (dMgrs *DirMgrCollection) InsertDirMgrAtIndex(dMgr DirMgr, index int) error

InsertDirMgrAtIndex - Inserts a new Directory Manager into the collection at array 'index'. The new Directory Manager is passed as input parameter 'dMgr'.

If input parameter 'index' is less than zero, an error will be returned. If 'index' exceeds the value of the last index in the collection, 'dMgr' will be added to the end of the collection at the next legal index.

func (DirMgrCollection) New

func (dMgrs DirMgrCollection) New() DirMgrCollection

New - Creates and returns a new and properly initialized Directory Manager Collection ('DirMgrCollection').

func (*DirMgrCollection) PeekDirMgrAtIndex

func (dMgrs *DirMgrCollection) PeekDirMgrAtIndex(idx int) (DirMgr, error)

PeekDirMgrAtIndex - Returns a deep copy of the Directory Manager ('DirMgr') object located at array index 'idx' in the Directory Manager Collection ('DirMgrCollection'). This is a 'Peek' method and therefore the original Directory Manager ('DirMgr') object is NOT deleted from the Directory Manager Collection ('DirMgrCollection') array.

At the completion of this method, the length of the Directory Manager Collection ('DirMgrCollection') array will remain unchanged.

func (*DirMgrCollection) PeekFirstDirMgr

func (dMgrs *DirMgrCollection) PeekFirstDirMgr() (DirMgr, error)

PeekFirstDirMgr - Returns a deep copy of the first Directory Manager ('DirMgr') object in the Directory Manager Collection ('DirMgrCollection'). This is a 'Peek' method and therefore the original Directory Manager ('DirMgr') object is NOT deleted from the Directory Manager Collection ('DirMgrCollection') array.

At the completion of this method, the length of the Directory Manager Collection ('DirMgrCollection') array will remain unchanged.

func (*DirMgrCollection) PeekLastDirMgr

func (dMgrs *DirMgrCollection) PeekLastDirMgr() (DirMgr, error)

PeekLastDirMgr - Returns a deep copy of the last Directory Manager ('DirMgr') object in the Directory Manager Collection ('DirMgrCollection').

This is a 'Peek' method and therefore the original Directory Manager ('DirMgr') object is NOT deleted from the Directory Manager Collection ('DirMgrCollection') array.

At the completion of this method, the length of the Directory Manager Collection ('DirMgrCollection') array will remain unchanged.

func (*DirMgrCollection) PopDirMgrAtIndex

func (dMgrs *DirMgrCollection) PopDirMgrAtIndex(idx int) (DirMgr, error)

PopDirMgrAtIndex - Returns a copy of the Directory Manager ('DirMgr') object located at index, 'idx', in the Directory Manager Collection ('DirMgrCollection') array.

As a 'Pop' method, the original Directory Manager ('DirMgr') object is deleted from the Directory Manager Collection ('DirMgrCollection') array. The 'DirMgr' object deleted is located at the index specified by input parameter, 'idx'.

Therefore at the completion of this method, the Directory Manager Collection array has a length which is one less than the starting array length.

If this method is called on an empty Director Manager Collection (i.e. length of array dMgrs.dirMgrs = 0), an io.EOF error is returned.

func (*DirMgrCollection) PopFirstDirMgr

func (dMgrs *DirMgrCollection) PopFirstDirMgr() (DirMgr, error)

PopFirstDirMgr - Returns a deep copy of the first Directory Manager ('DirMgr') object in the Directory Manager Collection array. As a 'Pop' method, the original Directory Manager ('DirMgr') object is deleted from the top of the Directory Manager Collection ('DirMgrCollection') array (dMgrs.dirMgrs array index = 0).

If this method is called on an empty Director Manager Collection (i.e. length of array dMgrs.dirMgrs = 0), an io.EOF error is returned.

Therefore at the completion of this method, the Directory Manager Collection array has a length which is one less than the starting array length.

func (*DirMgrCollection) PopLastDirMgr

func (dMgrs *DirMgrCollection) PopLastDirMgr() (DirMgr, error)

PopLastDirMgr - Returns a deep copy of the last Directory Manager ('DirMgr') object in the Directory Manager Collection array. As a 'Pop' method, the original Directory Manager ('DirMgr') object is deleted from the last array position of the Directory Manager Collection ('DirMgrCollection') array (dMgrs.dirMgrs[length-1]).

If this method is called on an empty Director Manager Collection (i.e. length of array dMgrs.dirMgrs = 0), an io.EOF error is returned.

Therefore at the completion of this method, the Directory Manager Collection array has a length which is one less than the starting array length.

func (*DirMgrCollection) SortByAbsPath

func (dMgrs *DirMgrCollection) SortByAbsPath(caseInsensitiveSort bool)

SortByAbsPath - Sorts the collection array of directory managers by absolute path.

If the input parameter 'caseInsensitiveSort' is set to 'true', it means that upper and lower case characters are NOT significant in the sorting operation. The sort operation therefore uses lower case versions of absolute path for comparison purposes.

On the other hand, if input parameter 'caseInsensitiveSort' is set to 'false', it means that upper and lower chase characters ARE significant to the sort operation.

type DirTreeCopyStats

type DirTreeCopyStats struct {
	TotalDirsScanned    uint64
	DirsCopied          uint64
	DirsCreated         uint64
	TotalFilesProcessed uint64
	FilesCopied         uint64
	FileBytesCopied     uint64
	FilesNotCopied      uint64
	FileBytesNotCopied  uint64
	ComputeError        error
}

type DirTreeOp

type DirTreeOp struct {
	CallingFunc        string
	FileOps            []FileOperationCode
	FileSelectCriteria FileSelectionCriteria
	SourceBaseDir      DirMgr
	TargetBaseDir      DirMgr
	ErrReturns         []error
}

DirTreeOp - Contains data fields used to store directory information generated by type DirMgr.

func (DirTreeOp) New

func (dTreeOp DirTreeOp) New() DirTreeOp

New - Creates, initializes and returns a new DirTreeOp instance.

type DirectoryCopyStats

type DirectoryCopyStats struct {
	DirCreated          uint64
	TotalFilesProcessed uint64
	FilesCopied         uint64
	FileBytesCopied     uint64
	FilesNotCopied      uint64
	FileBytesNotCopied  uint64
	ComputeError        error
}

type DirectoryDeleteFileInfo

type DirectoryDeleteFileInfo struct {
	StartPath                string
	Directories              DirMgrCollection
	ErrReturns               []error
	DeleteFileSelectCriteria FileSelectionCriteria
	DeletedFiles             FileMgrCollection
}

DirectoryDeleteFileInfo - structure used to delete files in a directory specified by 'StartPath'. Deleted files will be selected based on 'DeleteFileSelectCriteria' value.

'DeleteFileSelectCriteria' is a 'FileSelectionCriteria' type which contains FileNamePatterns strings and the FilesOlderThan or FilesNewerThan date time parameters which can be used as file selection criteria.

type DirectoryMoveStats

type DirectoryMoveStats struct {
	TotalSrcFilesProcessed   uint64
	SourceFilesMoved         uint64
	SourceFileBytesMoved     uint64
	SourceFilesRemaining     uint64
	SourceFileBytesRemaining uint64
	TotalDirsProcessed       uint64
	DirsCreated              uint64
	NumOfSubDirectories      uint64
	SourceDirWasDeleted      bool
	ComputeError             error
}

type DirectoryStatsDto

type DirectoryStatsDto struct {
	// contains filtered or unexported fields
}

func (*DirectoryStatsDto) IsInitialized

func (dirStats *DirectoryStatsDto) IsInitialized() bool

func (*DirectoryStatsDto) NumOfBytes

func (dirStats *DirectoryStatsDto) NumOfBytes() uint64

func (*DirectoryStatsDto) NumOfFiles

func (dirStats *DirectoryStatsDto) NumOfFiles() uint64

func (*DirectoryStatsDto) NumOfSubDirs

func (dirStats *DirectoryStatsDto) NumOfSubDirs() uint64

type DirectoryTreeInfo

type DirectoryTreeInfo struct {
	StartPath          string
	Directories        DirMgrCollection
	FoundFiles         FileMgrCollection
	ErrReturns         []error
	FileSelectCriteria FileSelectionCriteria
}

DirectoryTreeInfo - structure used to 'Find' files in a directory specified by 'StartPath'. The file search will be filtered by a 'FileSelectCriteria' object.

'FileSelectCriteria' is a FileSelectionCriteria type which contains FileNamePatterns strings and 'FilesOlderThan' or 'FilesNewerThan' date time parameters which can be used as a selection criteria.

func (*DirectoryTreeInfo) CopyToDirectoryTree

func (dirTree *DirectoryTreeInfo) CopyToDirectoryTree(
	baseDir, newBaseDir DirMgr) (DirectoryTreeInfo, error)

CopyToDirectoryTree - Copies an entire directory tree to an alternate location. The copy operation includes all files and all directories in the designated directory tree.

type FileAccessControl

type FileAccessControl struct {
	// contains filtered or unexported fields
}

FileAccessControl encapsulates the codes required the open files and configure file permissions. As such this type encapsulates types FilePermissionConfig and FileOpenConfig.

func (*FileAccessControl) CopyIn

func (fAccess *FileAccessControl) CopyIn(fA2 *FileAccessControl)

CopyIn - Receives a FileAccessControl instance and copies all the data fields to the current FileAccessControl instance. When complete, both the incoming and current FileAccessControl instances will be identical.

The type of copy operation performed is a 'deep copy'.

func (*FileAccessControl) CopyOut

func (fAccess *FileAccessControl) CopyOut() FileAccessControl

CopyOut - Creates and returns a deep copy of the current FileAccessControl instance.

func (*FileAccessControl) Empty

func (fAccess *FileAccessControl) Empty()

Empty - ReInitializes the current FileAccessControl instance to empty or zero values.

func (*FileAccessControl) Equal

func (fAccess *FileAccessControl) Equal(fA2 *FileAccessControl) bool

Equal - Returns 'true' if the incoming FileAccessControl instance is equal in all respects to the current FileAccessControl instance.

func (*FileAccessControl) GetCompositeFileOpenCode

func (fAccess *FileAccessControl) GetCompositeFileOpenCode() (int, error)

GetCompositeFileOpenCode - Returns the composite 'file open' code. This code is generated by combining the single FileOpenType value and zero or more FileOpenMode values.

func (*FileAccessControl) GetCompositePermissionMode

func (fAccess *FileAccessControl) GetCompositePermissionMode() (os.FileMode, error)

GetCompositePermissionMode - Returns the complete permission code as a type os.FileMode.

func (*FileAccessControl) GetCompositePermissionModeText

func (fAccess *FileAccessControl) GetCompositePermissionModeText() string

GetCompositePermissionModeText - Returns the composite permission file mode numerical value expressed as text.

Example:

      -rw-rw-rw- = returned value "0666"
      drwxrwxrwx = returned value "020000000777"

func (*FileAccessControl) GetFileOpenAndPermissionCodes

func (fAccess *FileAccessControl) GetFileOpenAndPermissionCodes() (int, os.FileMode, error)

GetFileOpenAndPermissionCodes - Returns both the complete File Open Code and complete Permission code.

func (*FileAccessControl) GetFileOpenConfig

func (fAccess *FileAccessControl) GetFileOpenConfig() (FileOpenConfig, error)

GetFileOpenConfig - Returns a deep copy of the FileOpenConfig type encapsulated by the current FileAccessControl instance.

func (*FileAccessControl) GetFileOpenType

func (fAccess *FileAccessControl) GetFileOpenType() (FileOpenType, error)

GetFileOpenType - Returns the File Open Type associated with the FileOpenConfig type stored as 'FileAccessControl.fileOpenCodes'.

func (*FileAccessControl) GetFilePermissionConfig

func (fAccess *FileAccessControl) GetFilePermissionConfig() (FilePermissionConfig, error)

GetFilePermissionConfig - Returns a deep copy of the FilePermissionConfig type encapsulated by the current FileAccessControl instance.

func (*FileAccessControl) GetFilePermissionTextCode

func (fAccess *FileAccessControl) GetFilePermissionTextCode() (string, error)

GetFilePermissionTextCode - Returns the file mode permissions expressed as a text string. The returned string includes the full and complete 10-character permission code.

Example Return Values:
      -rwxrwxrwx
      -rw-rw-rw-
      drwxrwxrwx

func (*FileAccessControl) IsValid

func (fAccess *FileAccessControl) IsValid() error

IsValid - If the current FileAccessControl instance is valid and properly initialized, this method returns nil. If the current FileAccessControl instance is invalid, this method returns an error.

func (FileAccessControl) New

func (fAccess FileAccessControl) New(
	openCodes FileOpenConfig,
	permissions FilePermissionConfig) (FileAccessControl, error)

New - Creates and returns a new instance of type FileAccessControl.

func (FileAccessControl) NewInitialized

func (fAccess FileAccessControl) NewInitialized() (FileAccessControl, error)

NewInitialized - Returns a new FileAccessControl instances with all File Open Codes and File Permission Codes initialized to 'None'.

func (FileAccessControl) NewReadOnlyAccess

func (fAccess FileAccessControl) NewReadOnlyAccess() (FileAccessControl, error)

NewReadOnlyAccess - Returns a FileAccessControl instance configured for Read-Only access.

func (FileAccessControl) NewReadWriteAccess

func (fAccess FileAccessControl) NewReadWriteAccess() (FileAccessControl, error)

NewReadWriteAccess - Returns a FileAccessControl instance configured for Read/Write access.

func (FileAccessControl) NewReadWriteCreateTruncateAccess

func (fAccess FileAccessControl) NewReadWriteCreateTruncateAccess() (FileAccessControl, error)

NewReadWriteCreateTruncateAccess - Returns a FileAccessControl instance configured for Read, Write, Create and Truncate access.

func (FileAccessControl) NewWriteOnlyAccess

func (fAccess FileAccessControl) NewWriteOnlyAccess() (FileAccessControl, error)

NewWriteOnlyAccess - Returns a FileAccessControl instance configured for Write-Only access.

func (FileAccessControl) NewWriteOnlyAppendAccess

func (fAccess FileAccessControl) NewWriteOnlyAppendAccess() (FileAccessControl, error)

NewWriteOnlyAppendAccess - Returns a FileAccessControl instance configured for Write/Only - Append access.

func (FileAccessControl) NewWriteOnlyTruncateAccess

func (fAccess FileAccessControl) NewWriteOnlyTruncateAccess() (FileAccessControl, error)

NewWriteOnlyTruncateAccess - Returns a FileAccessControl instance configured for Write/Only - Truncate access.

If the file previously exists, it will be truncated before the writing operation commences.

func (*FileAccessControl) SetFileOpenCodes

func (fAccess *FileAccessControl) SetFileOpenCodes(fileOpenCodes FileOpenConfig) error

SetFileOpenCodes - Assigns 'fileOpenCodes' to internal member variable, FileAccessControl.fileOpenCodes

func (*FileAccessControl) SetFilePermissionCodes

func (fAccess *FileAccessControl) SetFilePermissionCodes(
	filePermissions FilePermissionConfig) error

SetFilePermissionCodes - Assigns 'filePermissions' to internal member variable FileAccessControl.permissions.

type FileHelper

type FileHelper struct {
	Input  string
	Output string
}

FileHelper - The methods associated with this type provide generalized file creation, management and maintenance utilities.

'FileHelper' is a dependency for types 'DirMgr' and 'FileMgr'.

func (FileHelper) AddPathSeparatorToEndOfPathStr

func (fh FileHelper) AddPathSeparatorToEndOfPathStr(pathStr string) (string, error)

AddPathSeparatorToEndOfPathStr - Receives a path string as an input parameter. If the last character of the path string is not a path separator, this method will add a path separator to the end of that path string and return it to the calling method.

func (FileHelper) AdjustPathSlash

func (fh FileHelper) AdjustPathSlash(path string) string

AdjustPathSlash will standardize path separators according to operating system

func (FileHelper) AreSameFile

func (fh FileHelper) AreSameFile(pathFile1, pathFile2 string) (bool, error)

AreSameFile - Compares two paths or path/file names to determine if they are the same and equivalent.

An error will be triggered if one or both of the input parameters, 'pathFile1' and 'pathFile2' are empty/blank strings.

If the path file input parameters identify the same file, this method returns 'true'.

The two input parameters 'pathFile1' and 'pathFile2' will be converted to their absolute paths before comparisons are applied.

func (FileHelper) ChangeFileMode

func (fh FileHelper) ChangeFileMode(pathFileName string, filePermission FilePermissionConfig) error

ChangeFileMode changes the file mode of an existing file designated by input parameter 'pathFileName'. The os.FileMode value to which the mode will be changed is extracted from input parameter 'filePermission'.

If the file does Not exist, an error is triggered.

If the method succeeds and the file's mode is changed, an error value of 'nil' is returned.

func (FileHelper) ChangeFileTimes

func (fh FileHelper) ChangeFileTimes(pathFileName string, newAccessTime, newModTime time.Time) error

ChangeFileTimes - is a wrapper for os.Chtimes(). This method will set new access and modification times for a designated file.

If the path and file name do not exist, this method will return an error.

If successful, the access and modification times for the target file will be changed to to those specified by input parameters, 'newAccessTime' and 'newModTime'.

func (FileHelper) ChangeWorkingDir

func (fh FileHelper) ChangeWorkingDir(dirPath string) error

ChangeWorkingDir - Changes the current working directory to the named directory passed in input parameter, 'dirPath'. If there is an error, it will be of type *PathError.

func (FileHelper) CleanDirStr

func (fh FileHelper) CleanDirStr(dirNameStr string) (returnedDirName string, isEmpty bool, err error)

CleanDirStr - Cleans and formats a directory string.

Examples:

  dirName = '/someDir/xt_dirmgr_01_test.go' returns "./someDir"

  dirName = '../dir1/dir2/fileName.ext'     returns "../dir1/dir2"

  dirName = 'fileName.ext'                  returns "" isEmpty = true

  dirName = 'xt_dirmgr_01_test.go'          returns "" isEmpty = true

  dirName = '../dir1/dir2/'                 returns "../dir1/dir2"

  dirName = '../../../dir1/'                returns '../../../dir1'

  dirName = '../dir1/dir2/filename.ext'     returns "../dir1/dir2"

  dirName = '../dir1/dir2/.git'             returns "../dir1/dir2"

  dirName = 'somevalidcharacters'           returns "./somevalidchracters"

func (FileHelper) CleanFileNameExtStr

func (fh FileHelper) CleanFileNameExtStr(
	fileNameExtStr string) (returnedFileNameExt string, isEmpty bool, err error)

CleanFileNameExtStr - Cleans up a file name extension string.

Example:
  fileNameExt = '../dir1/dir2/fileName.ext'
                returns "fileName.ext" and isEmpty=false

  fileNameExt = 'fileName.ext"
                 returns "fileName.ext" and isEmpty=false

  fileNameExt = "../filesfortest/newfilesfortest/" (actually exists on disk)
                returns "" and isEmpty=true and error = nil

  fileNameExt = '../dir1/dir2/'
                 returns "" and isEmpty=true

  fileNameExt = '../filesfortest/newfilesfortest/newerFileForTest_01'
                returns "newerFileForTest_01" and isEmpty=false

  fileNameExt = '../filesfortest/newfilesfortest/.gitignore'
                returns ".gitignore" and isEmpty=false

func (FileHelper) CleanPathStr

func (fh FileHelper) CleanPathStr(pathStr string) string

CleanPathStr - Wrapper Function for filepath.Clean() See: https://golang.org/pkg/path/filepath/#Clean Clean returns the shortest path name equivalent to path by purely lexical processing. It applies the following rules iteratively until no further processing can be done:

  1. Replace multiple Separator elements with a single one.

  2. Eliminate each . path name element (the current directory).

  3. Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.

  4. Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path, assuming Separator is '/'.'

The returned path ends in a slash only if it represents a root directory, such as "/" on Unix or `C:\` on Windows. Finally, any occurrences of slash are replaced by Separator. If the result of this process is an empty string, Clean returns the string ".".

func (FileHelper) ConsolidateErrors

func (fh FileHelper) ConsolidateErrors(errs []error) error

ConsolidateErrors - Receives an array of errors and converts them to a single error which is returned to the caller. Multiple errors are separated by a new line character.

If the length of the error array is zero, this method returns nil.

func (FileHelper) ConvertDecimalToOctal

func (fh FileHelper) ConvertDecimalToOctal(number int) int

ConvertDecimalToOctal - Utility routine to convert a decimal (base 10) numeric value to an octal (base 8) numeric value. Useful in evaluating 'os.FileMode' values and associated constants.

Reference:
 https://www.cloudhadoop.com/2018/12/golang-example-convertcast-octal-to.html

------------------------------------------------------------------------

Usage:

initialDecimalValue := 511
expectedOctalValue := 777

actualOctalValue := ConvertDecimalToOctal(initialDecimalValue)

'actualOctalValue' is now equal to integer value '777'.

------------------------------------------------------------------------

Warning:

In the Go Programming Language, if you initialize an integer with a leading zero (e.g. x:= int(0777)), than number ('0777') is treated as an octal value and converted to a decimal value. Therefore, x:= int(0777) will mean that 'x' is set equal to 511. If you set x:= int(777), x will be set equal to '777'.

func (FileHelper) ConvertOctalToDecimal

func (fh FileHelper) ConvertOctalToDecimal(number int) int

ConvertOctalToDecimal - Utility routine to convert an octal (base 8) numeric value to a decimal (base 10) numeric value. Useful in evaluating 'os.FileMode' values and associated constants.

Reference:
 https://www.cloudhadoop.com/2018/12/golang-example-convertcast-octal-to.html

------------------------------------------------------------------------

Usage:

	expectedDecimalValue := 511
	initialOctalValue := 777
	actualDecimalValue := FileHelper{}.ConvertOctalToDecimal(initialOctalValue)

 actualDecimalValue is now equal to integer value, '511'.

------------------------------------------------------------------------

Warning:

In the Go Programming Language, if you initialize an integer with a leading zero (e.g. x:= int(0777)), than number ('0777') is treated as an octal value and converted to a decimal value. Therefore, x:= int(0777) will mean that 'x' is set equal to 511. If you set x:= int(777), x will be set equal to '777'.

func (FileHelper) CopyFileByIo

func (fh FileHelper) CopyFileByIo(src, dst string) (err error)

CopyFileByIo - Copies file from source path and file name to destination path and file name.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

Note: Unlike the method CopyFileByLink above, this method does NOT rely on the creation of symbolic links. Instead, a new destination file is created and the contents of the source file are written to the new destination file using "io.Copy()".

"io.Copy()" is the only method used to copy the designated source file. If this method fails, an error is returned.

If source file is equivalent to the destination file, no action will be taken and no error will be returned.

If the destination file does not exist, this method will create. However, it will NOT create the destination directory. If the destination directory does NOT exist, this method will abort the copy operation and return an error.

func (fh FileHelper) CopyFileByIoByLink(src, dst string) (err error)

CopyFileByLinkByIo - Copies a file from source to destination using one of two techniques.

First, this method will attempt to copy the designated file by means of creating a new destination file and using "io.Copy(out, in)" to copy the contents. This is accomplished by calling 'FileHelper.CopyFileByIo()'. If the call to 'FileHelper.CopyFileByIo()' fails, this method will attempt a second copy method.

The second attempt to to copy the designated file will be accomplished by creating a 'hard link' to the source file. The second, 'hard link', attempt will call method, 'FileHelper.CopyFileByLink()'.

If that 'hard link' operation fails, this method will call 'FileHelper.CopyFileByIo()'.

If both attempted file copy operations fail, an error will be returned.

See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (fh FileHelper) CopyFileByLink(src, dst string) (err error)

CopyFileByLink - Copies a file from source to destination by means of creating a 'hard link' to the source file, "os.Link(src, dst)".

Note: This method of copying files does not create a new destination file and write the contents of the source file to destination file. (See CopyFileByIo Below). Instead, this method performs the copy operation by creating a hard symbolic link to the source file.

By creating a 'linked' file, changing the contents of one file will be reflected in the second. The two linked files are 'mirrors' of each other.

Consider using CopyFileByIo() if the 'mirror' feature causes problems.

"os.Link(src, dst)" is the only method employed to copy a designated file. If "os.Link(src, dst)" fails, an err is returned.

See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

REQUIREMENT: The destination Path must previously exist. The destination file need NOT exist as it will be created. If the destination file currently exists, it will first be deleted and a new linked file will be crated.

func (FileHelper) CopyFileByLinkByIo

func (fh FileHelper) CopyFileByLinkByIo(src, dst string) (err error)

CopyFileByLinkByIo - Copies a file from source to destination using one of two techniques.

First, this method will attempt to copy the designated file by means of creating a 'hard link' to the source file. The 'hard link' attempt will call 'FileHelper.CopyFileByLink()'.

If that 'hard link' operation fails, this method will call 'FileHelper.CopyFileByIo()'.

CopyFileByIo() will create a new destination file and attempt to write the contents of the source file to the new destination file using "io.Copy(out, in)".

If both attempted file copy operations fail, an error will be returned.

See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (FileHelper) CreateFile

func (fh FileHelper) CreateFile(pathFileName string) (*os.File, error)

CreateFile - Wrapper function for os.Create. If the path component of input parameter 'pathFileName' does not exist, a type *PathError will be returned.

This method will 'create' the file designated by input parameter 'pathFileName'. 'pathFileName' should consist of a valid path, file name. The file name may consist of a file name and file extension or simply a file name.

If successful, this method will return a valid pointer to a type 'os.File' and an error value of 'nil'.

func (FileHelper) DeleteDirFile

func (fh FileHelper) DeleteDirFile(pathFile string) error

DeleteDirFile - Wrapper function for Remove. Remove removes the named file or directory. If there is an error, it will be a Non-Path Error.

func (FileHelper) DeleteDirPathAll

func (fh FileHelper) DeleteDirPathAll(pathDir string) error

DeleteDirPathAll - Wrapper function for RemoveAll. This method removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, this method takes no action and returns nil (no error).

Consider the following Example:

  1. D:\T08\x294_1\x394_1\x494_1 is a directory path that currently exists and contains files.

  2. Call DeleteDirPathAll("D:\\T08\\x294_1")

  3. Upon return from method DeleteDirPathAll(): a. Deletion Results: Directory D:\T08\x294_1\x394_1\x494_1 and any files in the 'x494_1' directory are deleted Directory D:\T08\x294_1\x394_1\ and any files in the 'x394_1' directory are deleted Directory D:\T08\x294_1\ and any files in the 'x294_1' directory are deleted

    b. The Parent Path 'D:\T08' and any files in that parent path 'D:\T08' directory are unaffected and continue to exist.

func (FileHelper) DeleteFilesWalkDirectory

func (fh FileHelper) DeleteFilesWalkDirectory(
	startPath string, fileSelectCriteria FileSelectionCriteria) (DirectoryDeleteFileInfo, error)

DeleteFilesWalkDirectory - This method 'walks' the directory tree searching for files which match the file selection criteria specified by input parameter 'fileSelectCriteria'. When a file matching said 'fileSelectCriteria' is found, that file is deleted.

IMPORTANT: This method deletes files!

This method returns file information on files deleted.

If a file matches the File Selection Criteria ('fileSelectCriteria') it is deleted and its file information is recorded in the returned DirectoryDeleteFileInfo instance, DirectoryDeleteFileInfo.DeletedFiles.

By the way, if ALL the file selection criterion are set to zero values or 'Inactive', then ALL FILES in the directory are selected, deleted and returned in the field, 'DirectoryDeleteFileInfo.DeletedFiles'.

------------------------------------------------------------------------

Input Parameter:

 startPath                         string - A string consisting of the starting path or
                                            or directory from which the file search
                                            operation will commence.

 fileSelectCriteria FileSelectionCriteria -
	    This input parameter should be configured with the desired file
	    selection criteria. Files matching this criteria will be returned as
	    'Found Files'. If file 'fileSelectCriteria' is uninitialized (FileSelectionCriteria{}).
     all directories the 'startPath' will be searched and all files within those
     directories will be deleted.

      _______________________________________________________________________________________________
      type FileSelectionCriteria struct {
        FileNamePatterns     []string    // An array of strings containing File Name Patterns
        FilesOlderThan       time.Time   // Match files with older modification date times
        FilesNewerThan       time.Time   // Match files with newer modification date times
        SelectByFileMode     FilePermissionConfig // Match file mode (os.FileMode).
        SelectCriterionMode  FileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
      }

      The FileSelectionCriteria type allows for configuration of single or multiple file
      selection criterion. The 'SelectCriterionMode' can be used to specify whether the
      file must match all, or any one, of the active file selection criterion.

      Elements of the FileSelectionCriteria Type are described below:

      FileNamePatterns []string  - An array of strings which may define one or more
                                   search patterns. If a file name matches any one of the
                                   search pattern strings, it is deemed to be a 'match'
                                   for the search pattern criterion.

                                     Example Patterns:
                                      FileNamePatterns = []string{"*.log"}
                                      FileNamePatterns = []string{"current*.txt"}
                                      FileNamePatterns = []string{"*.txt", "*.log"}

                                   If this string array has zero length or if
                                   all the strings are empty strings, then this
                                   file search criterion is considered 'Inactive'
                                   or 'Not Set'.

      FilesOlderThan  time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file is older than
                                  the 'FilesOlderThan' date time, that file is considered
                                  a 'match'	for this file selection criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

     FilesNewerThan   time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

     SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

     SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  _____________________________________________________________________

                                  FileSelectCriterionMode(0).ANDSelect() -
                                     File selected if all active selection criteria
                                     are satisfied.

                                     If this constant value is specified for the file selection mode,
                                     then a given file will not be judged as 'selected' unless all of
                                     the active selection criterion are satisfied. In other words, if
                                     three active search criterion are provided for 'FileNamePatterns',
                                     'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                     selected unless it has satisfied all three criterion in this example.

                                  FileSelectCriterionMode(0).ORSelect() -
                                     File selected if any active selection criterion is satisfied.

                                     If this constant value is specified for the file selection mode,
                                     then a given file will be selected if any one of the active file
                                     selection criterion is satisfied. In other words, if three active
                                     search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                     and 'FilesNewerThan', then a file will be selected if it satisfies any
                                     one of the three criterion in this example.

                                  _____________________________________________________________________

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are
'Inactive' or 'Not Set' (set to their zero or default values), then all of
the files processed in the directory tree will be deleted and returned in the
the file manager collection, DirectoryDeleteFileInfo.DeletedFiles.

  Example:
     FileNamePatterns  = ZERO Length Array
     filesOlderThan    = time.Time{}
     filesNewerThan    = time.Time{}

  In this example, all of the selection criterion are
  'Inactive' and therefore all of the files encountered
  in the target directory will be selected and returned
  as 'Found Files'.

  This same effect can be achieved by simply creating an
  empty file selection instance:

          FileSelectionCriteria{}

------------------------------------------------------------------------

Return Values:

DirectoryDeleteFileInfo -
                    If successful, files matching the file selection criteria input
                    parameter shown above will be deleted and returned in a
                    'DirectoryDeleteFileInfo' object. The file manager
                    'DirectoryDeleteFileInfo.DeletedFiles' contains information on all files
                    deleted during this operation.

              Note: It is a good idea to check the returned field 'DirectoryTreeInfo.ErrReturns'
                    to determine if any internal system errors were encountered while processing
                    the directory tree.

        __________________________________________________________________________________________________

        type DirectoryDeleteFileInfo struct {

          StartPath             string                // The starting path or directory for the file search

          Directories           DirMgrCollection      // Directory Manager instances found during the
                                                      //   directory tree search.
          DeletedFiles          FileMgrCollection     // Contains File Managers for Deleted Files matching
                                                      //   file selection criteria.
          ErrReturns            []error               // Internal System errors encountered during the search
                                                      //   and file deletion operations.
          FileSelectCriteria    FileSelectionCriteria // The File Selection Criteria submitted as an
                                                      // input parameter to this method.
        }

        __________________________________________________________________________________________________

error - If a program execution error is encountered during processing, it will
        be returned as an 'error' type. Also, see the comment on 'DirectoryDeleteFileInfo.ErrReturns',
        above.

func (FileHelper) DoesFileExist

func (fh FileHelper) DoesFileExist(pathFileName string) bool

DoesFileExist - Returns a boolean value designating whether the passed file name exists.

This method does not differentiate between Path Errors and Non-Path Errors returned by os.Stat(). The method only returns a boolean value.

If a Non-Path Error is returned by os.Stat(), this method will classify the file as "Does NOT Exist" and return a value of false.

For a more granular test of whether a file exists, see method FileHelper.DoesThisFileExist().

func (FileHelper) DoesFileInfoExist

func (fh FileHelper) DoesFileInfoExist(
	pathFileName string) (doesFInfoExist bool, fInfo os.FileInfo, err error)

DoesFileInfoExist - returns a boolean value indicating whether the path and file name passed to the function actually exists.

If the file actually exists, the function will return the associated FileInfo structure.

If 'pathFileName' does NOT exist, 'doesFInfoExist' will be set to'false', 'fInfo' will be set to 'nil' and the returned error value will be 'nil'.

func (FileHelper) DoesStringEndWithPathSeparator

func (fh FileHelper) DoesStringEndWithPathSeparator(pathStr string) bool

DoesStringEndWithPathSeparator - Returns 'true' if the string ends with a valid Path Separator. ('/' or '\' depending on the operating system)

func (FileHelper) DoesThisFileExist

func (fh FileHelper) DoesThisFileExist(pathFileName string) (pathFileNameDoesExist bool,
	nonPathError error)

DoesThisFileExist - Returns a boolean value signaling whether the path and file name represented by input parameter, 'pathFileName', does in fact exist. Unlike the similar method FileHelper.DoesFileExist(), this method returns an error in the case of Non-Path errors associated with 'pathFileName'.

Non-Path errors may arise for a variety of reasons, but the most common is associated with 'access denied' situations.

func (*FileHelper) FilterFileName

func (fh *FileHelper) FilterFileName(
	info os.FileInfo,
	fileSelectionCriteria FileSelectionCriteria) (isMatchedFile bool, err error)

FilterFileName - Utility method designed to determine whether a file described by a filePath string and an os.FileInfo object meets any one of three criteria: A string pattern match, a modification time which is older than the 'findFileOlderThan' parameter or a modification time which is newer than the 'findFileNewerThan' parameter.

If the three search criteria are all set the their 'zero' or default values, the no selection filter is applied and all files are deemed to be a match for the selection criteria ('isMatchedFile=true').

Three selection criterion are applied to the file name (info.Name()).

If a given selection criterion is set to a zero value, then that criterion is defined as 'not set' and therefore not used in determining determining whether a file is a 'match'.

If a given criterion is set to a non-zero value, then that criterion is defined as 'set' and the file information must comply with that criterion in order to be judged as a match ('isMatchedFile=true').

If none of the three criterion are 'set', then all files are judged as matched ('isMatchedFile=true').

If one of the three criterion is 'set', then a file must comply with that one criterion in order to be judged as matched ('isMatchedFile=true').

If two criteria are 'set', then the file must comply with both of those criterion in order to be judged as matched ('isMatchedFile=true').

If three criteria are 'set', then the file must comply with all three criterion in order to be judged as matched ('isMatchedFile=true').

func (FileHelper) FindFilesInPath

func (fh FileHelper) FindFilesInPath(pathName, fileSearchPattern string) ([]string, error)

FindFilesInPath - Will apply a search pattern to files and directories in the path designated by input parameter, 'pathName'. If the files and or directory names match the input parameter, 'fileSearchPattern' they will be returned in an array of strings.

Be Advised! The names returned in the string array may consist of both files and directory names, depending on the specified, 'fileSearchPattern'.

This method uses the "path/filepath" function, 'Glob'. Reference:

https://golang.org/pkg/path/filepath/#Glob

The File matching patterns depend on the 'go' "path/filepath" function, 'Match'. Reference https://golang.org/pkg/path/filepath/#Match

Note: This method will NOT search sub-directories. It will return the names of directories existing in the designated, 'pathName', depending on the 'fileSearchPattern' passed as an input parameter.

If Input Parameters 'pathName' or 'fileSearchPattern' are empty strings or consist of all space characters, this method will return an error.

Example 'fileSearchPattern' values:
      "*"     = Returns all files and directories (everything)
      "*.*"   = Returns files which have a file extension
      "*.txt" = Returns only files with a "txt" file extension

func (FileHelper) FindFilesWalkDirectory

func (fh FileHelper) FindFilesWalkDirectory(
	startPath string,
	fileSelectCriteria FileSelectionCriteria) (DirectoryTreeInfo, error)

FindFilesWalkDirectory - This method returns file information on files residing in a specified directory tree identified by the input parameter, 'startPath'.

This method 'walks the directory tree' locating all files in the directory tree which match the file selection criteria submitted as input parameter, 'fileSelectCriteria'.

If a file matches the File Selection Criteria, it is included in the returned field, 'DirectoryTreeInfo.FoundFiles'. By the way, if ALL the file selection criterion are set to zero values or 'Inactive', then ALL FILES in the directory are selected and returned in the field, 'DirectoryTreeInfo.FoundFiles'.

------------------------------------------------------------------------

Input Parameter:

 startPath                         string - A string consisting of the starting path or
                                            or directory from which the find files search
                                            operation will commence.

 fileSelectCriteria FileSelectionCriteria -
	    This input parameter should be configured with the desired file
	    selection criteria. Files matching this criteria will be returned as
	    'Found Files'. If file 'fileSelectCriteria' is uninitialized (FileSelectionCriteria{}).
     all directories and files will be returned from the 'startPath'

      _______________________________________________________________________________________________
      type FileSelectionCriteria struct {
        FileNamePatterns     []string    // An array of strings containing File Name Patterns
        FilesOlderThan       time.Time   // Match files with older modification date times
        FilesNewerThan       time.Time   // Match files with newer modification date times
        SelectByFileMode     FilePermissionConfig // Match file mode (os.FileMode).
        SelectCriterionMode  FileSelectCriterionMode // Specifies 'AND' or 'OR' selection mode
      }

      The FileSelectionCriteria type allows for configuration of single or multiple file
      selection criterion. The 'SelectCriterionMode' can be used to specify whether the
      file must match all, or any one, of the active file selection criterion.

      Elements of the FileSelectionCriteria Type are described below:

      FileNamePatterns []string  - An array of strings which may define one or more
                                   search patterns. If a file name matches any one of the
                                   search pattern strings, it is deemed to be a 'match'
                                   for the search pattern criterion.

                                     Example Patterns:
                                      FileNamePatterns = []string{"*.log"}
                                      FileNamePatterns = []string{"current*.txt"}
                                      FileNamePatterns = []string{"*.txt", "*.log"}

                                   If this string array has zero length or if
                                   all the strings are empty strings, then this
                                   file search criterion is considered 'Inactive'
                                   or 'Not Set'.

      FilesOlderThan  time.Time - This date time type is compared to file
                                  modification date times in order to determine
                                  whether the file is older than the 'FilesOlderThan'
                                  file selection criterion. If the file is older than
                                  the 'FilesOlderThan' date time, that file is considered
                                  a 'match'	for this file selection criterion.

                                  If the value of 'FilesOlderThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

     FilesNewerThan   time.Time - This date time type is compared to the file
                                  modification date time in order to determine
                                  whether the file is newer than the 'FilesNewerThan'
                                  file selection criterion. If the file modification date time
                                  is newer than the 'FilesNewerThan' date time, that file is
                                  considered a 'match' for this file selection criterion.

                                  If the value of 'FilesNewerThan' is set to time zero,
                                  the default value for type time.Time{}, then this
                                  file selection criterion is considered to be 'Inactive'
                                  or 'Not Set'.

     SelectByFileMode  FilePermissionConfig -
                                  Type FilePermissionConfig encapsulates an os.FileMode. The file
                                  selection criterion allows for the selection of files by File Mode.
                                  File modes are compared to the value	of 'SelectByFileMode'. If the
                                  File Mode for a given file is equal to the value of 'SelectByFileMode',
                                  that file is considered to be a 'match' for this file selection
                                  criterion. Examples for setting SelectByFileMode are shown as follows:

                                       fsc := FileSelectionCriteria{}
                                       err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
                                       err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")

     SelectCriterionMode FileSelectCriterionMode -
                                  This parameter selects the manner in which the file selection
                                  criteria above are applied in determining a 'match' for file
                                  selection purposes. 'SelectCriterionMode' may be set to one of
                                  two constant values:

                                  _____________________________________________________________________

                                  FileSelectCriterionMode(0).ANDSelect() -
                                     File selected if all active selection criteria
                                     are satisfied.

                                     If this constant value is specified for the file selection mode,
                                     then a given file will not be judged as 'selected' unless all of
                                     the active selection criterion are satisfied. In other words, if
                                     three active search criterion are provided for 'FileNamePatterns',
                                     'FilesOlderThan' and 'FilesNewerThan', then a file will NOT be
                                     selected unless it has satisfied all three criterion in this example.

                                  FileSelectCriterionMode(0).ORSelect() -
                                     File selected if any active selection criterion is satisfied.

                                     If this constant value is specified for the file selection mode,
                                     then a given file will be selected if any one of the active file
                                     selection criterion is satisfied. In other words, if three active
                                     search criterion are provided for 'FileNamePatterns', 'FilesOlderThan'
                                     and 'FilesNewerThan', then a file will be selected if it satisfies any
                                     one of the three criterion in this example.

                                  _____________________________________________________________________

------------------------------------------------------------------------

IMPORTANT:

If all of the file selection criterion in the FileSelectionCriteria object are
'Inactive' or 'Not Set' (set to their zero or default values), then all of
the files processed in the directory tree will be selected and returned as
'Found Files'.

  Example:
     FileNamePatterns  = ZERO Length Array
     filesOlderThan    = time.Time{}
     filesNewerThan    = time.Time{}

  In this example, all of the selection criterion are
  'Inactive' and therefore all of the files encountered
  in the target directory will be selected and returned
  as 'Found Files'.

  This same effect can be achieved by simply creating an
  empty file selection instance:

          FileSelectionCriteria{}

------------------------------------------------------------------------

Return Values:

DirectoryTreeInfo - If successful, files matching the file selection criteria input
                    parameter shown above will be returned in a 'DirectoryTreeInfo'
                    object. The field 'DirectoryTreeInfo.FoundFiles' contains information
                    on all the files in the specified directory tree which match the file selection
                    criteria.

              Note: It is a good idea to check the returned field 'DirectoryTreeInfo.ErrReturns'
                    to determine if any internal system errors were encountered while processing
                    the directory tree.

        __________________________________________________________________________________________________

        type DirectoryTreeInfo struct {
          StartPath             string                // The starting path or directory for the file search
          dirMgrs               []DirMgr              // dirMgrs found during directory tree search
          FoundFiles            []FileWalkInfo        // Found Files matching file selection criteria
          ErrReturns            []string              // Internal System errors encountered
          FileSelectCriteria    FileSelectionCriteria // The File Selection Criteria submitted as an
                                                      // input parameter to this method.
        }

        __________________________________________________________________________________________________

error - If a program execution error is encountered during processing, it will
        be returned as an 'error' type. Also, see the comment on 'DirectoryTreeInfo.ErrReturns',
        above.

func (FileHelper) GetAbsCurrDir

func (fh FileHelper) GetAbsCurrDir() (string, error)

GetAbsCurrDir - Returns the absolute path of the current working directory.

The current work directory is determined by a call to os.Getwd(). 'Getwd()' returns a rooted path name corresponding to the current directory. If the current directory can be reached via multiple paths (due to symbolic links), 'Getwd()' may return any one of them.

func (FileHelper) GetAbsPathFromFilePath

func (fh FileHelper) GetAbsPathFromFilePath(filePath string) (string, error)

GetAbsPathFromFilePath - Supply a string containing both the path file name and extension. This method will then return the absolute value of that path, file name and file extension.

func (FileHelper) GetCurrentDir

func (fh FileHelper) GetCurrentDir() (string, error)

GetCurrentDir - Wrapper function for Getwd(). Getwd returns a rooted path name corresponding to the current directory. If the current directory can be reached via multiple paths (due to symbolic links), Getwd may return any one of them.

func (FileHelper) GetDotSeparatorIndexesInPathStr

func (fh FileHelper) GetDotSeparatorIndexesInPathStr(pathStr string) ([]int, error)

GetDotSeparatorIndexesInPathStr - Returns an array of integers representing the indexes of dots ('.') located in input parameter 'pathStr'.

func (FileHelper) GetExecutablePathFileName

func (fh FileHelper) GetExecutablePathFileName() (string, error)

GetExecutablePathFileName - Gets the path and file name of the executable that started the current process.

This executable path and file name is generated by a call to os.Executable().

os.Executable() returns the path name for the executable that started the current process. There is no guarantee that the path is still pointing to the correct executable. If a symlink was used to start the process, depending on the operating system, the result might be the symlink or the path it pointed to. If a stable result is needed, path/filepath.EvalSymlinks might help.

Executable returns an absolute path unless an error occurred.

The main use case is finding resources located relative to an executable.

Executable is not supported on nacl.

func (FileHelper) GetFileExtension

func (fh FileHelper) GetFileExtension(
	pathFileNameExt string) (ext string, isEmpty bool, err error)

GetFileExt - Returns the File Extension with the dot. If there is no File Extension an empty string is returned (NO dot included). If the returned File Extension is an empty string, the returned parameter 'isEmpty' is set equal to 'true'.

When an extension is returned in the 'ext' variable, this extension includes a leading dot. Example: '.txt'

Example:

 Actual File Name Plus Extension: "newerFileForTest_01.txt"
         Returned File Extension: "txt"

 Actual File Name Plus Extension: "newerFileForTest_01"
         Returned File Extension: ""

 Actual File Name Plus Extension: ".gitignore"
         Returned File Extension: ""

func (FileHelper) GetFileInfo

func (fh FileHelper) GetFileInfo(pathFileName string) (os.FileInfo, error)

GetFileInfo - Wrapper function for os.Stat(). This method can be used to return FileInfo data on a specific file. If the file does NOT exist, an error will be triggered.

This method is similar to FileHelper.DoesFileInfoExist().

type FileInfo interface {
  Name()    string       // base name of the file
  Size()    int64        // length in bytes for regular files; system-dependent for others
  Mode()    FileMode     // file mode bits
  ModTime() time.Time    // modification time
  IsDir()   bool         // abbreviation for Mode().IsDir()
  Sys()     interface{}  // underlying data source (can return nil)
}

func (FileHelper) GetFileLastModificationDate

func (fh FileHelper) GetFileLastModificationDate(
	pathFileName string,
	customTimeFmt string) (time.Time, string, error)

GetFileLastModificationDate - Returns the last modification' date/time on a specific file. If input parameter 'customTimeFmt' string is empty, a default time format will be used to format the returned time string.

The default date time format is:

"2006-01-02 15:04:05.000000000"

func (FileHelper) GetFileMode

func (fh FileHelper) GetFileMode(pathFileName string) (FilePermissionConfig, error)

GetFileMode - Returns the mode (os.FileMode) for the file designated by input parameter 'pathFileName'. If the file does not exist, an error is triggered.

The 'os.FileMode' is returned via type 'FilePermissionCfg' which includes methods necessary to interpret the 'os.FileMode'.

func (FileHelper) GetFileNameWithExt

func (fh FileHelper) GetFileNameWithExt(
	pathFileNameExt string) (fNameExt string, isEmpty bool, err error)

GetFileNameWithExt - This method expects to receive a valid directory path and file name or file name plus extension. It then extracts the File Name and Extension from the file path and returns it as a string.

------------------------------------------------------------------------

Input Parameters:

pathFileNameExt string - This input parameter is expected to contain a properly formatted directory
                         path and File Name.  The File Name may or may not include a File Extension.
                         The directory path must include the correct delimiters such as path Separators
                         ('/' or'\'), dots ('.') and in the case of Windows, a volume designation
                         (Example: 'F:').

------------------------------------------------------------------------

Return Values:

fNameExt  string       - If successful, this method will the return value 'fNameExt' equal to the
                         File Name and File Extension extracted from the input file path, 'pathFileNameExt'.
                         Example 'fNameExt' return value: 'someFilename.txt'

                         If the File Extension is not present, only the File Name will be returned.
                         Example return value with no file extension: 'someFilename'.

isEmpty   bool         - If this method CAN NOT parse out a valid File Name and Extension from
                         input parameter string 'pathFileNameExt', return value 'fNameExt' will
                         be set to an empty string and return value 'isEmpty' will be set to 'true'.

err       error        - If an error is encountered during processing, 'err' will return a properly
                         formatted 'error' type.

                         Note that if this method cannot parse out a valid	File Name and Extension
                         due to an improperly formatted directory path and	file name string
                         (Input Parameter: 'pathFileNameExt'), 'fNameExt' will be set to an empty string,
                         'isEmpty' will be set to 'true' and 'err' return 'nil'. In this situation, no
                         error will be returned.

func (FileHelper) GetFileNameWithoutExt

func (fh FileHelper) GetFileNameWithoutExt(
	pathFileNameExt string) (fName string, isEmpty bool, err error)

GetFileNameWithoutExt - returns the file name without the path or extension. If the returned File Name is an empty string, isEmpty is set to true.

Example:

      Actual Path Plus File Name: = "./pathfilego/003_filehelper/common/xt_dirmgr_01_test.go"
              Returned File Name: = "dirmgr_01_test"

 Actual File Name Plus Extension: "newerFileForTest_01.txt"
              Returned File Name: "newerFileForTest_01"

 Actual File Name Plus Extension: "newerFileForTest_01"
              Returned File Name: "newerFileForTest_01"

 Actual File Name Plus Extension: ".gitignore"
              Returned File Name: ".gitignore"

func (FileHelper) GetFirstLastNonSeparatorCharIndexInPathStr

func (fh FileHelper) GetFirstLastNonSeparatorCharIndexInPathStr(
	pathStr string) (firstIdx, lastIdx int, err error)

GetFirstLastNonSeparatorCharIndexInPathStr - Basically this method returns the first index of the first alpha numeric character in a path string.

Specifically, the character must not be a path Separator ('\', '/') and it must not be a dot ('.').

If the first Non-Separator char is found, this method will return an integer index which is greater than or equal to zero plus an error value of nil.

The first character found will never be part of the volume name. Example On Windows: "D:\fDir1\fDir2" - first character index will be 3 denoting character 'f'.

func (FileHelper) GetLastPathElement

func (fh FileHelper) GetLastPathElement(pathName string) (string, error)

GetLastPathElement - Analyzes a 'pathName' string and returns the last element in the path. If 'pathName' ends in a path separator ('/'), this method returns an empty string.

Example:

pathName = '../dir1/dir2/fileName.ext' will return "fileName.ext"
pathName = '../dir1/dir2/' will return ""
pathName = 'fileName.ext' will return "fileName.ext"
pathName = '../dir1/dir2/dir3' will return "dir3"

func (FileHelper) GetPathAndFileNameExt

func (fh FileHelper) GetPathAndFileNameExt(
	pathFileNameExt string) (pathDir, fileNameExt string, bothAreEmpty bool, err error)

GetPathAndFileNameExt - Breaks out path and fileName+Ext elements from a path string. If both path and fileName are empty strings, this method returns an error.

func (FileHelper) GetPathFromPathFileName

func (fh FileHelper) GetPathFromPathFileName(
	pathFileNameExt string) (dirPath string, isEmpty bool, err error)

GetPathFromPathFileName - Returns the path from a path and file name string. If the returned path is an empty string, return parameter 'isEmpty' is set to 'true'.

------------------------------------------------------------------------

Input Parameter:

pathFileNameExt  string - This is an input parameter. The method expects to
                          receive a single, properly formatted path and file
                          name string delimited by dots ('.') and path Separators
                          ('/' or '\'). On Windows the 'pathFileNameExt' string
                          valid volume designations (Example: "D:")

------------------------------------------------------------------------

Return Values:

path             string - This is the directory path extracted from the input parameter
                          'pathFileNameExt'. If successful, the 'path' string that is returned
                          by this method WILL NOT include a trailing path separator ('/' or '\'
                          depending on the os). Example 'path': "./pathfile/003_filehelper"

isEmpty            bool - If the method determines that it cannot extract a valid directory
                          path from input parameter 'pathFileNameExt', this boolean value
                          will be set to 'true'. Failure to extract a valid directory path
                          will occur if the input parameter 'pathFileNameExt' is not properly
                          formatted as a valid path and file name.

err               error - If a processing error is detected, an error will be returned. Note that
                          in the event that this method fails to extract a valid directory path
                          'pathFileNameExt' due to the fact that 'pathFileNameExt' was improperly
                          formatted, 'isEmpty' will be set to 'true', but no error will be returned.

                          If no error occurs, 'err' is set to 'nil'.

------------------------------------------------------------------------

Examples:

pathFileNameExt = ""                  returns isEmpty==true  err==nil
pathFileNameExt = "D:\"               returns "D:\"
pathFileNameExt = "."                 returns ".\"
pathFileNameExt = "..\"               returns "..\"
pathFileNameExt = "...\"              returns ERROR

pathFileNameExt = ".\pathfile\003_filehelper\wt_HowToRunTests.md"
                                      returns ".\pathfile\003_filehelper"

pathFileNameExt = "someFile.go"       returns ""
pathFileNameExt = "..\dir1\dir2\.git" returns "..\dir1\dir2"
                                       '.git' is assumed to be a file.

func (FileHelper) GetPathSeparatorIndexesInPathStr

func (fh FileHelper) GetPathSeparatorIndexesInPathStr(
	pathStr string) ([]int, error)

GetPathSeparatorIndexesInPathStr - Returns an array containing the indexes of path Separators (Forward slashes or backward slashes depending on operating system).

func (FileHelper) GetVolumeName

func (fh FileHelper) GetVolumeName(pathStr string) string

GetVolumeName - Returns the volume name of associated with a given directory path. The method calls the function 'path/filepath.VolumeName().

VolumeName() returns the leading volume name if it exists in input parameter 'pathStr'.

Given "C:\foo\bar" it returns "C:" on Windows. Given "c:\foo\bar" it returns "c:" on Windows. Given "\\host\share\foo" it returns "\\host\share" on linux On other platforms, it returns "".

func (FileHelper) GetVolumeNameIndex

func (fh FileHelper) GetVolumeNameIndex(
	pathStr string) (volNameIndex int, volNameLength int, volNameStr string)

GetVolumeNameIndex - Analyzes input parameter 'pathStr' to determine if it contains a volume name. The method calls the function 'path/filepath.VolumeName().

VolumeName() returns the leading volume name if it exists in input parameter 'pathStr'.

Given "C:\foo\bar" it returns "C:" on Windows. Given "c:\foo\bar" it returns "c:" on Windows. Given "\\host\share\foo" it returns "\\host\share" on linux On other platforms, it returns "".

func (FileHelper) IsAbsolutePath

func (fh FileHelper) IsAbsolutePath(pathStr string) bool

IsAbsolutePath - Compares the input parameter 'pathStr' to the absolute path representation for 'pathStr' to determine whether 'pathStr' represents an absolute path.

func (FileHelper) IsPathFileString

func (fh FileHelper) IsPathFileString(
	pathFileStr string) (pathFileType PathFileTypeCode,
	absolutePathFile string,
	err error)

IsPathFileString - Returns 'true' if the it is determined that input parameter, 'pathFileStr', represents a directory path, file name and optionally, a file extension.

If 'pathFileStr' is judged to be a directory path and file name, by definition it cannot be solely a directory path.

------------------------------------------------------------------------

Input Parameter:

pathFileStr            string - The string to be analyzed.

Return Values:

pathFileType PathFileTypeCode - Path File Type Code indicating whether the input parameter 'pathFileStr'
                                is a Path, a Path and File, a File or "Indeterminate". "Indeterminate"
                                signals that the nature of 'pathFileStr' cannot be classified as either
                                a Path or a Path and File or a File.

                                --------------------------------------------------------
                                PathFileTypeCodes
                                   0 = None
                                   1 = Path
                                   2 = PathFile
                                   3 = File (with no path)
                                   4 = Volume
                                   5 = Indeterminate - Cannot determine whether string is a Path,
                                       Path & File or File

err                     error - If an error is encountered during processing, it is returned here. If no error
                                occurs, 'err' is set to 'nil'. An error will be triggered if the input parameter
                                'pathFileStr' cannot no alpa numeric characters.

func (FileHelper) IsPathString

func (fh FileHelper) IsPathString(
	pathStr string) (isPathStr bool, cannotDetermine bool, testPathStr string, err error)

IsPathString - Attempts to determine whether a string is a path string designating a directory (and not a path file name file extension string).

If the path exists on disk, this method will examine the associated file information and render a definitive and accurate determination as to whether the path string represents a directory.

------------------------------------------------------------------------

Input Parameter:

pathStr string       - The path string to be analyzed.

------------------------------------------------------------------------

Return Values:

isPathStr       bool - If the input parameter, 'pathStr'
                       is determined to be a directory
                       path, this return value is set to
                       true. Here, a 'directory path' is defined
                       as a true directory and the path does NOT
                       contain a file name.

cannotDetermine bool - If the method cannot determine whether
                       the input parameter 'pathStr' is or
                       is NOT a valid directory path, this
                       this return value will be set to 'true'.
                       The 'cannotDetermine=true' condition occurs
                       with path names like 'D:\DirA\common'. The
                       cannot determine whether 'common' is a file
                       name or a directory name.

testPathStr   string - Input parameter 'pathStr' is subjected to cleaning routines
                       designed to exclude extraneous characters from the analysis.
                       'testPathFileStr' is the actual string on which the analysis was
                       performed.

err            error - If an error occurs this return value will
                       be populated. If no errors occur, this return
                       value is set to nil.

func (FileHelper) JoinPaths

func (fh FileHelper) JoinPaths(p1 string, p2 string) string

JoinPaths - correctly joins 2-paths. Like the method JoinPathsAdjustSeparators() this method also converts path separators to the correct path separators for the current operating system.

func (FileHelper) JoinPathsAdjustSeparators

func (fh FileHelper) JoinPathsAdjustSeparators(
	p1 string, p2 string) string

JoinPathsAdjustSeparators - Joins two path strings and standardizes the path separators according to the current operating system.

func (FileHelper) MakeAbsolutePath

func (fh FileHelper) MakeAbsolutePath(relPath string) (string, error)

MakeAbsolutePath - Supply a relative path or any path string and resolve that path to an Absolute path. Note: Clean() is called on result by fp.Abs().

func (FileHelper) MakeDir

func (fh FileHelper) MakeDir(dirPath string) error

MakeDir - Creates a single directory. The method returns an error type. If the operation succeeds, the error value is 'nil'. If the operation fails the error value is populated with an appropriate error message.

This method will fail if the parent directory does not exist.

The permission bits 'drwxrwxrwx' are used for directory creation. If path is already a directory, this method does nothing and returns an error value of 'nil'.

Note that this method calls FileHelper.MakeDirPerm().

func (FileHelper) MakeDirAll

func (fh FileHelper) MakeDirAll(dirPath string) error

MakeDirAll - creates a directory named path, along with any necessary parent directories. In other words, all directories in the path are created.

The permission bits 'drwxrwxrwx' are used for all directories that the method creates.

If path is a directory which already exists, this method does nothing and returns and error value of 'nil'.

Note that this method calls FileHelper.MakeDirAllPerm()

func (FileHelper) MakeDirAllPerm

func (fh FileHelper) MakeDirAllPerm(dirPath string, permission FilePermissionConfig) error

MakeDirAllPerm - Creates a directory path along with any necessary parent paths.

If the target directory path already exists, this method does nothing and returns.

The input parameter 'permission' is of type 'FilePermissionConfig'. See method the documentation for method 'FilePermissionConfig.New()' for an explanation of permission codes.

If you wish to grant total access to a directory, consider setting permission code as follows:

FilePermissionConfig{}.New("drwxrwxrwx")

If the parent directories in parameter 'dirPath' do not yet exist, this method will create them.

func (FileHelper) MakeDirPerm

func (fh FileHelper) MakeDirPerm(dirPath string, permission FilePermissionConfig) error

MakeDirPerm - Creates a single directory using the permission codes passed by input parameter 'permission'.

This method will fail if the parent directory does not exist. To create all parent directories in the path use method 'FileHelper.MakeDirAllPerm()'.

The input parameter 'permission' is of type 'FilePermissionConfig'. See method the documentation for method 'FilePermissionConfig.New()' for an explanation of permission codes.

If you wish to grant total access to a directory, consider setting permission code as follows:

FilePermissionConfig{}.New("drwxrwxrwx")

An error will be triggered if the 'dirPath' input parameter represents an invalid path or if parent directories in the path do not exist.

func (FileHelper) MoveFile

func (fh FileHelper) MoveFile(src, dst string) error

MoveFile - Copies file from source to destination and, if successful, then deletes the original source file.

The copy procedure will carried out using the the 'Copy By Io' technique. See FileHelper.CopyFileByIo().

The 'move' operation will create the destination file, but it will NOT create the destination directory. If the destination directory does NOT exist, an error will be returned.

If this copy operation fails, the method will return an error and it will NOT delete the source file.

If an error is encountered during this procedure it will be returned by means of the return parameter 'err'.

func (FileHelper) OpenDirectory

func (fh FileHelper) OpenDirectory(
	directoryPath string,
	createDir bool) (*os.File, error)

OpenDirectory - Opens a directory and returns the associated 'os.File' pointer. This method will open a directory designated by input parameter, 'directoryPath'.

The input parameter 'createDir' determines the action taken if 'directoryPath' does not exist. If 'createDir' is set to 'true' and 'directoryPath' does not currently exist, this method will attempt to create 'directoryPath'. Directories created in this manner are configured with Open Type of 'Read-Write' and a Permission code of 'drwxrwxrwx'.

Alternatively, if 'createDir' is set to 'false' and 'directoryPath' does NOT exist, an error will be returned.

Regardless of whether the target directory path already exists or is created by this method, the returned os.File pointer is opened with the 'Read-Only' attribute (O_RDONLY) and a permission code of zero ("----------").

Note: The caller is responsible for calling "Close()" on the returned os.File pointer.

--------------------------------------------------------------------------------------------------------

Input Parameters:

directoryPath                  string - A string containing the path name of the directory
                                        which will be opened.

createDir                        bool - Determines what action will be taken if 'directoryPath'
                                        does NOT exist. If 'createDir' is set to 'true' and
                                        'directoryPath' does NOT exist, this method will attempt
                                        to create 'directoryPath'. Alternatively, if 'createDir'
                                        is set to false and 'directoryPath' does NOT exist, this
                                        method will terminate and an error will be returned.

                                        Directories created in this manner will have an Open Type
                                        of 'Read-Write' and a Permission code of 'drwxrwxrwx'. This
                                        differs from the Open Type and permission mode represented
                                        by the returned os.File pointer.

--------------------------------------------------------------------------------------------------------

Return Values:

*os.File        - If successful, this method returns an os.File pointer
                  to the directory designated by input parameter 'directoryPath'.

                  If successful, the returned os.File pointer is opened with the
                  'Read-Only' attribute (O_RDONLY) and a permission code of zero
                  ("----------").

                  If this method fails, the *os.File return value is 'nil'.

                  Note: The caller is responsible for calling "Close()" on this
                  os.File pointer.

error           - If the method completes successfully, the error return value
                  is 'nil'. If the method fails, the error type returned is
                  populated with an appropriate error message.

func (FileHelper) OpenFile

func (fh FileHelper) OpenFile(
	pathFileName string,
	fileOpenCfg FileOpenConfig,
	filePermissionCfg FilePermissionConfig) (filePtr *os.File, err error)

OpenFile - wrapper for os.OpenFile. This method may be used to open or create files depending on the File Open and File Permission parameters.

If successful, this method will return a pointer to the os.File object associated with the file designated for opening.

The calling routine is responsible for calling "Close()" on this os.File pointer.

------------------------------------------------------------------------

Input Parameters:

pathFileName                   string - A string containing the path and file name
                                        of the file which will be opened. If a parent
                                        path component does NOT exist, this method will
                                        trigger an error.

fileOpenCfg            FileOpenConfig - This parameter encapsulates the File Open parameters
                                        which will be used to open subject file. For an
                                        explanation of File Open parameters, see method
                                        FileOpenConfig.New().

filePermissionCfg FilePermissionConfig - This parameter encapsulates the File Permission

parameters which will be used to open the subject
file. For an explanation of File Permission parameters,
see method FilePermissionConfig.New().

------------------------------------------------------------------------

Return Values:

*os.File        - If successful, this method returns an os.File pointer
                  to the file designated by input parameter 'pathFileName'.
                  This file pointer can subsequently be used for reading
                  content from the subject file. It may NOT be used for
                  writing content to the subject file.

                  If this method fails, the *os.File return value is 'nil'.

                  Note: The caller is responsible for calling "Close()" on this
                  os.File pointer.

error           - If the method completes successfully, this return value
                  is 'nil'. If the method fails, the error type returned
                  is populated with an appropriate error message.

func (FileHelper) OpenFileReadOnly

func (fh FileHelper) OpenFileReadOnly(pathFileName string) (filePtr *os.File, err error)

OpenFileReadOnly - Opens the designated path file name for reading only.

If successful, this method returns a pointer of type *os.File which can only be used for reading reading content from the subject file. This file pointer is configured for 'Read-Only' operations. You may not write to the subject file using this pointer.

If the designated file ('pathFileName') does NOT exist, an error will be triggered.

------------------------------------------------------------------------

Input Parameter:

pathFileName        string - A string containing the path and file name
                             of the file which will be opened in the
                             'Read-Only' mode. If the path or file does
                             NOT exist, this method will trigger an error.

------------------------------------------------------------------------

Return Values:

*os.File        - If successful, this method returns an os.File pointer
                  to the file designated by input parameter 'pathFileName'.
                  This file pointer can subsequently be used for reading
                  content from the subject file. It may NOT be used for
                  writing content to the subject file.

                  If this method fails, the *os.File return value is 'nil'.

                  Note: The caller is responsible for calling "Close()" on this
                  os.File pointer.

error           - If the method completes successfully, this return value
                  is 'nil'. If the method fails, the error type returned
                  is populated with an appropriate error message.

func (FileHelper) OpenFileReadWrite

func (fh FileHelper) OpenFileReadWrite(
	pathFileName string,
	truncateFile bool) (*os.File, error)

OpenFileReadWrite - Opens the file designated by input parameter 'fileName' for 'Writing'. The actual permission code used to open the file is 'Read/Write'.

If the method is successful, a pointer to the opened file is returned along with an error value of 'nil'.

If the file does not exist, this method will attempt to create it.

If the file path does not exist, an error will be triggered.

If the method completes successfully, the caller is responsible for call "Close()" on the returned os.File pointer.

------------------------------------------------------------------------

Input Parameter:

pathFileName        string - A string containing the path and file name
                             of the file which will be opened in the
                             'Read/Write' mode. If the file does NOT
                             exist, this method will attempt to create
                             it. However, if the path component of
                             'pathFileName' does not exist, an error
                              will be returned.

truncateFile          bool - If set to 'true' and the target file will
                             be truncated to zero bytes in length before
                             it is opened.

                             If set to 'false', the target file will be
                             be opened in the 'Append' mode and any bytes
                             written to the file will be appended to the
                             end of the file. Under this scenario, the
                             original file contents are preserved and newly
                             written bytes are added to the end of the file.

                             If the file designated by input parameter 'pathFileName'
                             does not exist, this parameter ('truncateFile') is
                             ignored and the new created file is initialized
                             containing zero bytes.

------------------------------------------------------------------------

Return Values:

*os.File        - If successful, this method returns an os.File pointer
                  to the file opened for 'Read/Write' operations. This
                  file pointer can be used subsequently for writing
                  content to, or reading content from, the subject file.

                  If this method fails, this return value is 'nil'.

                  Note: The caller is responsible for calling "Close()" on this
                  os.File pointer.

error           - If the method completes successfully, this return value
                  is 'nil'. If the method fails, the error type returned
                  is populated with an appropriate error message.

func (FileHelper) OpenFileWriteOnly

func (fh FileHelper) OpenFileWriteOnly(
	pathFileName string,
	truncateFile bool) (*os.File, error)

OpenFileWriteOnly - Opens a file for 'Write-Only' operations. Input parameter 'pathFileName' specifies the the path and file name of the file which will be opened.

If the path component of 'pathFileName' does not exist, an error will be returned.

If the designated file does not exist, this method will attempt to create the file.

If the method completes successfully, the caller is responsible for calling 'Close()' on the returned os.File pointer.

------------------------------------------------------------------------

Input Parameter:

pathFileName        string - A string containing the path and file name
                             of the file which will be opened in the
                             'Write Only' mode. If the file does NOT
                             exist, this method will attempt to create
                             it. However, if the path component of
                             'pathFileName' does not exist, an error
                              will be returned.

truncateFile          bool - If set to 'true' and the target file will
                             be truncated to zero bytes in length before
                             it is opened.

                             If set to 'false', the target file will be
                             be opened in the 'Append' mode and any bytes
                             written to the file will be appended to the
                             end of the file. Under this scenario, the
                             original file contents are preserved and newly
                             written bytes are added to the end of the file.

                             If the file designated by input parameter 'pathFileName'
                             does not exist, this parameter ('truncateFile') is
                             ignored and the newly created file is initialized
                             with zero bytes of content.

------------------------------------------------------------------------

Return Values:

*os.File        - If successful, this method returns an os.File pointer
                  to the file opened for 'Write Only' operations. This
                  file pointer can be used for writing content to the
                  subject file.

                  If this method fails, this return value is 'nil'.

                  Note: The caller is responsible for calling "Close()" on this
                  os.File pointer.

error           - If the method completes successfully, this return value
                  is 'nil'. If the method fails, the error type returned
                  is populated with an appropriate error message.

func (FileHelper) RemovePathSeparatorFromEndOfPathString

func (fh FileHelper) RemovePathSeparatorFromEndOfPathString(pathStr string) string

RemovePathSeparatorFromEndOfPathString - Remove Trailing path Separator from a path string - if said trailing path Separator exists.

func (*FileHelper) SearchFileModeMatch

func (fh *FileHelper) SearchFileModeMatch(
	info os.FileInfo,
	fileSelectCriteria FileSelectionCriteria) (isFileModeSet, isFileModeMatch bool, err error)

SearchFileModeMatch - This method determines whether the file mode of the file described by input parameter, 'info', is match for the File Selection Criteria 'fileSelectCriteria.SelectByFileMode'. If the file's FileMode matches the 'fileSelectCriteria.SelectByFileMode' value, the return value, 'isFileModeMatch' is set to 'true'.

If 'fileSelectCriteria.SelectByFileMode' is NOT initialized to a valid File Mode value, the return value 'isFileModeSet' is set to 'false' signaling the File Mode File Selection Criterion is NOT active.

Note: Input parameter 'info' is of type os.FileInfo. You can substitute a type 'FileInfoPlus' object for the 'info' parameter because 'FileInfoPlus' implements the 'os.FileInfo' interface.

func (*FileHelper) SearchFileNewerThan

func (fh *FileHelper) SearchFileNewerThan(
	info os.FileInfo,
	fileSelectCriteria FileSelectionCriteria) (isFileNewerThanSet, isFileNewerThanMatch bool, err error)

SearchFileNewerThan - This method is called to determine whether the file described by the input parameter 'info' is a 'match' for the File Selection Criteria, 'fileSelectCriteria.FilesNewerThan'. If the file modification date time occurs after the 'fileSelectCriteria.FilesNewerThan' date time, the return value 'isFileNewerThanMatch' is set to 'true'.

If 'fileSelectCriteria.FilesNewerThan' is set to time.Time zero ( the default or zero value for this type), the return value 'isFileNewerThanSet' is set to 'false' signaling that this search criterion is NOT active.

Note: Input parameter 'info' is of type os.FileInfo. You can substitute a type 'FileInfoPlus' object for the 'info' parameter because 'FileInfoPlus' implements the 'os.FileInfo' interface.

func (*FileHelper) SearchFileOlderThan

func (fh *FileHelper) SearchFileOlderThan(
	info os.FileInfo,
	fileSelectCriteria FileSelectionCriteria) (isFileOlderThanSet,
	isFileOlderThanMatch bool,
	err error)

SearchFileOlderThan - This method is called to determine whether the file described by the input parameter 'info' is a 'match' for the File Selection Criteria, 'fileSelectCriteria.FilesOlderThan'. If the file modification date time occurs before the 'fileSelectCriteria.FilesOlderThan' date time, the return value 'isFileOlderThanMatch' is set to 'true'.

If 'fileSelectCriteria.FilesOlderThan' is set to time.Time zero ( the default or zero value for this type), the return value 'isFileOlderThanSet' is set to 'false' signaling that this search criterion is NOT active.

Note: Input parameter 'info' is of type os.FileInfo. You can substitute a type 'FileInfoPlus' object for the 'info' parameter because 'FileInfoPlus' implements the 'os.FileInfo' interface.

func (*FileHelper) SearchFilePatternMatch

func (fh *FileHelper) SearchFilePatternMatch(
	info os.FileInfo,
	fileSelectCriteria FileSelectionCriteria) (isPatternSet, isPatternMatch bool, err error)

SearchFilePatternMatch - used to determine whether a file described by the 'info' parameter meets the specified File Selection Criteria and is judged to be a match for the fileSelectCriteria FileNamePattern. 'fileSelectCriteria.FileNamePatterns' consists of a string array. If the pattern signified by any element in the string array is a 'match', the return value 'isPatternMatch' is set to true.

If the 'fileSelectCriteria.FileNamePatterns' array is empty or if it contains only empty strings, the return value isPatternSet is set to 'false' signaling that the pattern file search selection criterion is NOT active.

Note: Input parameter 'info' is of type os.FileInfo. You can substitute a type 'FileInfoPlus' object for the 'info' parameter because 'FileInfoPlus' implements the 'os.FileInfo' interface.

func (FileHelper) StripLeadingDotSeparatorChars

func (fh FileHelper) StripLeadingDotSeparatorChars(pathName string) (string, int)

StripLeadingDotSeparatorChars - Strips or deletes the following characters from the front of path or directory names.

Leading Characters To Be Removed:

" " (Space)
PathSeparator
"."
".."
"." + PathSeparator
".." + PathSeparator

func (FileHelper) SwapBasePath

func (fh FileHelper) SwapBasePath(
	oldBasePath,
	newBasePath,
	targetPath string) (string, error)

SwapBasePath - Searches the 'targetPath' string for the existence of 'oldBasePath'. If 'oldBasePath' is found, it is replaced with 'newBasePath'.

If 'oldBasePath' is not found in 'targetPath' an error is returned.

Likewise, if 'oldBasePath' is not located at the beginning of 'targetPath', an error will be returned.

type FileInfoPlus

type FileInfoPlus struct {

	// CreateTimeStamp - Not part of FileInfo interface.
	// Date time at which this instance of Type 'FileInfoPlus' was initialized
	CreateTimeStamp time.Time
	// contains filtered or unexported fields
}

FileInfoPlus - Conforms to the os.FileInfo interface. This structure will store os.FileInfo information plus additional information related to a file or directory.

func (*FileInfoPlus) CopyOut

func (fip *FileInfoPlus) CopyOut() FileInfoPlus

CopyOut - Creates a deep copy of the current FileInfoPlus instance and returns it.

This method is NOT part of the FileInfo interface.

func (*FileInfoPlus) DirPath

func (fip *FileInfoPlus) DirPath() string

DirPath - Returns the directory path. This field, FileInfoPlus.dirPath, is not part of the standard FileInfo interface.

This method is NOT part of the FileInfo interface.

func (*FileInfoPlus) Empty

func (fip *FileInfoPlus) Empty()

Empty - Sets the internal data fields of the current FileInfoPlus instances to their zero or nil value.

This method is NOT part of the FileInfo interface.

func (*FileInfoPlus) Equal

func (fip *FileInfoPlus) Equal(fip2 *FileInfoPlus) bool

Equal - Compares two FileInfoPlus objects to determine if they are equal.

This method is NOT part of the FileInfo interface.

func (*FileInfoPlus) GetOriginalFileInfo

func (fip *FileInfoPlus) GetOriginalFileInfo() os.FileInfo

GetOriginalFileInfo - If the FileInfoPlus instance was initialized with an os.FileInfo value, this method will return that original os.FileInfo value. This is useful for passing parameters to some low level go routines such as os.SameFile().

This method is NOT part of the FileInfo interface.

func (FileInfoPlus) IsDir

func (fip FileInfoPlus) IsDir() bool

IsDir - 'true' = this is a directory, not a file.

abbreviation for Mode().IsDir()

func (*FileInfoPlus) IsDirectoryPathInitialized

func (fip *FileInfoPlus) IsDirectoryPathInitialized() bool

IsDirectoryPathInitialized - Returns a boolean value signaling whether the directory path has been initialized for this instance of the FileInfoPlus instance. FYI, the fields FileInfoPlus.isDirPathInitialized and FileInfoPlus.dirPath do NOT exist in a standard os.FileInfo object.

A FileInfoPlus directory path is properly initialized only if one of the following two methods is called:

1. FileInfoPlus.NewFromPathFileInfo() 2. FileInfoPlus.SetDirectoryPath

This method is NOT part of the FileInfo interface.

func (*FileInfoPlus) IsFileInfoInitialized

func (fip *FileInfoPlus) IsFileInfoInitialized() bool

IsFileInfoInitialized - Returns a boolean value signaling whether this instance of FileInfoPlus has been initialized.

A FileInfoPlus instance is properly initialized only if one of the following three methods is called:

1. FileInfoPlus.NewFromFileInfo() 2. FileInfoPlus.NewFromPathFileInfo() 3. FileInfoPlus.SetIsFInfoInitialized()

This method is NOT part of the FileInfo interface.

func (FileInfoPlus) ModTime

func (fip FileInfoPlus) ModTime() time.Time

ModTime - file modification time

func (FileInfoPlus) Mode

func (fip FileInfoPlus) Mode() os.FileMode

Mode - file mode bits. See os.FileMode A FileMode represents a file's mode and permission bits. The bits have the same definition on all systems, so that information about files can be moved from one system to another as a portable. Not all bits apply to all systems. The only required bit is ModeDir for directories.

type FileMode uint32

The defined file mode bits are the most significant bits of the FileMode. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added. const (

 // The single letters are the abbreviations
 // used by the String method's formatting.
	ModeDir        FileMode = 1 << (32 - 1 - iota) // d: is a directory
	ModeAppend                                     // a: append-only
	ModeExclusive                                  // l: exclusive use
	ModeTemporary                                  // T: temporary file; Plan 9 only
	ModeSymlink                                    // L: symbolic link
	ModeDevice                                     // D: device file
	ModeNamedPipe                                  // p: named pipe (FIFO)
	ModeSocket                                     // S: Unix domain socket
	ModeSetuid                                     // u: setuid
	ModeSetgid                                     // g: setgid
	ModeCharDevice                                 // c: Unix character device, when ModeDevice is set
	ModeSticky                                     // t: sticky

	// Mask for the type bits. For regular files, none will be set.
	ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice

	ModePerm FileMode = 0777 // Unix permission bits

)

func (FileInfoPlus) Name

func (fip FileInfoPlus) Name() string

Name - base name of the file.

Example:
            Complete File Name: "newerFileForTest_01.txt"
  Base Name returned by Name(): "newerFileForTest_01.txt"

func (FileInfoPlus) NewFromDirMgrFileInfo

func (fip FileInfoPlus) NewFromDirMgrFileInfo(
	dMgr DirMgr,
	info os.FileInfo) (FileInfoPlus, error)

NewFromDirMgrFileInfo - Creates and returns a new FileInfoPlus object populated with a Directory Manager (DirMgr) and File Info data (os.FileInfo) received from the input parameters 'dMgr' and 'info'.

This method is NOT part of the FileInfo interface.

------------------------------------------------------------------------

Example Usage:

fip, err := FileInfoPlus{}.NewFromDirMgrFileInfo(dMgr, info)
fip is now configured as a newly populated FileInfoPlus instance.

func (FileInfoPlus) NewFromFileInfo

func (fip FileInfoPlus) NewFromFileInfo(info os.FileInfo) FileInfoPlus

NewFromFileInfo - Creates and returns a new FileInfoPlus object populated with FileInfo data received from the input parameter. Notice that this version of the 'NewFromPathFileNameExtStr' method does NOT set the Directory path.

This method is NOT part of the FileInfo interface.

------------------------------------------------------------------------

Example Usage:

fip := FileInfoPlus{}.NewFromFileInfo(info)
fip is now a newly populated FileInfoPlus instance.

func (FileInfoPlus) NewFromPathFileInfo

func (fip FileInfoPlus) NewFromPathFileInfo(
	dirPath string,
	info os.FileInfo) (FileInfoPlus, error)

NewFromPathFileInfo - Creates and returns a new FileInfoPlus object populated with directory path and FileInfo data received from the input parameters.

This method is NOT part of the FileInfo interface.

------------------------------------------------------------------------

Example Usage:

fip, err := FileInfoPlus{}.NewFromPathFileInfo(dirPath, info)
fip is now a newly populated FileInfoPlus instance.

func (*FileInfoPlus) SetDirectoryPath

func (fip *FileInfoPlus) SetDirectoryPath(dirPath string) error

SetDirectoryPath - Sets the dirPath field. This field is not part of the standard FileInfo data structure.

func (*FileInfoPlus) SetIsDir

func (fip *FileInfoPlus) SetIsDir(isDir bool)

SetIsDir - Sets is directory field.

func (*FileInfoPlus) SetIsFInfoInitialized

func (fip *FileInfoPlus) SetIsFInfoInitialized(isInitialized bool)

SetIsFInfoInitialized - Sets the flag for 'Is File Info Initialized' If set to 'true' it means that all of the File Info fields have been initialized.

func (*FileInfoPlus) SetModTime

func (fip *FileInfoPlus) SetModTime(fileModTime time.Time)

SetModTime - Sets the file modification time

func (*FileInfoPlus) SetMode

func (fip *FileInfoPlus) SetMode(fileMode os.FileMode)

SetMode - Sets the file Mode

func (*FileInfoPlus) SetName

func (fip *FileInfoPlus) SetName(name string)

SetName - Sets the file name field.

func (*FileInfoPlus) SetSize

func (fip *FileInfoPlus) SetSize(fileSize int64)

SetSize - Sets the file size field

func (*FileInfoPlus) SetSysDataSrc

func (fip *FileInfoPlus) SetSysDataSrc(sysDataSrc interface{})

SetSysDataSrc - Sets the dataSrc field

func (FileInfoPlus) Size

func (fip FileInfoPlus) Size() int64

Size - file length in bytes for regular files; system-dependent for others

func (FileInfoPlus) Sys

func (fip FileInfoPlus) Sys() interface{}

Sys - underlying data source (can return nil)

func (FileInfoPlus) SysAsString

func (fip FileInfoPlus) SysAsString() string

SysAsString - underlying data source. If Sys is 'nil', this method will return an empty string.

type FileMgr

type FileMgr struct {
	// contains filtered or unexported fields
}

FileMgr - This type and its associated methods are used to manage organize and control disk files and file permissions.

Dependencies:

Type 'FileMgr' depends on type,'FileHelper' which is contained in source code file, 'filehelper.go' located in this directory.

To create an instance of type 'FileMgr' use one of the 'FileMgr.New' methods.

func (*FileMgr) ChangePermissionMode

func (fMgr *FileMgr) ChangePermissionMode(mode FilePermissionConfig) error

ChangePermissionMode - This method is a wrapper for os.Chmod().

ChangePermissionMode changes the permissions mode of the named file to mode. If the file is a symbolic link, it changes the mode of the link's target. If there is an error, it will be of type *PathError.

A different subset of the mode bits are used, depending on the operating system.

On Unix, the mode's permission bits, ModeSetuid, ModeSetgid, and ModeSticky are used.

On Windows, the mode must be non-zero but otherwise only the 0200 bit (owner writable) of mode is used; it controls whether the file's read-only attribute is set or cleared. attribute. The other bits are currently unused. Use mode 0400 for a read-only file and 0600 for a readable+writable file.

For Windows - Eligible permission codes are:

  'modeStr'      Octal
   Symbolic      Mode Value     File Access

   -r--r--r--     0444          File - read only
   -rw-rw-rw-     0666          File - read & write

On Plan 9, the mode's permission bits, ModeAppend, ModeExclusive, and ModeTemporary are used.

func (*FileMgr) CloseThisFile

func (fMgr *FileMgr) CloseThisFile() error

CloseThisFile - This method will call the Close() method on the current file pointer, FileMgr.filePtr.

In addition, if the file has been opened for Write or Read-Write, this method will automatically flush the file buffers.

func (*FileMgr) CopyFileMgrByIo

func (fMgr *FileMgr) CopyFileMgrByIo(fMgrDest *FileMgr) error

CopyFileMgrByIo - Copies the file represented by the current File Manager instance to a location specified by a destination input parameter 'fMgrDest', an instance of type FileMgr.

Note that if the destination directory does not exist, this method will attempt to create it.

One attempt will be made to copy the source file to the specified destination file using a technique known as 'io.Copy'. This technique will create a new destination file and copy the source file contents to that new destination file.

If this attempted 'io.Copy' operation fails, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang https://golang.org/pkg/io/#Copy

----------------------------------------------------------------------------------

Input Parameter:

fMgrDest  FileMgr - This File Manager type specifies the path and file name
                    of the destination file to which the source file identified
                    by the current File Manger will be copied.

                    If the directory path associated with 'fMgrDest' this
                    method will attempt to create it.

------------------------------------------------------------------------

Return Values:

error         - If this method completes successfully, the returned 'error'
                Type is set equal to 'nil'. If an error condition is encountered,
                this method will return an 'error' Type which contains an
                appropriate error message.

                Note: an error will be returned if the file identified by the
                current source File Manager instance does NOT exist.
func (fMgr *FileMgr) CopyFileMgrByIoByLink(fMgrDest *FileMgr) error

CopyFileMgrByIoByLink - Copies the file represented by the current File Manager instance to a location specified by a destination input parameter 'fMgrDest', an instance of type FileMgr.

Note that if the destination directory does not exist, this method will attempt to create it.

The copy operation will be carried out in two attempts. The first attempt will try to copy the source file to the destination by creating a new file and copying the source file contents to the new destination file using a technique known as 'io.Copy'.

If that first file copy operation fails, a second attempt will be made using a technique known as a 'Hard Link'. This technique will utilize a hard symbolic link to the existing source file in order to create the destination file.

If both attempted copy operations fail, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (*FileMgr) CopyFileMgrByIoWithBuffer

func (fMgr *FileMgr) CopyFileMgrByIoWithBuffer(
	fMgrDest *FileMgr, bufferSize int) error

CopyFileMgrByIo - Copies the file represented by the current File Manager instance to a location specified by a destination input parameter 'fMgrDest', another instance of type FileMgr.

Note that if the destination directory does not exist, this method will attempt to create it.

One attempt will be made to copy the source file to the specified destination file using a technique known as 'io.Copy'. This technique will create a new destination file and copies the source file contents to that new destination file.

If this attempted 'io.Copy' operation fails, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

Input Parameter:

fMgrDest  FileMgr - This File Manager type specifies the path and file name
                    of the destination file to which the source file identified
                    by the current File Manger will be copied.

                    If the directory path associated with 'fMgrDest' this
                    method will attempt to create it.

bufferSize    int - The size in bytes of a local buffer which will be used
                    to copy the source File Manager (fMgr) to the destination
                    File Manager (fMgrDest). This is useful when copying large
                    files.

                    If this value is set equal or less than zero, the default
                    default internal buffer will be used. Reference:
                      https://golang.org/pkg/io/#CopyBuffer

------------------------------------------------------------------------

Return Values:

error         - If this method completes successfully, the returned 'error'
                Type is set equal to 'nil'. If an error condition is encountered,
                this method will return an 'error' Type which contains an
                appropriate error message.

                Note: an error will be returned if the file identified by the
                current source File Manager instance does NOT exist.
func (fMgr *FileMgr) CopyFileMgrByLink(fMgrDest *FileMgr) error

CopyFileMgrByLink - Copies the file represented by the current File Manager instance to a location specified by a destination input parameter 'fMgrDest', an instance of type FileMgr.

Note that if the destination directory does not exist, this method will attempt to create it.

This method will make one attempt to copy the source file to the specified destination using a technique known as a 'Hard Link'. This technique will utilize a hard symbolic link to the existing source file in order to create the destination file.

By creating a 'linked' file, changing the contents of one file will be reflected in the second. The two linked files are 'mirrors' of each other.

Consider using FileMgr.CopyFileMgrByIo() if the 'mirror' feature causes problems.

If the 'Hard Link' copy operation fails, and error will be returned.

Reference:
 https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang
 https://golang.org/pkg/os/#Link

func (*FileMgr) CopyFileMgrByLinkByIo

func (fMgr *FileMgr) CopyFileMgrByLinkByIo(fMgrDest *FileMgr) error

CopyFileMgrByLinkByIo - Copies the file represented by the current File Manager instance to a location specified by a destination input parameter 'fMgrDest', an instance of type FileMgr.

Note that if the destination directory does not exist, this method will attempt to create it.

The copy operation will be carried out in two attempts. The first attempt will try to copy the source file to the destination using a technique known as a 'Hard Link'. This technique will utilize a hard symbolic link to the existing source file in order to create the destination file.

If the first copy attempt fails, this method will try to copy the file to the destination by creating a new file and copying the source file contents to that new destination file. This technique is known as 'io.Copy'.

If both attempted copy operations fail, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (*FileMgr) CopyFileMgrWithBuffer

func (fMgr *FileMgr) CopyFileMgrWithBuffer(
	fMgrDest *FileMgr,
	localCopyBuffer []byte) error

CopyFileMgrWithBuffer - Performs a Copy By IO operation which copies the file identified by the current File Manager to the file specified by the input parameter 'fMgrDest'. 'fMgrDest' is another instance of 'FileMgr'.

This method differs from a similar method, 'FileMgr.CopyFileMgrByIo()' in that the calling function must supply a local copy buffer of type []byte. The copy operation stages through the provided buffer (if one is required) rather than allocating a temporary internal buffer. This approach can be useful when copying a series of large files.

Internally, this method calls io.CopyBuffer().

Reference:
  https://golang.org/pkg/io/#CopyBuffer
  https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

----------------------------------------------------------------------------------

Input Parameter:

fMgrDest       FileMgr - An instance of FileMgr which identifies the destination
                         file to which the source file identified by the current
                         FileMgr will be copied.

localCopyBuffer []byte - A byte array which will be used as an internal buffer through
                         which to stage the copy operation. If this buffer is 'nil' or
                         if this is a zero length byte array, an error will be returned.

------------------------------------------------------------------------------------------

Return Value:

error - If this method completes successfully, the returned 'error'
        Type is set equal to 'nil'. If an error condition is encountered,
        this method will return an 'error' Type which contains an
        appropriate error message.

        Note: an error will be returned if the source file identified by
        the current FileMgr instance does NOT exist. Likewise, an error
        will also be triggered if input parameter 'localCopyBuffer' is
        'nil' or if it is a zero length byte array.

func (*FileMgr) CopyFileStrByIo

func (fMgr *FileMgr) CopyFileStrByIo(dstPathFileNameExt string) error

CopyFileStrByIo - Copies the file represented by the current File Manager instance to a location specified by a destination input parameter. The destination input parameter, 'dstPathFileNameExt' is a string containing the path, file name and file extension of the destination file.

Note that if the destination directory does not exist, this method will attempt to create it.

One attempt will be made to copy the source file to the specified destination using a technique known as 'Copy By IO'. This technique create a new destination file and copies the source file contents to that new destination file.

If this attempted 'io.Copy' operation fails, and error will be returned.

Reference:
 https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang
 https://golang.org/pkg/io/#Copy
func (fMgr *FileMgr) CopyFileStrByIoByLink(dstPathFileNameExt string) error

CopyFileStrByIoByLink - Copies the file represented by the current File Manager instance to a location specified by a destination input parameter. The destination input parameter, 'dstPathFileNameExt' is a string containing the path, file name and file extension of the destination file.

Note that if the destination directory does not exist, this method will attempt to create it.

The copy operation will be carried out in two attempts. The first attempt will try to copy the file to the destination by creating a new file and copying the source file contents to the new destination file. This technique is known as 'io.Copy'.

If that attempted file copy operation fails, a second attempt will be made using a technique known as a 'Hard Link'. This technique will utilize a hard symbolic link to the existing source file in order to create the destination file.

If both attempted copy operations fail, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (fMgr *FileMgr) CopyFileStrByLink(dstPathFileNameExt string) error

CopyFileStrByLink - Copies the file represented by the current File Manager instance to a location specified by a destination input parameter. The destination input parameter, 'dstPathFileNameExt' is a string containing the path, file name and file extension of the destination file.

Note that if the destination directory does not exist, this method will attempt to create it.

This method will make one attempt to copy the source file to the specified destination using a technique known as a 'Hard Link'. This technique will utilize a hard symbolic link to the existing source file in order to create the destination file.

If 'Hard Link' copy operation fails, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (*FileMgr) CopyFileStrByLinkByIo

func (fMgr *FileMgr) CopyFileStrByLinkByIo(dstPathFileNameExt string) error

CopyFileStrByLinkByIo - Copies the file represented by the current File Manager instance to a location specified by a destination input parameter. The destination input parameter, 'dstPathFileNameExt' is a string containing the path, file name and file extension of the destination file.

Note that if the destination directory does not exist, this method will attempt to create it.

The copy operation will be carried out in two attempts. The first attempt will try to copy the source file to the destination using a technique known as a 'Hard Link'. This technique will utilize a hard symbolic link to the existing source file in order to create the destination file.

If the first copy attempt fails, this method will try to copy the file to the destination by creating a new file and copying the source file contents to the new destination file. This technique is known as 'io.Copy'.

If both attempted copy operations fail, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (*FileMgr) CopyFileToDirByIo

func (fMgr *FileMgr) CopyFileToDirByIo(dir DirMgr) error

CopyFileToDirByIo - Copies the file identified by the current File Manager (FileMgr) instance to another directory specified by input parameter 'dir', an instance of type 'DirMgr'.

Note that if the destination directory does not exist, this method will attempt to create it.

One attempt will be made to copy the source file to the specified destination directory using a technique known as 'io.Copy'. This technique create a new destination file and copies the source file contents to that new destination file.

If this attempted 'io.Copy' operation fails, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (fMgr *FileMgr) CopyFileToDirByIoByLink(dir DirMgr) error

CopyFileToDirByIoByLink - Copies the file identified by the current File Manager (FileMgr) instance to another directory specified by input parameter 'dir', an instance of type 'DirMgr'.

Note that if the destination directory does not exist, this method will attempt to create it.

The copy operation will be carried out in two attempts. The first attempt will try to copy the file to the destination by creating a new file and copying the source file contents to the new destination file using a technique known as 'io.Copy' or 'Copy by IO'.

If that attempted file copy operation fails, a second attempt will be made using a technique known as a 'Hard Link'. This technique will utilize a hard symbolic link to the existing source file in order to create the destination file.

If both attempted copy operations fail, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (fMgr *FileMgr) CopyFileToDirByLink(dir DirMgr) error

CopyFileToDirByLink - Copies the file identified by the current File Manager (FileMgr) instance to another directory specified by input parameter 'dir', an instance of type 'DirMgr'.

Note that if the destination directory does not exist, this method will attempt to create it.

This method will make one attempt to copy the source file to the specified destination directory using a technique known as a 'Hard Link'. This technique will utilize a hard symbolic link to the existing source file in order to create the destination file.

If the 'Hard Link' copy operation fails, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (*FileMgr) CopyFileToDirByLinkByIo

func (fMgr *FileMgr) CopyFileToDirByLinkByIo(dir DirMgr) error

CopyFileToDirByLinkByIo - Copies the file identified by the current File Manager (FileMgr) instance to another directory specified by input parameter 'dir', an instance of type 'DirMgr'.

Note that if the destination directory does not exist, this method will attempt to create it.

The copy operation will be carried out in two attempts. The first attempt will try to copy the source file to the destination directory using a technique known as a 'Hard Link'. This technique will utilize a hard symbolic link to the existing source file in order to create the destination file.

If the first copy attempt fails, this method will try to copy the file to the destination directory by creating a new file and copying the source file contents to the new destination file. This technique is known as 'io.Copy'.

If both attempted copy operations fail, and error will be returned.

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

func (FileMgr) CopyFromStrings

func (fMgr FileMgr) CopyFromStrings(
	sourcePathFileNameExt,
	destPathFileNameExt string) (fMgrSrc, fMgrDest FileMgr, err error)

CopyFromStrings - Copies a source file to a destination file. The source and destination files are identified by two strings specifying path, file name, and file extensions. The copy operation employs the 'Copy By IO' technique (a.k.a. 'io.Copy').

Reference: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang https://golang.org/pkg/io/#Copy

----------------------------------------------------------------------------------

Input Parameter:

sourcePathFileNameExt string - A text string which identifies the path, file name

and file extension of the source file which will be
used in the copy operation.

destPathFileNameExt string - A text string which identifies the path, file name

and file extension of the destination file which will
be used in the copy operation.

------------------------------------------------------------------------------------------

Return Values:

srcFMgr  FileMgr - If successful, this method returns a File Manager instance which
                   identifies the source file used in the copy operation.

destFMgr FileMgr - If successful, this method returns a File Manager instance which
                   identifies the destination file used in the copy operation.

err        error - If this method completes successfully, the returned 'error'
                   Type is set equal to 'nil'. If an error condition is encountered,
                   this method will return an 'error' Type which contains an
                   appropriate error message.

                   Note: an error will be returned if the file identified by the
                   input parameter 'sourcePathFileNameExt' does NOT exist.

------------------------------------------------------------------------------------------

Usage:

srcFileMgr, destFileMgr, err := FileMgr{}.CopyFromStrings(
                                "../Dir1/srcFile",
                                "../Dir2/destFile")

func (*FileMgr) CopyIn

func (fMgr *FileMgr) CopyIn(fmgr2 *FileMgr)

CopyIn - Copies data from an incoming FileMgr object into the current FileMgr object.

Note: Internal file pointer will not be copied.

func (*FileMgr) CopyOut

func (fMgr *FileMgr) CopyOut() FileMgr

CopyOut - Duplicates the file information in the current FileMgr object and returns it as a new FileMgr object.

Note: Internal File Pointer will not be copied.

func (*FileMgr) CreateDir

func (fMgr *FileMgr) CreateDir() error

CreateDir - Creates the directory previously configured for this file manager instance.

func (*FileMgr) CreateDirAndFile

func (fMgr *FileMgr) CreateDirAndFile() error

CreateDirAndFile - Performs two operations:

If the home directory does not currently exist, this method
will first create the directory tree containing the file.

Next, the file will be created. If the file previously exists, it will be truncated.

Note that if this method successfully creates the file, a File Pointer (*File) will be stored in the FileMgr field fMgr.filePtr. Be sure to close the File Pointer when finished with it. See FileMgr.CloseThisFile().

func (*FileMgr) CreateThisFile

func (fMgr *FileMgr) CreateThisFile() error

CreateThisFile - Creates the File identified by FileMgr (FileMgr.absolutePathFileName).

If the directory in the path file name designation does not exist, this method will throw an error.

See Method CreateDirAndFile() which will create both the directory and the file as required.

Note that if the file is actually created, the returned file pointer (*File) is stored in the FileMgr field, fMgr.filePtr. Be sure to 'close' the File Pointer when finished with it. See FileMgr.CloseThisFile()

func (*FileMgr) DeleteThisFile

func (fMgr *FileMgr) DeleteThisFile() error

func (*FileMgr) DoesFileExist

func (fMgr *FileMgr) DoesFileExist() bool

DoesFileExist - returns 'true' if the subject FileMgr file does in fact exist. If the file does NOT exist, a boolean value of 'false' is returned.

This method uses os.Stat() to test for the existence of a file path. If a non-path error is returned by os.Stat(), it is ignored and the file path is classified as 'Does Not Exist'.

This is very similar to 'FileMgr.DoesThisFileExist()'. However, unlike this method, 'FileMgr.DoesThisFileExist()' will return a non-path error. This method only returns a boolean value signaling whether the file path exists.

If this method encounters a non-path error or if the current FileMgr instance is invalid, a boolean value of 'false' will be returned.

func (*FileMgr) DoesThisFileExist

func (fMgr *FileMgr) DoesThisFileExist() (fileDoesExist bool, nonPathError error)

DoesThisFileExist - Returns a boolean value designating whether the file specified by the current FileMgr.absolutePathFileName field exists.

func (*FileMgr) Empty

func (fMgr *FileMgr) Empty()

Empty - resets all data fields in the FileMgr structure to their uninitialized or zero state.

func (*FileMgr) Equal

func (fMgr *FileMgr) Equal(fmgr2 *FileMgr) bool

Equal - Compares a second FileHelper data structure to the current FileHelper data structure and returns a boolean value indicating whether they are equal in all respects.

func (*FileMgr) EqualAbsPaths

func (fMgr *FileMgr) EqualAbsPaths(fmgr2 *FileMgr) bool

EqualAbsPaths - Returns 'true' if both the current File Manager and the input File Manager ('fmgr2') have the same file paths.

In other words, this method answers the question, 'Do Both Files have the same directory?'.

The path comparisons are case insensitive. This means that both paths will be converted to lower case before making the comparison.

Also, the path comparison will be performed on the absolute paths associated with the two File Managers.

If the file paths are NOT equal, this method returns 'false.

NOTE: This method will NOT test the equality of file names and extensions. ONLY the file paths (directories) will be compared.

func (*FileMgr) EqualFileNameExt

func (fMgr *FileMgr) EqualFileNameExt(fmgr2 *FileMgr) bool

EqualFileNameExt - Returns 'true' if both the current File Manager and the input File Manager ('fmgr2') have the same file name and file extension.

The File Name and File Extension comparisons are case insensitive. This means that both file name and file extension will be converted to lower case before making the comparision.

Example: xray.txt is considered equal to XRAY.TXT

If the either the File Name or File Extension are NOT equal, this method will return 'false'.

NOTE: This method will NOT test the equality of the file paths or directories. ONLY the file name and file extension are tested for equaltiy.

func (*FileMgr) EqualPathFileNameExt

func (fMgr *FileMgr) EqualPathFileNameExt(fmgr2 *FileMgr) bool

EqualPathFileNameExt - Returns 'true' if both the current File Manager and the input File Manager ('fmgr2') have the same absolute path, file name and file extension.

The string comparisons are case insensitive. This means that the paths, file names and file extensions will all be converted to lower case before making the comparision.

Example: d:\dir1\xray.txt is considered equal to D:\DIR1\XRAY.TXT

If the path, file name or file extensions are NOT equal, this method will return 'false'.

func (*FileMgr) FlushBytesToDisk

func (fMgr *FileMgr) FlushBytesToDisk() error

FlushBytesToDisk - After Writing bytes to a file, use this method to commit the contents of the current file to stable storage.

func (*FileMgr) GetAbsolutePath

func (fMgr *FileMgr) GetAbsolutePath() string

GetAbsolutePath - Returns the absolute path for the current File Manager instance.

Note: The file name and file extension are NOT included. Only the absolute path is returned as a 'string'.

func (*FileMgr) GetAbsolutePathFileName

func (fMgr *FileMgr) GetAbsolutePathFileName() string

GetAbsolutePathFileName - Returns the absolute path, file name and file extension for the current File Manager instance.

The returned path/file name string may consist of both upper and lower case characters.

See the companion method GetAbsolutePathFileNameLc() which returns a path/file name string consisting entirely of lower case characters.

func (*FileMgr) GetAbsolutePathFileNameLc

func (fMgr *FileMgr) GetAbsolutePathFileNameLc() string

GetAbsolutePathFileNameLc - Returns the absolute path, file name and file extension for the current File Manager instance.

The returned path/file name string will consist entirely of lower case characters.

See companion method GetAbsolutePathFileName() which returns the same path/file name string with upper and lower case characters.

func (*FileMgr) GetBufioReader

func (fMgr *FileMgr) GetBufioReader() *bufio.Reader

GetBufioReader - Returns a pointer to the internal bufio.Reader, FileMgr.fileBufRdr. This pointer is initialized when the file is opened for Read or Read-Write operations.

Be advised that if the file identified by the current FileMgr instance has not been opened the returned pointer to 'fMgr.fileBufRdr' may be nil.

func (*FileMgr) GetBufioWriter

func (fMgr *FileMgr) GetBufioWriter() *bufio.Writer

GetBufioWriter - Returns a pointer to the internal bufio.Writer, 'FileMgr.fileBufWriter'. This pointer is initialized when the file is opened for Write or Read-Write operations.

Be advised that if the file identified by the current FileMgr instance has not been opened, the returned pointer to 'fMgr.fileBufWriter' may be nil.

func (*FileMgr) GetDirMgr

func (fMgr *FileMgr) GetDirMgr() DirMgr

GetDirMgr - returns a deep copy of the Directory Manager for this FileMgr instance.

func (*FileMgr) GetFileBytesWritten

func (fMgr *FileMgr) GetFileBytesWritten() uint64

GetFileBytesWritten - Returns the sum of private member variables, 'FileMgr.buffBytesWritten' + 'FileMgr.fileBytesWritten'.

These variables records the number of bytes written to the FileMgr's target file since it was opened with 'Write' or 'Read-Write' permissions.

func (*FileMgr) GetFileExt

func (fMgr *FileMgr) GetFileExt() string

GetFileExt() - returns a string containing the File Extension for this File Manager instance.

IMPORTANT: The returned file extension will contain the preceding dot separator.

Example:
        File Name Plus Extension: "newerFileForTest_01.txt"
         Returned File Extension: ".txt"

        File Name Plus Extension: "newerFileForTest_01"
         Returned File Extension: ""

func (*FileMgr) GetFileInfo

func (fMgr *FileMgr) GetFileInfo() (fInfo os.FileInfo, err error)

GetFileInfo - Wrapper function for os.Stat(). This method can be used to return FileInfo data on the specific file identified by FileMgr.absolutePathFileName.

An error will be triggered if the file path does NOT exist!

 type FileInfo interface {
	 Name() string       // base name of the file
	 Size() int64        // length in bytes for regular files; system-dependent for others
	 Mode() FileMode     // file mode bits
	 ModTime() time.Time // modification time
	 IsDir() bool        // abbreviation for Mode().IsDir()
	 Sys() interface{}   // underlying data source (can return nil)
 }

func (*FileMgr) GetFileInfoPlus

func (fMgr *FileMgr) GetFileInfoPlus() (fInfo FileInfoPlus, err error)

GetFileInfoPlus - Returns a FileInfoPlus instance containing os.FileInfo and other data on the current FileManager instance.

An error will be triggered if the file path does NOT exist!

func (*FileMgr) GetFileModTime

func (fMgr *FileMgr) GetFileModTime() (time.Time, error)

GetFileModTime - Returns the time of the last file modification as a type, 'time.Time'.

If the file does NOT exist, an error is returned.

func (*FileMgr) GetFileModTimeStr

func (fMgr *FileMgr) GetFileModTimeStr(timeFormat string) (string, error)

GetFileModTimeStr - Returns the time of the last file modification as a string. If the file does NOT exist, an error is returned.

----------------------------------------------------------------------------------

Input Parameters:

timeFormat  string - A format string used to format the last modification time for
                     the file identified by the current File Manager (FileMgr) instance.

                     If the string is empty ("") or if the time format is invalid, the
                     method will automatically format the time using the default format,
                     "2019-03-12 21:49:00:00".

------------------------------------------------------------------------

Return Values:

string        - The time at which the current file was last modified formatted
                as a string. The time format is determined by input parameter
                'timeFormat'. If 'timeFormat' is empty or if 'timeFormat' is an
                invalid format, the default format "2019-03-12 21:49:00:00" will
                be substituted.

error         - If this method completes successfully, the returned error Type is
                set equal to 'nil'. If an error condition is encountered, this
                method will return an error Type which contains an appropriate
                error message.

                Note: an error will be returned if the file identified by the current
                File Manager instance does NOT exist.

func (*FileMgr) GetFileName

func (fMgr *FileMgr) GetFileName() string

GetFileName - returns the file name for this File Manager.

Example:

        File Name Plus Extension: "newerFileForTest_01.txt"
              Returned File Name: "newerFileForTest_01"

        File Name Plus Extension: "newerFileForTest_01"
              Returned File Name: "newerFileForTest_01"

func (*FileMgr) GetFileNameExt

func (fMgr *FileMgr) GetFileNameExt() string

GetFileNameExt - Returns a string containing the combination of file name and file extension configured for this File Manager instance

 Example:

         File Name Plus Extension: "newerFileForTest_01.txt"
Returned File Name Plus Extension: "newerFileForTest_01.txt"

         File Name Plus Extension: "newerFileForTest_01"
Returned File Name Plus Extension: "newerFileForTest_01"

func (*FileMgr) GetFilePermissionConfig

func (fMgr *FileMgr) GetFilePermissionConfig() (fPerm FilePermissionConfig, err error)

GetFilePermissionConfig - Returns a FilePermissionConfig instance encapsulating all of the permission information associated with this file.

If the file does NOT exist, this method will return an error.

func (*FileMgr) GetFilePermissionTextCodes

func (fMgr *FileMgr) GetFilePermissionTextCodes() (string, error)

GetFilePermissionTextCodes - If the current file exists on disk, this method will return the File Permission Codes, otherwise known as the unix permission bits, in the form of a 10-character string.

If the file does NOT exist, this method will return an error.

Examples:

Permission
  Text        Octal            File Access
  Codes      Notation          Permission Descriptions

----------     0000             File - no permissions
-rwx------     0700             File - read, write, & execute only for owner
-rwxrwx---     0770             File - read, write, & execute for owner and group
-rwxrwxrwx     0777             File - read, write, & execute for owner, group and others
---x--x--x     0111             File - execute
--w--w--w-     0222             File - write only
--wx-wx-wx     0333             File - write & execute
-r--r--r--     0444             File - read only
-r-xr-xr-x     0555             File - read & execute
-rw-rw-rw-     0666             File - read & write
-rwxr-----     0740             File - Owner can read, write, & execute. Group can only read;
                                File - others have no permissions
drwxrwxrwx     20000000777      File - Directory - read, write, & execute for owner, group and others

func (*FileMgr) GetFilePtr

func (fMgr *FileMgr) GetFilePtr() *os.File

GetFilePtr - will return the internal *os.File pointer for this File Manager instance. Depending on circumstances, this pointer may be nil.

func (*FileMgr) GetFileSize

func (fMgr *FileMgr) GetFileSize() int64

GetFileSize() - Returns os.FileInfo.Size() length in bytes for regular files; system-dependent for others.

If the File Manager file does NOT exist, or if there is a file-path error, the value returned is -1.

func (*FileMgr) GetOriginalPathFileName

func (fMgr *FileMgr) GetOriginalPathFileName() string

GetOriginalPathFileName - Returns the path and file name used originally to configure this File Manager object.

Note: The original path and file name will be adjusted to reflect the path operators used in the operating system for the host computer.

func (*FileMgr) GetReaderBufferSize

func (fMgr *FileMgr) GetReaderBufferSize() int

GetReaderBufferSize() - Returns the size for the internal Bufio Reader's buffer. If the value is less than 1 it means that the buffer will be set to the default size at the next 'Read' Operation.

func (*FileMgr) GetWriterBufferSize

func (fMgr *FileMgr) GetWriterBufferSize() int

GetWriterBufferSize() - Returns the size for the internal Bufio Writers's buffer. If the value is less than 1 it means that the buffer will be set to the default size at the next 'Write' Operation.

func (*FileMgr) IsAbsolutePathFileNamePopulated

func (fMgr *FileMgr) IsAbsolutePathFileNamePopulated() bool

IsAbsolutePathFileNamePopulated - Returns a boolean value indicating whether absolute path and file name is initialized and populated.

func (*FileMgr) IsFileExtPopulated

func (fMgr *FileMgr) IsFileExtPopulated() bool

IsFileExtPopulated - Returns a boolean value indicating whether the File Extension for this File Manager instance is populated.

func (*FileMgr) IsFileMgrValid

func (fMgr *FileMgr) IsFileMgrValid(errorPrefixStr string) (err error)

IsFileMgrValid - Analyzes the current FileMgr object. If the current FileMgr object is INVALID, an error is returned.

If the current FileMgr is VALID, this method returns 'nil'

func (*FileMgr) IsFileNameExtPopulated

func (fMgr *FileMgr) IsFileNameExtPopulated() bool

IsFileNameExtPopulated - Returns a boolean value indicating whether both the File Name and Extension for this File Manager instance have been populated.

If either the File Name or the File Extension is blank (empty), this method returns false.

Both the File Name AND the File Extension must be populated before this method returns 'true'.

func (*FileMgr) IsFileNamePopulated

func (fMgr *FileMgr) IsFileNamePopulated() bool

IsFileNamePopulated - returns a boolean value indicating whether the file name for this File Manager object is populated.

func (*FileMgr) IsFilePointerOpen

func (fMgr *FileMgr) IsFilePointerOpen() bool

IsFilePointerOpen - Returns a boolean value indicating whether the File Pointer (*os.File) for this File Manager instance is open, or not.

func (*FileMgr) IsInitialized

func (fMgr *FileMgr) IsInitialized() bool

isInitialized - Returns a boolean indicating whether the FileMgr object is properly initialized.

func (*FileMgr) MoveFileToFileMgr

func (fMgr *FileMgr) MoveFileToFileMgr(destinationFMgr FileMgr) error

MoveFileToFileMgr - This method will move the file identified by the current FileMgr to a new path and file name specified by the input parameter 'destinationFMgr' which is of type 'FileMgr'.

IMPORTANT:

The file identified by the current FileMgr object will be DELETED!

The new file is defined by input parameter 'destinationFMgr'.

If the input parameter 'destinationFMgr' contains a directory path which currently does NOT exist, it will be created.

func (*FileMgr) MoveFileToFileStr

func (fMgr *FileMgr) MoveFileToFileStr(pathFileNameExt string) (FileMgr, error)

MoveFileToFileStr - This method will move the file identified by the current FileMgr to a new path and file name contained in the input parameter 'pathFileNameExt' which is of type string.

IMPORTANT:

The file identified by the current FileMgr object will be DELETED!

The new file is defined by input parameter 'pathFileNameExt'.

If the input parameter 'pathFileNameExt' contains a directory path which currently does NOT exist, it will be created.

func (*FileMgr) MoveFileToNewDir

func (fMgr *FileMgr) MoveFileToNewDir(dirPath string) (FileMgr, error)

MoveFileToNewDir - This method will move the current file identified by this FileMgr object to a new path designated by input parameter string, 'dirPath'.

IMPORTANT:

The current file identified by the current FileMgr object will be DELETED!

The new file located in the new directory will be returned in the return parameter 'newFMgr'.

If input parameter 'dirPth' contains a directory path which does not currently exist, it will be created.

func (*FileMgr) MoveFileToNewDirMgr

func (fMgr *FileMgr) MoveFileToNewDirMgr(dMgr DirMgr) (FileMgr, error)

MoveFileToNewDirMgr - This method will move the file identified by the current FileMgr to a new path contained in the input parameter 'dMgr'.

IMPORTANT:

The current file identified by the current FileMgr object will be DELETED!

The new file located in the new directory will be returned as a type 'FileMgr'.

If the input parameter 'dMgr' does not contain a path which currently exists, it will be created.

func (FileMgr) New

func (fMgr FileMgr) New(pathFileNameExt string) (FileMgr, error)

New - Creates a new File Manager ('FileMgr') instance. This method receives an input parameter of type string and parses out the path, file name and file extension.

The file data is returned in the data fields of the new FileMgr object.

This method is identical to method 'NewFromPathFileNameExtStr()'.

------------------------------------------------------------------------

Input Parameter:

pathFileNameExt string - Must consist of a valid path, file name
                         and file extension. The file need not exist.
                         Failure to provide a properly formatted path
                         path, file name will result in an error.

------------------------------------------------------------------------

Return Values:

FileMgr       - If the method completes successfully, a valid FileMgr instance
                is returned containing information on the file specified in the
                two input parameter 'pathFileNameExt'.

error         - If this method completes successfully, the returned error
                Type is set equal to 'nil'. If an error condition is encountered,
                this method will return an error Type which contains an appropriate
                error message.

------------------------------------------------------------------------

Usage:

fmgr := FileMgr{}.New("../common/fileName.ext")

func (FileMgr) NewFromDirMgrFileNameExt

func (fMgr FileMgr) NewFromDirMgrFileNameExt(
	dirMgr DirMgr,
	fileNameExt string) (FileMgr, error)

NewFromDirMgrFileNameExt - this method is designed to create a new File Manager (FileMgr) object from two input parameters.

Input parameter 'dirMgr' is a valid and correctly populated Directory Manager object containing the file path.

Input parameter 'fileNameExt' is a string containing the file name and the file extension.

'dirMgr' and 'fileNameExt' will be combined to create a new File Manager (FileMgr) with a properly configured path, file name and file extension.

----------------------------------------------------------------------------------

Input Parameters:

dirMgr      DirMgr - A valid and properly initialized Directory Manager (type: DirMgr).
                     This object contains the file path which will be combined with the
                     the second input parameter, 'fileNameExt' to create the new File
                     Manager (type: FileMgr)

fileNameExt string - A string containing the file name and file extension which will be
                     used to create the new File Manager (type: FileMgr).

------------------------------------------------------------------------

Return Values:

FileMgr       - If the method completes successfully, a valid FileMgr instance
                is returned containing information on the file specified in the
                two input parameters 'dirMgr' and 'fileNameExt'.

error         - If this method completes successfully, the returned error
                Type is set equal to 'nil'. If an error condition is encountered,
                this method will return an error Type which contains an appropriate
                error message.

------------------------------------------------------------------------

Usage:

dMgr, err := DirMgr{}.New("D:\\TestDir")

if err != nil {
 fmt.Printf("Error='%v' \n", err.Error())
 return
}

fileNameExt := "yourFile.txt"

fMgr, err := FileMgr{}.NewFromDirMgrFileNameExt(dMgr, fileNameExt)

func (FileMgr) NewFromDirStrFileNameStr

func (fMgr FileMgr) NewFromDirStrFileNameStr(
	dirStr,
	fileNameExtStr string) (FileMgr, error)

NewFromDirStrFileNameStr - Creates a new file manager object (FileMgr) from a directory string and a File Name and Extension string passed as input parameters.

----------------------------------------------------------------------------------

Input Parameters:

dirStr         string - A string containing the directory or file path which will be
                        combined with the second input parameter, 'fileNameExt' to
                        create the new File Manager (type: FileMgr).

fileNameExtStr string - A string containing the file name and file extension which will be
                        used to create the new File Manager (type: FileMgr).

------------------------------------------------------------------------

Return Values:

FileMgr       - If the method completes successfully, a valid FileMgr instance
                is returned containing information on the file specified in the
                two input parameters 'dirStr' and 'fileNameExtStr'.

error         - If this method completes successfully, the returned error
                Type is set equal to 'nil'. If an error condition is encountered,
                this method will return an error Type which contains an appropriate
                error message.

------------------------------------------------------------------------

Usage:

dirStr := "D:\\TestDir"

fileNameExtStr := "yourFile.txt"

fMgr, err := FileMgr{}.NewFromDirStrFileNameStr(dirStr, fileNameExtStr)

func (FileMgr) NewFromFileInfo

func (fMgr FileMgr) NewFromFileInfo(dirPathStr string, info os.FileInfo) (FileMgr, error)

NewFromFileInfo - Creates and returns a new FileMgr object based on input from a directory path string and an os.FileInfo object.

----------------------------------------------------------------------------------

Input Parameters:

 dirPathStr      string - The directory path. NOTE: This does NOT contain the
	                         file name.

 info       os.FileInfo - A valid and populated FileInfo structure containing the
                          file name.

------------------------------------------------------------------------

Return Values:

FileMgr       - If the method completes successfully, a valid FileMgr instance
                is returned containing information on the file specified in the
                input parameter 'info'.

error         - If this method completes successfully, the returned error
                Type is set equal to 'nil'. If an error condition is encountered,
                this method will return an error Type which encapsulates an
                appropriate error message.

func (FileMgr) NewFromPathFileNameExtStr

func (fMgr FileMgr) NewFromPathFileNameExtStr(pathFileNameExt string) (FileMgr, error)

NewFromPathFileNameExtStr - Creates a new File Manager ('FileMgr') instance. This method receives an input parameter of type string and parses out the path, file name and file extension.

The file data is returned in the data fields of the new FileMgr object.

This method is identical to method 'New()'.

------------------------------------------------------------------------

Input Parameter:

pathFileNameExt string - Must consist of a valid path, file name
                         and file extension. The file need not exist.
                         Failure to provide a properly formatted path
                         path and file name will result in an error.
                         The file extension is optional.

------------------------------------------------------------------------

Usage:

fmgr := FileMgr{}.NewFromPathFileNameExtStr("../somedirectory/fileName.ext")

func (*FileMgr) OpenThisFile

func (fMgr *FileMgr) OpenThisFile(fileAccessCtrl FileAccessControl) error

OpenThisFile - Opens the file identified by the current FileMgr object using the file open parameters and file permission parameters contained in the 'FileAccessControl' instance passed as 'fileAccessCtrl'.

Note: If the FileMgr directory path does not exist, this method will create that directory path.

func (*FileMgr) OpenThisFileReadOnly

func (fMgr *FileMgr) OpenThisFileReadOnly() error

OpenThisFileReadOnly - Opens the file identified by the current FileMgr object as a 'Read-Only' File. Subsequent operations may read from this file but may NOT write to this file.

As the method's name implies, the 'FileMgr.absolutePathFileName' will be opened for reading only.

If FileMgr.absolutePathFileName does not exist, an error will be returned.

If successful, the FileMode is set to "-r--r--r--" and the permission Mode is set to '0444'.

Note: If the 'FileMgr' directory path or file do not exist, this method will return an error.

func (*FileMgr) OpenThisFileReadWrite

func (fMgr *FileMgr) OpenThisFileReadWrite() error

OpenThisFileReadWrite - Opens the file identified by the current FileMgr object. If successful, this method will use FileMgr.absolutePathFileName to open an *os.File or File Pointer.

As the method's name implies, the 'FileMgr.absolutePathFileName' will be opened for reading and writing. If FileMgr.absolutePathFileName does not exist, it will be created. The FileMode is set to'-rw-rw-rw-' and the permission Mode= '0666'.

Note: If the 'FileMgr' directory path and file do not exist, this method will will create them.

func (*FileMgr) OpenThisFileWriteOnly

func (fMgr *FileMgr) OpenThisFileWriteOnly() error

OpenThisFileWriteOnly - Opens the current file for 'WriteOnly' operations. If successful, this method will use FileMgr.absolutePathFileName to open an *os.File or File Pointer.

As the method's name implies, the 'FileMgr.absolutePathFileName' will be opened for writing only. If FileMgr.absolutePathFileName does not exist, it will be created. The FileMode is set to "--w--w--w-" and the permission Mode is set to '0222'.

Note: If the 'FileMgr' directory path and file do not exist, this method will will create them.

func (*FileMgr) OpenThisFileWriteOnlyAppend

func (fMgr *FileMgr) OpenThisFileWriteOnlyAppend() error

OpenThisFileWriteOnlyAppend - Opens the current file for 'Write Only' with an 'Append' mode. All bytes written to the file will be written at the end of the current file and none of the file's original content will be overwritten.

Note: If the 'FileMgr' directory path and file do not exist, this method will will create both the path and file.

func (*FileMgr) OpenThisFileWriteOnlyTruncate

func (fMgr *FileMgr) OpenThisFileWriteOnlyTruncate() error

OpenThisFileWriteOnlyAppend - Opens the current file for 'Write Only' with an 'Truncate' mode. This means that if the file previously exists, all of the existing file content will be deleted before the 'write' operation will begin.

Note: If the 'FileMgr' directory path and file do not exist, this method will will create both the path and file.

func (*FileMgr) ReadAllFile

func (fMgr *FileMgr) ReadAllFile() (bytesRead []byte, err error)

ReadAllFile - Reads the file identified by the current FileMgr and returns the contents in a byte array.

If no errors are encountered the returned 'error' value is nil. This method does not return io.EOF as an error. This is is because it reads the entire file and therefor no End Of File flag is required.

func (*FileMgr) ReadFileBytes

func (fMgr *FileMgr) ReadFileBytes(byteBuff []byte) (bytesRead int, err error)

ReadFileBytes - Reads bytes from the file identified by the current FileMgr object. Bytes are stored in 'byteBuff', a byte array passed in as an input parameter.

If successful, the returned error value is 'nil' or io.EOF.

The returned value 'int' contains the number of bytes read from the current file.

At End of File (EOF), the byte count will be zero and err will be equal to 'io.EOF'.

func (*FileMgr) ReadFileLine

func (fMgr *FileMgr) ReadFileLine(delim byte) (bytesRead []byte, err error)

ReadFileLine - Effectively, this method reads a file one line at a time and returns the line as an array of bytes. The delimiter for lines read is specified by input parameter 'delim' of type byte.

This method uses the 'bufio' package.

If End Of File (EOF) is reached, this method returns the 'bytesRead' and an error which is equal to 'io.EOF'.

Note that the delimiter is returned as the last character in bytes read.

func (*FileMgr) ReadFileString

func (fMgr *FileMgr) ReadFileString(delim byte) (stringRead string, err error)

ReadFileString - Wrapper for bufio.ReadString. ReadFileString reads until the first occurrence of 'delim' in the input, returning a string containing the data up to and including the delimiter. If ReadFileString encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadFileString returns err != nil if and only if the returned data does not end in 'delim'.

func (*FileMgr) ResetFileInfo

func (fMgr *FileMgr) ResetFileInfo() error

ResetFileInfo - Acquires the current os.FileInfo data associated with the file identified by the current FileMgr instance.

An error will be triggered if the file path does NOT exist!

func (*FileMgr) SetFileInfo

func (fMgr *FileMgr) SetFileInfo(info os.FileInfo) error

SetFileInfo - Used to initialize the os.FileInfo structure maintained as part of the current FileMgr object.

Be careful: Failure of the input parameter to match the current FileMgr file name will trigger an error.

func (*FileMgr) SetFileMgrFromDirMgrFileName

func (fMgr *FileMgr) SetFileMgrFromDirMgrFileName(
	dMgr DirMgr,
	fileNameExt string) (isEmpty bool, err error)

SetFileMgrFromDirMgrFileName - Sets the data fields of the current FileMgr object based on a DirMgr object and a File Name string which are passed as input parameters.

------------------------------------------------------------------------

Return Values:

isEmpty       - This value is set to 'false' if, and only if, all internal
                values are set to valid legitimate values.

error         - If this method completes successfully, the returned error
                Type is set equal to 'nil'. If an error condition is encountered,
                this method will return an error Type which contains an appropriate
                error message.

func (*FileMgr) SetFileMgrFromPathFileName

func (fMgr *FileMgr) SetFileMgrFromPathFileName(
	pathFileNameExt string) (isEmpty bool, err error)

func (*FileMgr) SetReaderBufferSize

func (fMgr *FileMgr) SetReaderBufferSize(readBuffSize int)

SetReaderBufferSize - Sets the Read Buffer size in bytes. If the value is less than 1, the buffer size will be set to the system default size.

func (*FileMgr) SetWriterBufferSize

func (fMgr *FileMgr) SetWriterBufferSize(writeBuffSize int)

SetWriterBufferSize - Sets the Write Buffer size in bytes. If the value is less than 1, the buffer size will be set to the system default size.

func (*FileMgr) WriteBytesToFile

func (fMgr *FileMgr) WriteBytesToFile(
	bytes []byte) (numBytesWritten int, err error)

WriteBytesToFile a string to the File identified by FileMgr.absolutePathFileName. If the file is not open, this method will attempt to open it.

If the number of bytes written to the file is less than len(bytes), an error will be returned.

This method uses the 'bufio' package.

func (*FileMgr) WriteStrToFile

func (fMgr *FileMgr) WriteStrToFile(str string) (numBytesWritten int, err error)

WriteStrToFile - Writes a string to the File identified by FileMgr.absolutePathFileName. If the file is not open, this method will attempt to open it.

If the number of bytes written to the file is less than len(str), an error will be returned.

This method uses the 'bufio' package.

type FileMgrCollection

type FileMgrCollection struct {
	// contains filtered or unexported fields
}

FileMgrCollection - Manages a collection of FileMgr instances.

Dependencies: 'FileMgrCollection' depends on type, 'FileHelper' which is located in source code file 'filehelper.go'.

func (*FileMgrCollection) AddFileMgr

func (fMgrs *FileMgrCollection) AddFileMgr(fMgr FileMgr)

AddFileMgr - Adds a FileMgr object to the collection

func (*FileMgrCollection) AddFileMgrByDirFileNameExt

func (fMgrs *FileMgrCollection) AddFileMgrByDirFileNameExt(
	directory DirMgr,
	fileNameExt string) error

AddFileMgrByDirFileNameExt - Add a new File Manager using input parameters 'directory' and 'pathFileNameExt'.

func (*FileMgrCollection) AddFileMgrByDirStrFileNameStr

func (fMgrs *FileMgrCollection) AddFileMgrByDirStrFileNameStr(
	pathName string,
	fileNameExt string) error

AddFileMgrByDirStrFileNameStr - Adds a FileMgr object to the collection based on input parameter strings, 'pathName' and 'fileNameExt'.

func (*FileMgrCollection) AddFileMgrByFileInfo

func (fMgrs *FileMgrCollection) AddFileMgrByFileInfo(pathName string, info os.FileInfo) error

AddFileMgrByFileInfo - Adds a File Manager object to the collection based on input from a directory path string and a os.FileInfo object.

func (*FileMgrCollection) AddFileMgrByPathFileNameExt

func (fMgrs *FileMgrCollection) AddFileMgrByPathFileNameExt(
	pathFileNameExt string) error

AddFileMgrByPathFileNameExt - Add a new File Manager based on input parameter 'pathFileNameExt' which includes the full path name, file name and file extension.

func (*FileMgrCollection) AddFileMgrCollection

func (fMgrs *FileMgrCollection) AddFileMgrCollection(fMgrs2 *FileMgrCollection)

AddFileMgrCollection - Adds another collection of File Manager (FileMgr) objects to the current collection.

func (*FileMgrCollection) CopyFilesToDir

func (fMgrs *FileMgrCollection) CopyFilesToDir(targetDirectory DirMgr) error

CopyFilesToDir - Copies all the files in the File Manager Collection to the specified target directory.

func (*FileMgrCollection) CopyOut

func (fMgrs *FileMgrCollection) CopyOut() (FileMgrCollection, error)

CopyOut - Returns an FileMgrCollection which is an exact duplicate of the current FileMgrCollection

func (*FileMgrCollection) DeleteAtIndex

func (fMgrs *FileMgrCollection) DeleteAtIndex(idx int) error

DeleteAtIndex - Deletes a member File Manager from the collection at the index specified by input parameter 'idx'.

If successful, at the completion of this method, the File Manager Collection array will have a length which is one less than the starting array length.

func (*FileMgrCollection) FindFiles

func (fMgrs *FileMgrCollection) FindFiles(
	fileSelectionCriteria FileSelectionCriteria) (FileMgrCollection, error)

FindFiles - Searches the current FileMgrCollection and returns a new FileMgrCollection containing FileMgr objects which match the specified search criteria.

func (*FileMgrCollection) GetFileMgrArray

func (fMgrs *FileMgrCollection) GetFileMgrArray() []FileMgr

GetFileMgrArray - Returns the entire Directory Manager Array managed by this collection.

------------------------------------------------------------------------

Input Parameters:

None

------------------------------------------------------------------------

Return Values:

[]FileMgr      - The array of of FileMgr instances maintained by this
                 collection.

func (*FileMgrCollection) GetFileMgrAtIndex

func (fMgrs *FileMgrCollection) GetFileMgrAtIndex(idx int) (*FileMgr, error)

GetFileMgrAtIndex - If successful, this method returns a pointer to the FileMgr instance at the array index specified. The 'Peek' and 'Pop' methods below return FileMgr objects using a 'deep' copy and therefore offer better protection against data corruption.

func (*FileMgrCollection) GetNumOfFileMgrs

func (fMgrs *FileMgrCollection) GetNumOfFileMgrs() int

GetNumOfFileMgrs - returns the array length of the of the File Manager Collection, 'FileMgrCollection'. Effectively the returned integer is a count of the number of File Managers (FileMgr's) in the Collection.

func (*FileMgrCollection) GetNumOfFiles

func (fMgrs *FileMgrCollection) GetNumOfFiles() int

GetNumOfFiles - returns the array length of the of the File Manager Collection, 'FileMgrCollection'. Effectively the returned integer is a count of the number of files or File Managers (FileMgr's) in the Collection.

func (*FileMgrCollection) GetTotalFileBytes

func (fMgrs *FileMgrCollection) GetTotalFileBytes() uint64

GetTotalFileBytes - Returns the total number of file bytes represented by all files in the collection.

func (*FileMgrCollection) InsertFileMgrAtIndex

func (fMgrs *FileMgrCollection) InsertFileMgrAtIndex(fMgr FileMgr, index int) error

InsertFileMgrAtIndex - Inserts a new File Manager into the collection at array 'index'. The new File Manager is passed as input parameter 'fMgr'.

If input parameter 'index' is less than zero, an error will be returned. If 'index' exceeds the value of the last index in the collection, 'fMgr' will be added to the end of the collection at the next legal index.

func (FileMgrCollection) New

New - Creates and returns a new, empty and properly initialized File Manager Collection ('FileMgrCollection').

func (*FileMgrCollection) PeekFileMgrAtIndex

func (fMgrs *FileMgrCollection) PeekFileMgrAtIndex(idx int) (FileMgr, error)

PeekFileMgrAtIndex - Returns a deep copy of the File Manager ('FileMgr') object located at array index 'idx' in the File Manager Collection ('FileMgrCollection'). This is a 'Peek' method and therefore the original File Manager ('FileMgr') object is NOT deleted from the File Manager Collection ('FileMgrCollection') array.

At the completion of this method, the length of the File Manager Collection ('FileMgrCollection') array will remain unchanged.

func (*FileMgrCollection) PeekFirstFileMgr

func (fMgrs *FileMgrCollection) PeekFirstFileMgr() (FileMgr, error)

PeekFirstFileMgr - Returns a deep copy of the first File Manager ('FileMgr') object in the File Manager Collection ('FileMgrCollection'). This is a 'Peek' method and therefore the original File Manager ('FileMgr') object is NOT deleted from the File Manager Collection ('FileMgrCollection') array.

At the completion of this method, the length of the File Manager Collection ('FileMgrCollection') array will remain unchanged.

func (*FileMgrCollection) PeekLastFileMgr

func (fMgrs *FileMgrCollection) PeekLastFileMgr() (FileMgr, error)

PeekLastFileMgr - Returns a deep copy of the last File Manager ('FileMgr') object in the File Manager Collection ('FileMgrCollection').

This is a 'Peek' method and therefore the original File Manager ('FileMgr') object is NOT deleted from the File Manager Collection ('FileMgrCollection') array.

At the completion of this method, the length of the File Manager Collection ('FileMgrCollection') array will remain unchanged.

func (*FileMgrCollection) PopFileMgrAtIndex

func (fMgrs *FileMgrCollection) PopFileMgrAtIndex(idx int) (FileMgr, error)

PopFileMgrAtIndex - Returns a deep copy of the File Manager ('FileMgr') object located at index, 'idx', in the File Manager Collection ('FileMgrCollection') array.

As a 'Pop' method, the original File Manager ('FileMgr') object is deleted from the File Manager Collection ('FileMgrCollection') array.

Therefore, at the completion of this method, the File Manager Collection array has a length which is one less than the starting array length.

func (*FileMgrCollection) PopFirstFileMgr

func (fMgrs *FileMgrCollection) PopFirstFileMgr() (FileMgr, error)

PopFirstFileMgr - Returns a deep copy of the first File Manager ('FileMgr') object in the File Manager Collection array. As a 'Pop' method, the original File Manager ('FileMgr') object is deleted from the File Manager Collection ('FileMgrCollection') array.

Therefore at the completion of this method, the File Manager Collection array has a length which is one less than the starting array length.

func (*FileMgrCollection) PopLastFileMgr

func (fMgrs *FileMgrCollection) PopLastFileMgr() (FileMgr, error)

PopLastFileMgr - Returns a deep copy of the last File Manager ('FileMgr') object in the File Manager Collection array. As a 'Pop' method, the original File Manager ('FileMgr') object is deleted from the File Manager Collection ('FileMgrCollection') array.

Therefore at the completion of this method, the File Manager Collection array has a length which is one less than the starting array length.

func (*FileMgrCollection) SortByAbsPathFileName

func (fMgrs *FileMgrCollection) SortByAbsPathFileName(caseInsensitiveSort bool)

SortByAbsPathFileName - Sorts the collection array of file managers by absolute path, file name and file extension.

If the input parameter 'caseInsensitiveSort' is set to 'true', it means that upper and lower case characters are NOT significant in the sorting operation. The sort operation therefore uses lower case versions of absolute path, file name and file extension for comparison purposes.

On the other hand, if input parameter 'caseInsensitiveSort' is set to 'false', it means that upper and lower chase characters ARE significant to the sort operation.

type FileOpenConfig

type FileOpenConfig struct {
	// contains filtered or unexported fields
}

func (*FileOpenConfig) CopyIn

func (fOpenCfg *FileOpenConfig) CopyIn(fOpStat2 *FileOpenConfig)

CopyIn - Receives a FileOpenConfig instance and copies all the data fields to the current FileOpenConfig instance. When complete, both the incoming and current FileOpenConfig instances will be identical.

The type of copy operation performed is a 'deep copy'.

func (*FileOpenConfig) CopyOut

func (fOpenCfg *FileOpenConfig) CopyOut() FileOpenConfig

CopyOut - Creates and returns a deep copy of the current FileOpenConfig instance.

func (*FileOpenConfig) Empty

func (fOpenCfg *FileOpenConfig) Empty()

Empty - ReInitializes the current FileOpenConfig instance to empty or zero values.

func (*FileOpenConfig) Equal

func (fOpenCfg *FileOpenConfig) Equal(fOpStat2 *FileOpenConfig) bool

Equal - Returns 'true' if the incoming FileOpenConfig instance is equal in all respects to the current FileOpenConfig instance.

func (*FileOpenConfig) GetCompositeFileOpenCode

func (fOpenCfg *FileOpenConfig) GetCompositeFileOpenCode() (int, error)

GetCompositeFileOpenCode - Returns the composite 'file open' code. This code is generated by or'ing together the stored single FileOpenType value and zero or more FileOpenMode values.

func (*FileOpenConfig) GetFileOpenModes

func (fOpenCfg *FileOpenConfig) GetFileOpenModes() []FileOpenMode

GetFileOpenModes - Returns a array of stored FileOpenMode values

func (*FileOpenConfig) GetFileOpenNarrativeText

func (fOpenCfg *FileOpenConfig) GetFileOpenNarrativeText() string

GetFileOpenNarrativeText - Returns a string with the File Open Type and File Open Modes expressed as descriptive text.

func (*FileOpenConfig) GetFileOpenType

func (fOpenCfg *FileOpenConfig) GetFileOpenType() FileOpenType

GetFileOpenType - Returns the stored FileOpenType value.

func (*FileOpenConfig) IsValid

func (fOpenCfg *FileOpenConfig) IsValid() error

IsValid - If the current FileOpenConfig instance is valid and properly initialized, this method returns nil. If the current FileOpenConfig instance is invalid, this method returns an error.

func (FileOpenConfig) New

func (fOpenCfg FileOpenConfig) New(fOpenType FileOpenType, fOpenModes ...FileOpenMode) (FileOpenConfig, error)

New - Creates and returns a fully initialized FileOpenConfig instance which encapsulates a "File Open" parameter or code.

To create a File Open parameter, two components are required:

  1. A FileOpenType AND

  2. A FileOpenMode

    FileOpenType: In order to open a file, exactly one of the following File Open Codes MUST be specified:

    FileOpenType(0).TypeReadOnly() FileOpenType(0).TypeWriteOnly() FileOpenType(0).TypeReadWrite()

    FileOpenMode: In addition to a 'FileOpenType', a File Open Mode is also required. Zero or more of the following File Open Mode codes may optionally be specified to better control file open behavior.

    FileOpenMode(0).ModeAppend() FileOpenMode(0).ModeCreate() FileOpenMode(0).ModeExclusive() FileOpenMode(0).ModeSync() FileOpenMode(0).ModeTruncate()

    The composite file open code is created internally by or'ing together the FileOpenType and FileOpenMode codes.

    Reference CONSTANTS: https://golang.org/pkg/os/

------------------------------------------------------------------------

Input Parameters:

fOpenType      FileOpenType - The FileOpenType used to open a file.

fOpenModes     FileOpenMode - Zero or more FileOpenMode instances which will be or'd
                              with the input parameter 'fOpenType' in order to generate
                              the composite 'file open' code which will be used to open
                              a file.  If no File Open Modes will be used, the user should
                              pass 'FileOpenMode(0).None()' or pass nothing for this
                              parameter.

------------------------------------------------------------------------

Return Values:

FileOpenConfig - If successful, this method will return a new, fully initialized instance
                 of FileOpenConfig. The type 'FileOpenConfig' creates and encapsulates the
                 file open code required by low-level file open methods.

error          - If this method completes successfully, the returned error
                 Type is set equal to 'nil'. If an error condition is encountered,
                 this method will return an error Type which encapsulates an
                 appropriate error message.

func (*FileOpenConfig) SetFileOpenModes

func (fOpenCfg *FileOpenConfig) SetFileOpenModes(fOpenModes ...FileOpenMode) error

SetFileOpenModes - Receives a series of FileOpenMode instances and replaces the internal stored FileOpenMode values for this FileOpenConfig instance.

To clear the current internal FileOpenMode values, pass nothing as an input parameter or pass the value FileOpenMode(0).None().

func (*FileOpenConfig) SetFileOpenType

func (fOpenCfg *FileOpenConfig) SetFileOpenType(fOpenType FileOpenType) error

SetFileOpenType - Receives an input parameter 'fOpenType' which is used to set the internal stored FileOpenType for the current FileOpenConfig instance.

type FileOpenMode

type FileOpenMode int

FileOpenMode - To further control the file open operation, one or more FileOpenMode values may be or'd with a FileOpenType code in order to control behavior.

In addition, one of the three codes may be or'd with zero or more of the following File Open Modes (Type: 'FileOpenMode') to better control file open behavior.

FileOpenMode has been adapted to function as an enumeration of valid File Open Mode values. Since Go does not directly support enumerations, the 'FileOpenMode' has been configured to function in a manner similar to classic enumerations found in other languages like C#. For additional information, reference:

Jeffrey Richter Using Reflection to implement enumerated types
       https://www.youtube.com/watch?v=DyXJy_0v0_U

These FileOpenMode methods used as enumerators for os mode constants:

FileOpenMode(0).ModeNone()
FileOpenMode(0).ModeAppend()
FileOpenMode(0).ModeTypeCreate()
FileOpenMode(0).ModeExclusive()
FileOpenMode(0).ModeSync()
FileOpenMode(0).ModeTruncate()

Reference CONSTANTS: https://golang.org/pkg/os/

The FileOpenType type is used in conjunction with FileOpenMode to specify file permissions. Reference the 'FileOpenType' in this 'pathfileops' package. The methods used to specify File Open Types are listed as follows:

FileOpenType(0).TypeReadOnly()
FileOpenType(0).TypeWriteOnly()
FileOpenType(0).TypeReadWrite()

Reference CONSTANTS: https://golang.org/pkg/os/

func (FileOpenMode) IsValid

func (fOpenMode FileOpenMode) IsValid() error

IsValid - If the value of the current FileOpenMode is 'invalid', this method will return an error. If the FileOpenMode is 'valid', this method will return a value of 'nil'.

This is a standard utility method and is not part of the valid enumerations for this type.

func (FileOpenMode) ModeAppend

func (fOpenMode FileOpenMode) ModeAppend() FileOpenMode

Append - append data to the file when writing.

func (FileOpenMode) ModeCreate

func (fOpenMode FileOpenMode) ModeCreate() FileOpenMode

Create - create a new file if none exists.

func (FileOpenMode) ModeExclusive

func (fOpenMode FileOpenMode) ModeExclusive() FileOpenMode

Exclusive - used with FileOpenControlMode(0).Create(), file must not exist.

func (FileOpenMode) ModeNone

func (fOpenMode FileOpenMode) ModeNone() FileOpenMode

None - No File Open Mode is active

func (FileOpenMode) ModeSync

func (fOpenMode FileOpenMode) ModeSync() FileOpenMode

Sync - open for synchronous I/O.

func (FileOpenMode) ModeTruncate

func (fOpenMode FileOpenMode) ModeTruncate() FileOpenMode

Truncate - if possible, truncate file when opened.

func (FileOpenMode) ParseString

func (fOpenMode FileOpenMode) ParseString(
	valueString string,
	caseSensitive bool) (FileOpenMode, error)

ParseString - Receives a string and attempts to match it with the string value of a supported enumeration. If successful, a new instance of FileOpenMode is returned set to the value of the associated enumeration.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Input Parameters

valueString   string - A string which will be matched against the
                       enumeration string values. If 'valueString'
                       is equal to one of the enumeration names, this
                       method will proceed to successful completion

caseSensitive   bool - If 'true' the search for enumeration names
                       will be case sensitive and will require an
                       exact match. Therefore, 'append' will NOT
                       match the enumeration name, 'Append'.

                       If 'false' a case insensitive search is conducted
                       for the enumeration name. In this case, 'append'
                       will match match enumeration name 'Append'.

------------------------------------------------------------------------

Return Values

FileOpenMode - Upon successful completion, this method will return a new
               instance of FileOpenMode set to the value of the enumeration
               matched by the string search performed on input parameter,
               'valueString'.

error        - If this method completes successfully, the returned error
               Type is set equal to 'nil'. If an error condition is encountered,
               this method will return an error Type which encapsulates an
               appropriate error message.

------------------------------------------------------------------------

Usage

t, err := FileOpenMode(0).ParseString("Append", true)
                     OR
t, err := FileOpenMode(0).ParseString("ModeAppend", true)
                     OR
t, err := FileOpenMode(0).ParseString("ModeAppend()", true)
                     OR
t, err := FileOpenMode(0).ParseString("Append()", true)
                     OR
t, err := FileOpenMode(0).ParseString("append", false)

In any case shown above, t is now equal to FileOpenMode(0).Append()

func (FileOpenMode) String

func (fOpenMode FileOpenMode) String() string

String - Returns a string with the name of the enumeration associated with this instance of 'FileOpenMode'.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Return Value:

string - The string label or description for the current enumeration
         value. If, the FileOpenMode value is invalid, this method will
         return an empty string.

------------------------------------------------------------------------

Usage

t:= FileOpenMode(0).ModeAppend()
str := t.String()
    str is now equal to 'ModeAppend'

func (FileOpenMode) Value

func (fOpenMode FileOpenMode) Value() int

Value - This is a utility method which is not part of the enumerations supported by this type. It returns the numeric value of the enumeration associated with the current FileOpenMode instance.

This is a standard utility method and is not part of the valid enumerations for this type.

type FileOpenType

type FileOpenType int

FileOpenType - In order to open a file, exactly one of the following File Open Codes MUST be specified:

FileOpenType(0).TypeReadOnly()
FileOpenType(0).TypeWriteOnly()
FileOpenType(0).TypeReadWrite()

In addition, one of the three previous codes may be or'd with zero or more of the following File Open Modes (Type: 'FileOpenMode') to better control file open behavior.

FileOpenMode(0).ModeAppend()
FileOpenMode(0).ModeCreate()
FileOpenMode(0).ModeExclusive()
FileOpenMode(0).ModeSync()
FileOpenMode(0).ModeTruncate()

Reference CONSTANTS: https://golang.org/pkg/os/

This type serves a wrapper for os package constants.

FileOpenType has been adapted to function as an enumeration of valid File Open Type values. Since Go does not directly support enumerations, the 'FileOpenType' has been configured to function in a manner similar to classic enumerations found in other languages like C#. For additional information, reference:

Jeffrey Richter Using Reflection to implement enumerated types
       https://www.youtube.com/watch?v=DyXJy_0v0_U

func (FileOpenType) IsValid

func (fOpenType FileOpenType) IsValid() error

IsValid - If the value of the current FileOpenType is 'invalid', this method will return an error. If the FileOpenType is 'valid', this method will return a value of 'nil'.

This is a standard utility method and is not part of the valid enumerations for this type.

func (FileOpenType) ParseString

func (fOpenType FileOpenType) ParseString(
	valueString string,
	caseSensitive bool) (FileOpenType, error)

ParseString - Receives a string and attempts to match it with the string value of a supported enumeration. If successful, a new instance of FileOpenType is returned set to the value of the associated enumeration.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Input Parameters:

valueString   string - A string which will be matched against the
                       enumeration string values. If 'valueString'
                       is equal to one of the enumeration names, this
                       method will proceed to successful completion.

                       You can prefix the string with "Type" or not.
                       Examples: "ReadOnly" or "TypeReadOnly"
                       Either string will produce the correct result.

caseSensitive   bool - If 'true' the search for enumeration names
                       will be case sensitive and will require an
                       exact match. Therefore, 'readonly' will NOT
                       match the enumeration name, 'ReadOnly'.

                       If 'false' a case insensitive search is conducted
                       for the enumeration name. In this case, 'readonly'
                       will match match enumeration name 'ReadOnly'.

------------------------------------------------------------------------

Return Values:

FileOpenType - Upon successful completion, this method will return a new
               instance of FileOpenType set to the value of the enumeration
               matched by the string search performed on input parameter,
               'valueString'.

error        - If this method completes successfully, the returned error
               Type is set equal to 'nil'. If an error condition is encountered,
               this method will return an error Type which encapsulates an
               appropriate error message.

------------------------------------------------------------------------

Usage:

t, err := FileOpenType(0).ParseString("ReadOnly", true)
                       Or
t, err := FileOpenType(0).ParseString("TypeReadOnly", true)
                       Or
t, err := FileOpenType(0).ParseString("TypeReadOnly()", true)
                       Or
t, err := FileOpenType(0).ParseString("ReadOnly()", true)
                       Or
t, err := FileOpenType(0).ParseString("readonly", false)

In of the cases shown above, t is now equal to FileOpenType(0).ReadOnly()

func (FileOpenType) String

func (fOpenType FileOpenType) String() string

String - Returns a string with the name of the enumeration associated with this instance of 'FileOpenType'. This is a standard utility method and is not part of the valid enumerations for this type.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Return Value:

string - The string label or description for the current enumeration
         value. If, the FileOpenType value is invalid, this method will
         return an empty string.

------------------------------------------------------------------------

Usage

t   := FileOpenType(0).TypeReadWrite()
str := t.String()
  str is now equal to "TypeReadWrite"

func (FileOpenType) TypeNone

func (fOpenType FileOpenType) TypeNone() FileOpenType

None - No File Open Type specified

func (FileOpenType) TypeReadOnly

func (fOpenType FileOpenType) TypeReadOnly() FileOpenType

ReadOnly - File opened for 'Read Only' access

func (FileOpenType) TypeReadWrite

func (fOpenType FileOpenType) TypeReadWrite() FileOpenType

ReadWrite - File opened for 'Read and Write' access

func (FileOpenType) TypeWriteOnly

func (fOpenType FileOpenType) TypeWriteOnly() FileOpenType

WriteOnly - File opened for 'Write Only' access

func (FileOpenType) Value

func (fOpenType FileOpenType) Value() int

Value - This is a utility method which is not part of the enumerations supported by this type. It returns the numeric value of the enumeration associated with the current FileOpenType instance.

This is a standard utility method and is not part of the valid enumerations for this type.

type FileOperationCode

type FileOperationCode int

FileOperationCode - Integer enumeration. Signals the type of operation to be performed on a file.

Usage:

----------------------------------------------------

To designate a File Operation Code, use the form:

FileOperationCode(0).MoveSourceFileToDestinationFile()

To access the File Operation Code using strictly dot notation, use either the private variable:

fileOpCode.MoveSourceFileToDestinationFile()

OR the public global variable:

FileOpCode.MoveSourceFileToDestinationFile()

Listing Of File Operation Codes:

----------------------------------------------------

FileOperationCode(0).None()
FileOperationCode(0).MoveSourceFileToDestinationFile()
FileOperationCode(0).MoveSourceFileToDestinationDir()
FileOperationCode(0).DeleteDestinationFile()
FileOperationCode(0).DeleteSourceFile()
FileOperationCode(0).DeleteSourceAndDestinationFiles()
FileOperationCode(0).CopySourceToDestinationByHardLinkByIo()
FileOperationCode(0).CopySourceToDestinationByIoByHardLink()
FileOperationCode(0).CopySourceToDestinationByHardLink()
FileOperationCode(0).CopySourceToDestinationByIo()
FileOperationCode(0).CreateSourceDir()
FileOperationCode(0).CreateSourceDirAndFile()
FileOperationCode(0).CreateSourceFile()
FileOperationCode(0).CreateDestinationDir()
FileOperationCode(0).CreateDestinationDirAndFile()
FileOperationCode(0).CreateDestinationFile()

FileOperationCode has been adapted to function as an enumeration of valid File Operation Code values. Since Go does not directly support enumerations, the 'FileOperationCode' has been configured to function in a manner similar to classic enumerations found in other languages like C#. For additional information, reference:

Jeffrey Richter Using Reflection to implement enumerated types
       https://www.youtube.com/watch?v=DyXJy_0v0_U
func (fop FileOperationCode) CopySourceToDestinationByHardLink() FileOperationCode

CopySourceToDestinationByHardLink - Copies the Source File to the Destination using one copy mode. The only copy attempt utilizes 'Copy by Hard Link'. If this attempted copy fails, an error is returned. The source file is unaffected.

See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

Usage:

FileOperationCode(0).CopySourceToDestinationByHardLink()

func (FileOperationCode) CopySourceToDestinationByHardLinkByIo

func (fop FileOperationCode) CopySourceToDestinationByHardLinkByIo() FileOperationCode

FileOperationCode(0).CopySourceToDestinationByHardLinkByIo() - Copies the Source File to the Destination using two copy attempts. The first copy is by Hard Link. If the first copy attempt fails, a second copy attempt is initiated by creating a new file and copying the contents by 'io.Copy'.

An error is returned only if both copy attempts fail. The source file is unaffected.

See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

Usage:

FileOperationCode(0).FileOperationCode(0).CopySourceToDestinationByHardLinkByIo()()

func (FileOperationCode) CopySourceToDestinationByIo

func (fop FileOperationCode) CopySourceToDestinationByIo() FileOperationCode

CopySourceToDestinationByIo - Copies the Source File to the Destination using only one copy mode. The only copy attempt is initiated using 'Copy by IO' or 'io.Copy'. If this fails an error is returned. The source file is unaffected.

See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

Usage:

FileOperationCode(0).CopySourceToDestinationByIo()
func (fop FileOperationCode) CopySourceToDestinationByIoByHardLink() FileOperationCode

FileOperationCode(0).CopySourceToDestinationByIoByHardLink() - Copies the Source File to the Destination using two copy attempts. The first copy is by 'io.Copy' which creates a new file and copies the contents to the new file. If the first attempt fails, a second copy attempt is initiated using 'copy by hard link'.

An error is returned only if both copy attempts fail. The source file is unaffected.

See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

Usage:

FileOperationCode(0).CopySourceToDestinationByIoByHardLink()

func (FileOperationCode) CreateDestinationDir

func (fop FileOperationCode) CreateDestinationDir() FileOperationCode

CreateDestinationDir - Creates the Destination Directory

Usage:

FileOperationCode(0).CreateDestinationDir()

func (FileOperationCode) CreateDestinationDirAndFile

func (fop FileOperationCode) CreateDestinationDirAndFile() FileOperationCode

CreateDestinationDirAndFile - Creates the Destination Directory and File

Usage:

FileOperationCode(0).CreateDestinationDirAndFile()

func (FileOperationCode) CreateDestinationFile

func (fop FileOperationCode) CreateDestinationFile() FileOperationCode

CreateDestinationFile - Creates the Destination File

Usage:

FileOperationCode(0).CreateDestinationFile()

func (FileOperationCode) CreateSourceDir

func (fop FileOperationCode) CreateSourceDir() FileOperationCode

CreateSourceDir - Creates the Source Directory

Usage:

FileOperationCode(0).CreateSourceDir()

formerly FileOperationCode(0).CreateSourceDir()

func (FileOperationCode) CreateSourceDirAndFile

func (fop FileOperationCode) CreateSourceDirAndFile() FileOperationCode

CreateSourceDirAndFile - Creates the Source Directory and File

Usage:

FileOperationCode(0).CreateSourceDirAndFile()

func (FileOperationCode) CreateSourceFile

func (fop FileOperationCode) CreateSourceFile() FileOperationCode

CreateSourceFile - Creates the Source File

Usage:

FileOperationCode(0).CreateSourceFile()

func (FileOperationCode) DeleteDestinationFile

func (fop FileOperationCode) DeleteDestinationFile() FileOperationCode

DeleteDestinationFile() - Deletes the Destination file if it exists

Usage:

FileOperationCode(0).DeleteDestinationFile()

func (FileOperationCode) DeleteSourceAndDestinationFiles

func (fop FileOperationCode) DeleteSourceAndDestinationFiles() FileOperationCode

DeleteSourceAndDestinationFiles - Deletes both the Source and Destination files if they exist.

Usage:

FileOperationCode(0).DeleteSourceAndDestinationFiles()

func (FileOperationCode) DeleteSourceFile

func (fop FileOperationCode) DeleteSourceFile() FileOperationCode

DeleteSourceFile() - Deletes the Source file if it exists

Usage:

FileOperationCode(0).DeleteSourceFile()

func (FileOperationCode) IsValid

func (fop FileOperationCode) IsValid() error

IsValid - If the value of the current FileOperationCode is 'invalid', this method will return an error. If the FileOperationCode is 'valid', this method will return a value of 'nil'.

This is a standard utility method and is not part of the valid enumerations for this type.

func (FileOperationCode) MoveSourceFileToDestinationDir

func (fop FileOperationCode) MoveSourceFileToDestinationDir() FileOperationCode

MoveSourceFileToDestinationDir - Moves the source file to the destination directory and then deletes the original source file. The destination file name is the same as the source file name.

Usage:

FileOperationCode(0).MoveSourceFileToDestinationDir()

func (FileOperationCode) MoveSourceFileToDestinationFile

func (fop FileOperationCode) MoveSourceFileToDestinationFile() FileOperationCode

MoveSourceFileToDestinationFile - Moves the source file to the destination file and then deletes the original source file.

Usage:

FileOperationCode(0).MoveSourceFileToDestinationFile()

func (FileOperationCode) None

None - No operation (NOOP) No File Operation is performed.

Usage:

FileOperationCode(0).None()

func (FileOperationCode) ParseString

func (fop FileOperationCode) ParseString(
	valueString string,
	caseSensitive bool) (FileOperationCode, error)

ParseString - Receives a string and attempts to match it with the string value of a supported enumeration. If successful, a new instance of FileOperationCode is returned set to the value of the associated enumeration.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Input Parameters

valueString   string - A string which will be matched against the
                       enumeration string values. If 'valueString'
                       is equal to one of the enumeration names, this
                       method will proceed to successful completion

caseSensitive   bool - If 'true' the search for enumeration names
                       will be case sensitive and will require an
                       exact match. Therefore, 'movesourcefiletodestination' will NOT
                       match the enumeration name, 'MoveSourceFileToDestinationFile'.

                       If 'false' a case insensitive search is conducted
                       for the enumeration name. In this case, 'movesourcefiletodestination'
                       will match match enumeration name 'MoveSourceFileToDestinationFile'.

------------------------------------------------------------------------

Return Values

FileOperationCode - Upon successful completion, this method will return a new
                    instance of FileOperationCode set to the value of the enumeration
                    matched by the string search performed on input parameter,
                    'valueString'.

error             - If this method completes successfully, the returned error
                    Type is set equal to 'nil'. If an error condition is encountered,
                    this method will return an error Type which encapsulates an
                    appropriate error message.

------------------------------------------------------------------------

Usage

	t, err := FileOperationCode(0).ParseString("MoveSourceFileToDestinationFile", true)
                                 OR
	t, err := FileOperationCode(0).ParseString("movesourcefiletodestination", false)

	For all of the cases shown above,
	t is now equal to FileOperationCode(0).MoveSourceFileToDestinationFile()

func (FileOperationCode) String

func (fop FileOperationCode) String() string

String - Returns a string with the name of the enumeration associated with this instance of 'FileOperationCode'.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Return Value:

string - The string label or description for the current enumeration
         value. If, the FileOperationCode value is invalid, this method
         will return an empty string.

------------------------------------------------------------------------

Usage

t:= FileOperationCode(0).MoveSourceFileToDestinationFile()
str := t.String()
    str is now equal to "MoveSourceFileToDestinationFile"

func (FileOperationCode) Value

func (fop FileOperationCode) Value() int

Value - This is a utility method which is not part of the enumerations supported by this type. It returns the numeric value of the enumeration associated with the current FileOperationCode instance.

This is a standard utility method and is not part of the valid enumerations for this type.

type FileOps

type FileOps struct {
	// contains filtered or unexported fields
}

FileOps - This type is used to manage and coordinate various operations performed on files. Hence the name, File Operations.

func (*FileOps) CopyOut

func (fops *FileOps) CopyOut() FileOps

CopyOut - Returns a deep copy of the current FileOps instance.

func (*FileOps) Equal

func (fops *FileOps) Equal(fops2 *FileOps) bool

Equal - Returns 'true' if source, destination and opToExecute are equivalent. In other words both the current File Operations instance and the File Operations instance passed as an input parameter must have data fields which are equal in all respects.

If any data field is found to be unequal, this method returns 'false'.

func (*FileOps) EqualPathFileNameExt

func (fops *FileOps) EqualPathFileNameExt(fops2 *FileOps) bool

EqualPathFileNameExt - Compares two File Operations Types, 'FileOps'. The method returns 'true' if source and destination absolute paths, file names and file extensions are equivalent. Data Field 'opToExecute' is not included in the comparison.

The absolute path, file name and file extension comparisons are case insensitive. This means that all strings used in the comparisons are first converted to lower case before testing for equivalency.

If the absolute paths, file names and file extensions are NOT equal, this method returns 'false'.

func (*FileOps) ExecuteFileOperation

func (fops *FileOps) ExecuteFileOperation(fileOp FileOperationCode) error

ExecuteFileOperation - Executes specific operations on the source and/or destination files configured and identified in the current FileOps instance.

------------------------------------------------------------------------

Input Parameters:

FileOperationCode

The FileOperationCode type consists of the following
constants.

FileOperationCode(0).MoveSourceFileToDestinationFile()
	Moves the source file to the destination file and
	then deletes the original source file

FileOperationCode(0).DeleteDestinationFile()
	Deletes the Destination file if it exists

FileOperationCode(0).DeleteSourceFile()
	Deletes the Source file if it exists

FileOperationCode(0).DeleteSourceAndDestinationFiles
	Deletes both the Source and Destination files
	if they exist.

FileOperationCode(0).CopySourceToDestinationByHardLinkByIo()
	Copies the Source File to the Destination
	using two copy attempts. The first copy is
	by Hard Link. If the first copy attempt fails,
	a second copy attempt is initiated/ by creating
	a new file and copying the contents by 'io.Copy'.
	An error is returned only if both copy attempts
	fail. The source file is unaffected.

	See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

FileOperationCode(0).CopySourceToDestinationByIoByHardLink()
	Copies the Source File to the Destination
	using two copy attempts. The first copy is
	by 'io.Copy' which creates a new file and copies
	the contents to the new file. If the first attempt
	fails, a second copy attempt is initiated using
	'copy by hard link'. An error is returned only
	if both copy attempts fail. The source file is
	unaffected.

	See: https://stackoverflow.com/questions/21060945/simple-way-to-copy-a-file-in-golang

FileOperationCode(0).CopySourceToDestinationByHardLink()
	Copies the Source File to the Destination
	using one copy mode. The only copy attempt
	utilizes 'Copy by Hard Link'. If this fails
	an error is returned.  The source file is
	unaffected.

FileOperationCode(0).CopySourceToDestinationByIo()
	Copies the Source File to the Destination
	using only one copy mode. The only copy
	attempt is initiated using 'Copy by IO' or
	'io.Copy'.  If this fails an error is returned.
	The source file is unaffected.

FileOperationCode(0).CreateSourceDir()
	Creates the Source Directory

FileOperationCode(0).CreateSourceDirAndFile()
	Creates the Source Directory and File

FileOperationCode(0).CreateSourceFile()
	Creates the Source File

FileOperationCode(0).CreateDestinationDir()
	Creates the Destination Directory

FileOperationCode(0).CreateDestinationDirAndFile()
	Creates the Destination Directory and File

FileOperationCode(0).CreateDestinationFile()
	Creates the Destination File

func (*FileOps) GetDestination

func (fops *FileOps) GetDestination() FileMgr

GetSource - Returns a deep copy of the destination FileMgr instance.

func (*FileOps) GetSource

func (fops *FileOps) GetSource() FileMgr

GetSource - Returns a deep copy of the source FileMgr instance.

func (*FileOps) IsInitialized

func (fops *FileOps) IsInitialized() bool

IsInitialized - Returns a boolean value indicating whether this FileOps instance has been properly initialized.

func (FileOps) NewByDirMgrFileName

func (fops FileOps) NewByDirMgrFileName(
	sourceDir DirMgr,
	sourceFileNameExt string,
	destinationDir DirMgr,
	destinationFileNameExt string) (FileOps, error)

NewByDirMgrFileName - Creates and returns a new FileOps instance based on input parameters, source Directory Manger, source file name and extension string, destination Directory Manager and destination file name and extension string.

If the destinationFileNameExt string is an empty string, it will default to the 'sourceFileNameExt'

func (FileOps) NewByDirStrsAndFileNameExtStrs

func (fops FileOps) NewByDirStrsAndFileNameExtStrs(
	sourceDirStr string,
	sourceFileNameExtStr string,
	destinationDirStr string,
	destinationFileNameExtStr string) (FileOps, error)

NewByDirStrsAndFileNameExtStrs - Creates and returns a new FileOps instance based on source and destination input parameters which consist of two pairs of directory or path strings and file name and extension strings.

If the input parameter, 'destinationFileNameExtStr' is an empty string, it will be defaulted to a string value equal to 'sourceFileNameExtStr'.

func (FileOps) NewByFileMgrs

func (fops FileOps) NewByFileMgrs(
	source,
	destination FileMgr) (FileOps, error)

NewByFileMgrs - Creates and returns a new FileOps instance based on input parameters 'source' and 'destination' File Managers.

func (FileOps) NewByPathFileNameExtStrs

func (fops FileOps) NewByPathFileNameExtStrs(
	sourcePathFileNameExt string,
	destinationPathFileNameExt string) (FileOps, error)

NewByPathFileNameExtStrs - Creates and returns a new FileOps instance based on two string input parameters. The first represents the path name, file name and extension of the source file. The second represents the path name, file name and extension of the destination file.

func (*FileOps) SetFileOpsCode

func (fops *FileOps) SetFileOpsCode(fOpCode FileOperationCode) error

SetFileOpsCode - Sets the File Operations code for the current FileOps instance.

type FileOpsCollection

type FileOpsCollection struct {
	// contains filtered or unexported fields
}

FileOpsCollection - A collection of files and file operations which are designed to perform specific actions on disk files.

func (*FileOpsCollection) AddByDirMgrFileName

func (fOpsCol *FileOpsCollection) AddByDirMgrFileName(
	sourceDirMgr DirMgr,
	sourceFileNameExt string,
	destinationDirMgr DirMgr,
	destinationFileNameExt string) error

AddByDirMgrFileName - Creates and Adds another FileOps object to the collection based on input parameters consisting of a pair of DirMgr and file name extension strings for source and destination.

func (*FileOpsCollection) AddByDirStrsAndFileNameExtStrs

func (fOpsCol *FileOpsCollection) AddByDirStrsAndFileNameExtStrs(
	sourceDirStr,
	sourceFileNameExtStr,
	destinationDirStr,
	destinationFileNameExtStr string) error

AddByDirStrsAndFileNameExtStrs - Creates and adds another File Operations object to the collection based on two pairs of directory name and file name extension strings for both source and destination respectively.

func (*FileOpsCollection) AddByFileMgrs

func (fOpsCol *FileOpsCollection) AddByFileMgrs(
	sourceFileMgr,
	destinationFileMgr FileMgr) error

AddByFileMgrs - Adds another FileOps object to the collection based source and destination input parameters of type 'FileMgr'.

func (*FileOpsCollection) AddByFileOps

func (fOpsCol *FileOpsCollection) AddByFileOps(fileOp FileOps) error

AddByFileOps - Adds a FileOps object to the existing collection based on the 'FileOps' Input parameter.

func (*FileOpsCollection) AddByPathFileNameExtStrs

func (fOpsCol *FileOpsCollection) AddByPathFileNameExtStrs(
	sourcePathFileNameExt,
	destinationPathFileNameExt string) error

AddByPathFileNameExtStrs - Creates and adds another File Operations object to the collection based on two input strings which contain the full path name, file name and file extension for the source and destination respectively.

func (*FileOpsCollection) CopyOut

func (fOpsCol *FileOpsCollection) CopyOut() (FileOpsCollection, error)

CopyOut - Returns an FileMgrCollection which is an exact duplicate of the current FileMgrCollection. The copy is operation is a 'deep copy'.

func (*FileOpsCollection) DeleteAtIndex

func (fOpsCol *FileOpsCollection) DeleteAtIndex(idx int) error

DeleteAtIndex - Deletes a member File Operations element from the collection at the index specified by input parameter, 'idx'.

If successful, at the completion of this method, the File Operations Collection array will have a length which is one less than the starting array length.

func (*FileOpsCollection) Equal

func (fOpsCol *FileOpsCollection) Equal(fOpsCol2 *FileOpsCollection) bool

Equal - Compares the input parameter FileOpsCollection to the current FileOpsCollection instance. If they are equal, this method returns true.

func (*FileOpsCollection) ExecuteFileOperations

func (fOpsCol *FileOpsCollection) ExecuteFileOperations(
	fileOp FileOperationCode) error

ExecuteFileOperations - Executes a file operation on each member of the File Operations Collection. Any errors are collected and returned in an error array.

The type of file operation performed is specified by input parameter, 'fileOp'. 'fileOp' is of type 'FileOperationCode'.

func (*FileOpsCollection) GetFileOpsAtIndex

func (fOpsCol *FileOpsCollection) GetFileOpsAtIndex(idx int) (*FileOps, error)

GetFileOpsAtIndex - If successful, this method returns a pointer to the FileOps instance at the array index specified. The 'Peek' and 'Pop' methods below return FileOps objects using a 'deep' copy and therefore offer better protection against data corruption.

func (*FileOpsCollection) GetNumOfFileOps

func (fOpsCol *FileOpsCollection) GetNumOfFileOps() int

GetNumOfFileOps - Returns the number of File Operations objects in the collection. Effectively, this is the array length of internal field FileOpsCollection.fileOps.

func (*FileOpsCollection) InsertFileOpsAtIndex

func (fOpsCol *FileOpsCollection) InsertFileOpsAtIndex(fOps FileOps, index int) error

InsertFileOpsAtIndex - Inserts a new File Operations type ('FileOps') into the collection at array 'index'. The new File Operations instance is passed as input parameter 'fOps'.

If input parameter 'index' is less than zero, an error will be returned. If 'index' exceeds the value of the last index in the collection, 'fOps' will be added to the end of the collection at the next legal index.

func (FileOpsCollection) New

func (fOpsCol FileOpsCollection) New() FileOpsCollection

New - Creates and returns a new, properly initialized instance of 'FileOpsCollection'

func (FileOpsCollection) NewFromFileMgrCollection

func (fOpsCol FileOpsCollection) NewFromFileMgrCollection(
	fMgrCol *FileMgrCollection,
	sourceBaseDir,
	targetBaseDir *DirMgr) (FileOpsCollection, error)

NewFromFileMgrCollection - Creates and returns a new File Operations Collection ('FileOpsCollection') generated from an existing File Manger Collection ('FileMgrCollection') and a target base directory.

The source files for the new File Operations Collection are taken from the input parameter 'fMgrCol', the incoming File Manager Collection.

The destination files for the new File Operations Collection are created from the source file names. The destination file directories are created by substituting the target base directory ('targetBaseDir') for the source base directory ('sourceBaseDir') in the source directory tree.

This substitution is helpful when copying one directory tree to another directory tree.

func (*FileOpsCollection) PeekFileOpsAtIndex

func (fOpsCol *FileOpsCollection) PeekFileOpsAtIndex(idx int) (FileOps, error)

PeekFileOpsAtIndex - Returns a deep copy of the File Operations ('FileOps') object located at array index 'idx' in the File Operations Collection ('FileOpsCollection'). This is a 'Peek' method and therefore the original File Operations ('FileOps') object is NOT deleted from the File Operations Collection ('FileOpsCollection') array.

At the completion of this method, the length of the File Operations Collection ('FileOpsCollection') array will remain unchanged.

func (*FileOpsCollection) PeekFirstFileOps

func (fOpsCol *FileOpsCollection) PeekFirstFileOps() (FileOps, error)

PeekFirstFileOps - Returns a deep copy of the first File Operations ('FileOps') object in the File Operations Collection ('FileOpsCollection'). This is a 'Peek' method and therefore the original File Operations ('FileOps') object is NOT deleted from the File Operations Collection ('FileOpsCollection') array.

At the completion of this method, the length of the File Operations Collection ('FileOpsCollection') array will remain unchanged.

func (*FileOpsCollection) PeekLastFileOps

func (fOpsCol *FileOpsCollection) PeekLastFileOps() (FileOps, error)

PeekLastFileOps - Returns a deep copy of the last File Operations ('FileOps') object in the File Operations Collection ('FileOpsCollection').

This is a 'Peek' method and therefore the original File Operations ('FileOps') object is NOT deleted from the File Operations Collection ('FileOpsCollection') array.

At the completion of this method, the length of the File Operations Collection ('FileOpsCollection') array will remain unchanged.

func (*FileOpsCollection) PopFileOpsAtIndex

func (fOpsCol *FileOpsCollection) PopFileOpsAtIndex(idx int) (FileOps, error)

PopFileOpsAtIndex - Returns a copy of the File Operations (FileOps) object located at index, 'idx', in the File Operations Collection ('FileOpsCollection') array. As a 'Pop' method, the original File Operations ('FileOps') object is deleted from the File Operations Collection ('FileOpsCollection') array.

Therefore at the completion of this method, the File Operations Collection array has a length which is one less than the starting array length.

func (*FileOpsCollection) PopFirstFileOps

func (fOpsCol *FileOpsCollection) PopFirstFileOps() (FileOps, error)

PopFirstFileOps - Returns a deep copy of the first File Operations ('FileOps') object in the File Operations Collection array. As a 'Pop' method, the original File Operations ('FileOps') object is deleted from the File Operations Collection ('FileOpsCollection') array.

Therefore at the completion of this method, the File Operations Collection array has a length which is one less than the starting array length.

func (*FileOpsCollection) PopLastFileOps

func (fOpsCol *FileOpsCollection) PopLastFileOps() (FileOps, error)

PopLastFileOps - Returns a deep copy of the last File Operations ('FileOps') object in the File Operations Collection array. As a 'Pop' method, the original File Operations ('FileOps') object is deleted from the File Operations Collection ('FileOpsCollection') array.

Therefore, at the completion of this method, the File Operations Collection array has a length which is one less than the starting array length.

type FilePermissionConfig

type FilePermissionConfig struct {
	// contains filtered or unexported fields
}

FilePermissionConfig - Provides methods to support the creation and management of of File Permissions for using in controlling file operations. The Go Programming Language uses os.FileMode (https://golang.org/pkg/os/#FileMode) and unix permission bits to configure file permissions.

Reference:
https://www.cyberciti.biz/faq/explain-the-nine-permissions-bits-on-files/
https://en.wikipedia.org/wiki/File_system_permissions

The FilePermissionConfig methods will allow for configuration of valid file permissions which are subsequently stored as an os.FileMode in a private member variable, 'FilePermissionConfig.fileMode'.

When evaluated as a string, file permission is defined by a 10-character string. The first character is an 'Entry Type' and the remaining 9-characters are unix permission bits.

Example: -rwxrwxrwx
         drwxrwxrwx - identifies permissions for directory
                      value = 020000000777

Internal private member variable stores the consolidated permission as a numerical value in 'FilePermissionConfig.fileMode'.

func (*FilePermissionConfig) CopyIn

func (fPerm *FilePermissionConfig) CopyIn(fPerm2 *FilePermissionConfig)

CopyIn - Receives a FilePermissionConfig instance and copies all data fields to the current FilePermissionConfig instance. When complete, both the incoming and current FilePermissionConfig instances will be identical. The type of copy operation performed is a 'deep copy'.

func (*FilePermissionConfig) CopyOut

func (fPerm *FilePermissionConfig) CopyOut() FilePermissionConfig

CopyOut - Returns a new instance of FilePermissionConfig which is in all respects an exact duplicate of the current FilePermissionConfig instance. The type of copy operation performed is a 'deep copy'.

func (*FilePermissionConfig) Empty

func (fPerm *FilePermissionConfig) Empty()

Empty - ReInitializes the current FilePermissionConfig instance to empty or zero values.

func (*FilePermissionConfig) Equal

func (fPerm *FilePermissionConfig) Equal(fPerm2 *FilePermissionConfig) bool

Equal - Returns 'true' if the incoming FilePermissionConfig instance is equal in all respects to the current FilePermissionConfig instance.

func (*FilePermissionConfig) GetCompositePermissionMode

func (fPerm *FilePermissionConfig) GetCompositePermissionMode() (os.FileMode, error)

GetCompositePermissionMode - Returns the os.FileMode from the internal data field, 'FilePermissionConfig.fileMode'. 'fileMode' represents the complete, consolidated permission code. It therefore contains the two elements which make up a consolidated permission code: Entry Type and Permission Bits.

This method returns the complete permission code as a type 'os.FileMode'.

func (*FilePermissionConfig) GetEntryTypeComponent

func (fPerm *FilePermissionConfig) GetEntryTypeComponent() (OsFilePermissionCode, error)

GetEntryTypeComponent - Returns the 'Entry Type' component of the current os.FileMode permissions value. The 'Entry Type' is the first character in a 10-character permissions text string. For the majority of applications, the leading character in a 10-character permissions text string is either a hyphen ('-') indicating the subject is a file - or - a 'd' indicating the subject is a directory. For a file, the File Mode Entry Type value is zero ('0'). For a directory, the File Mode Entry Type value is equal to 'os.ModDir'.

------------------------------------------------------------------------

Return Values:

OsFilePermissionCode - The OsFilePermissionCode type is set to the value of
                       the os.FileMode constant representing the Entry Type
                       associated with the permission value encapsulated by
                       this FilePermissionConfig instance.

func (*FilePermissionConfig) GetFileMode

func (fPerm *FilePermissionConfig) GetFileMode() (os.FileMode, error)

GetFileMode - Returns a FileMode containing only the least significant 9-bits of the encapsulated FileMode representing the unix permission bits.

If this value is converted to a permissions string, the actual string returned will contains 10-characters, have the first character (index=0) will always be a hyphen ("-"). The hyphen ("-") indicates a file, however it should be ignored in this case. The only valid a reliable unix permission bits are in the last 9-characters (string indexes 1-8). When evaluating permission bits returned by this method as permission strings always ignore the first character which will always be a hyphen ("-").

To acquire the full and valid 10-digit permission string use method FilePermissionConfig.GetPermissionTextCode() documented below.

func (*FilePermissionConfig) GetIsDir

func (fPerm *FilePermissionConfig) GetIsDir() (bool, error)

GetIsDir - Return a bool indicating whether the encapsulated FileMode is a directory or not. A returned value of 'true' signals that the FileMode represents a directory.

This method serves as a wrapper for os.FileMode.IsDir()

func (*FilePermissionConfig) GetIsRegular

func (fPerm *FilePermissionConfig) GetIsRegular() (bool, error)

GetIsRegular - Return a bool indicating whether the encapsulated FileMode is a file or not. A returned value of 'true' signals that the FileMode represents a file.

This method serves as a wrapper for os.FileMode.IsRegular()

func (*FilePermissionConfig) GetPermissionComponents

func (fPerm *FilePermissionConfig) GetPermissionComponents() (
	osMode OsFilePermissionCode, permissionBits os.FileMode, err error)

GetPermissionComponents - Returns the two components of a permission configuration.

------------------------------------------------------------------------

Return Values:

entryType OsFilePermissionCode - The Entry Type or os mode value. Generally this will either be
                                 OsFilePermissionCode(0).ModeNone() for files
                                                 or
                                 OsFilePermissionCode(0).ModeDir() for directories.

                                 For more information see method FilePermissionConfig.GetEntryTypeComponent()

permissionBits  os.FileMode - The 9-least significant bits designate the unix
                              permission bits.

                              Be advised that if you call string on this result
                              (permissionBits.String()) you will receive a 10-character
                              string the first character of which is always a hyphen ("-").
                              Disregard this first character, only the last 9-characters of
                              the string are valid permission descriptors. For more information
                              see method FilePermissionConfig.GetFileMode()

                              To create a full and complete permission code, permissionBits must
                              be or'd with a valid Entry Type, os mode value.

func (*FilePermissionConfig) GetPermissionFileModeValueText

func (fPerm *FilePermissionConfig) GetPermissionFileModeValueText() string

GetPermissionFileModeValueText - Returns the Permission File Mode numeric value as text. The text presents the octal value of the File Mode.

Example:
      -rw-rw-rw- = returned value 0666
      drwxrwxrwx = returned value 020000000777

func (*FilePermissionConfig) GetPermissionNarrativeText

func (fPerm *FilePermissionConfig) GetPermissionNarrativeText() string

GetPermissionNarrativeText - Returns a string containing a narrative text description of the current permission codes.

Example Return Value
    "Entry Type: ModeFile  -Permission Code: -rwxrwxrwx   -File Mode Value: 0777"

func (*FilePermissionConfig) GetPermissionTextCode

func (fPerm *FilePermissionConfig) GetPermissionTextCode() (string, error)

GetPermissionTextCode - Returns the file mode permissions expressed as a text string. The returned string includes the full and complete 10-character permission code.

Example Return Values:
      -rwxrwxrwx
      -rw-rw-rw-
      drwxrwxrwx

func (*FilePermissionConfig) IsValid

func (fPerm *FilePermissionConfig) IsValid() error

IsValid - If the current FilePermissionConfig instance is judged to be 'Invalid', this method will return an error.

Otherwise, if the current instance of FilePermissionConfig evaluates as 'Valid', the method will return 'nil'.

func (FilePermissionConfig) New

func (fPerm FilePermissionConfig) New(modeStr string) (FilePermissionConfig, error)

New - Creates and returns a new FilePermissionConfig instance initialized with a an os.FileMode value generated from the input parameter 'modeStr'.

'modeStr' is a 10-character string containing the read, write and execute permissions for the the three groups, 'Owner', 'Group' and 'Other'.

The text codes used in the 'modeStr' mimic the Unix permission codes.

Reference:
  https://www.cyberciti.biz/faq/explain-the-nine-permissions-bits-on-files/.
  https://en.wikipedia.org/wiki/File_system_permissions

The first character of the 'modeStr' designates the 'Entry Type'. Currently, only two 'Entry Type' characters are supported. Therefore, the first character in the 10-character input parameter 'modeStr' MUST be either a "-" indicating a file, or a "d" indicating a directory.

The remaining nine characters in the 'modeStr' represent unix permission bits and consist of three group fields each containing 3-characters. Each character in the three group fields may be consist of 'r' (Read-Permission), 'w' (Write-Permission), 'x' (Execute-Permission) or '-' signaling no permission or no access allowed. A typical 'modeStr' authorizing permission for full access to a file would be styled as:

Example: "-rwxrwxrwx"

Groups: - Owner/User, Group, Other
From left to right
First Characters is Entry Type index 0 ("-")

First Char index 0 =      "-"    Designates a file
Char indexes 1-3 = Owner  "rwx"  Authorizing 'Read', 'Write' & Execute Permissions for 'Owner'
Char indexes 4-6 = Group  "rwx"  Authorizing 'Read', 'Write' & Execute Permissions for 'Group'
Char indexes 7-9 = Other  "rwx"  Authorizing 'Read', 'Write' & Execute Permissions for 'Other'

The Symbolic notation provided by input parameter 'modeStr' MUST conform to the options presented below. The first character or 'Entry Type' is listed as "-". However, in practice, the caller may set the first character as either a "-", specifying a file, or a "d", specifying a directory. No other first character types are currently supported.

Three SymbolicGroups: The three group types are: Owners, Groups & Others.

10-Character
 'modeStr'
 Symbolic      Octal      File Access
 Notation      Notation   Permission Descriptions
 ----------    0000       no permissions
 -rwx------    0700       read, write, & execute only for owner
 -rwxrwx---    0770       read, write, & execute for owner and group
 -rwxrwxrwx    0777       read, write, & execute for owner, group and others
 ---x--x--x    0111       execute
 --w--w--w-    0222       write
 --wx-wx-wx    0333       write & execute
 -r--r--r--    0444       read
 -r-xr-xr-x    0555       read & execute
 -rw-rw-rw-    0666       read & write
 -rwxr-----    0740       Owner can read, write, & execute. Group can only read;
                             others have no permissions

Note: drwxrwxrwx - identifies permissions for directory
                   value = 020000000777

------------------------------------------------------------------------

Input Parameter:

modeStr  string - 'modeStr' must conform to the symbolic notation options shown
                  above. Failure to comply with this requirement will generate an
                  error. As indicated, 'modeStr' must consist of 10-characters.
                  The first character in 'modeStr' may be '-' specifying a fle or
                  'd' specifying a directory.

                  Reference:
                  How to use special permissions: the setuid, setgid and sticky bits
                  https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits

func (FilePermissionConfig) NewByComponents

func (fPerm FilePermissionConfig) NewByComponents(
	entryType OsFilePermissionCode,
	unixPermissionTextStr string) (FilePermissionConfig, error)

NewByComponents - Creates and returns a new instance of FilePermissionConfig using two input parameters, 'entryType' and 'unixPermissionTextStr'.

For additional documentation see method FilePermissionConfig.SetFileModeByComponents() which is called by this method.

------------------------------------------------------------------------

Input Parameters:

entryType OsFilePermissionCode - The code which makes up the first character in
                                 a 10-digit unix permission character string.
                                 This a wrapper for os.FileMode constants.
                                   Reference:
                                      https://golang.org/pkg/os/#FileMode

                                 Select this value with caution. See the warning below.

unixPermissionTextStr string   - A 9-character string containing the unix permission
                                 bits expressed as three groups of 3-characters each.
                                 Note: if the string is the standard 10-character string,
                                 only the last 9-characters will be used.

                                 The 9-characters are constituents of the the three Symbolic
                                 Groups: Owners/Users, Groups & Others. Each group has three
                                 characters which may be 'r', 'w', 'x'. If a permission is not
                                 set, that character position contains a '-'.

 'unixPermissionTextStr'
      9-Character          File Access
      Notation             Permission Descriptions
      ---------            File - no permissions
      rwx------            File - read, write, & execute only for owner
      rwxrwx---            File - read, write, & execute for owner and group
      rwxrwxrwx            File - read, write, & execute for owner, group and others
      --x--x--x            File - execute
      -w--w--w-            File - write
      -wx-wx-wx            File - write & execute
      r--r--r--            File - read
      r-xr-xr-x            File - read & execute
      rw-rw-rw-            File - read & write
      rwxr-----            File - Owner can read, write, & execute. Group can only read;

Note: drwxrwxrwx - identifies permissions for directory
                    value = 020000000777

------------------------------------------------------------------------

Warning:

Incorrect or invalid File Permissions can cause extensive damage. If you don't know what you are doing, you would be well advised to use one of the other methods in this type which provide additional safeguards.

If you decide to proceed, be guided by the wisdom of Davy Crockett:

"Be always sure you are right - then go ahead."

func (FilePermissionConfig) NewByFileMode

func (fPerm FilePermissionConfig) NewByFileMode(fMode os.FileMode) (FilePermissionConfig, error)

NewByFileMode - Creates and returns a new instance of FilePermissionConfig. The instance is initialized using the input parameter 'fMode' of type 'os.FileMode'. 'fMode' is assumed to contain all of the codes necessary for the configuration of unix file permission bits.

func (FilePermissionConfig) NewByOctalDigits

func (fPerm FilePermissionConfig) NewByOctalDigits(
	octalFileModeCode int) (FilePermissionConfig, error)

NewByOctalDigits - Creates and returns a new FilePermissionConfig instance by initializing the internal FileMode data field (FilePermissionConfig.fileMode) to the value represented by input parameter, 'octalFileModeCode'.

Note: This method calls FilePermissionConfig.SetFileModeByOctalDigits().

------------------------------------------------------------------------

Input Parameter:

octalFileModeCode int - This parameter contains the integer value of the
                        of the permission code which will be used to
                        initialize the current FilePermissionConfig instance
                        (FilePermissionConfig.fileMode). The integer digits
                        in 'octalFileModeCode' represent the octal value
                        for the file permission as indicated by the following
                        examples.
 ____________________________________________________________________________

          Input Parameter
              integer            Equivalent
 Octal    'octalFileModeCode'    Symbolic      File Access
 Digits        value             Notation      Permission Descriptions
 0000 	         0               ----------    File - no permissions
 0700 	       700               -rwx------    File - read, write, & execute only for owner
 0770 	       770               -rwxrwx---    File - read, write, & execute for owner and group
 0777 	       777               -rwxrwxrwx    File - read, write, & execute for owner, group and others
 0111 	       111               ---x--x--x    File - execute
 0222 	       222               --w--w--w-    File - write
 0333 	       333               --wx-wx-wx    File - write & execute
 0444 	       444               -r--r--r--    File - read
 0555 	       555               -r-xr-xr-x    File - read & execute
 0666 	       666               -rw-rw-rw-    File - read & write
 0740 	       740               -rwxr-----    File - Owner can read, write, & execute. Group can only read;
                                                      others have no permissions

 20000000777   20000000777       drwxrwxrwx    Directory - read, write, & execute for owner, group and others

 See method FilePermissionConfig.SetFileModeByTextCode() for more documentation

------------------------------------------------------------------------

Warning:

In the Go Programming Language, if you initialize an integer with a leading zero (e.g. x:= int(0777)), than number ('0777') is treated as an octal value and converted to a decimal value. Therefore, x:= int(0777) will mean that 'x' is set equal to 511. If you set x:= int(777), x will be set equal to '777'. For purposes of this method enter the octal code as x:= int(777).

func (*FilePermissionConfig) SetByFileMode

func (fPerm *FilePermissionConfig) SetByFileMode(fMode os.FileMode) error

SetByFileMode - Sets the permission codes for this FilePermissionConfig instance using an input parameter of type 'os.FileMode'. If the value does not include a valid os mode constant, and error will be returned.

If successful, this method will assign the os.FileMode input value to the internal data field, 'FilePermissionConfig.fileMode'.

func (*FilePermissionConfig) SetFileModeByComponents

func (fPerm *FilePermissionConfig) SetFileModeByComponents(
	entryType OsFilePermissionCode, unixPermissionTextStr string) error

SetFileModeByComponents - Sets the value of the current FilePermissionConfig instance by initializing the internal FileMode data field (FilePermissionConfig.fileMode). The final FileMode value is computed by integrating the 'entryType' FileMode with the unix permission symbolic values provided by the input parameter, 'unixPermissionStr'. This approach allows the caller to created custom File Permissions.

------------------------------------------------------------------------

Input Parameters:

entryType OsFilePermissionCode - The code which makes up the first character in
                                 a 10-digit unix permission character string.
                                 This a wrapper for os.FileMode constants.
                                   Reference:
                                      https://golang.org/pkg/os/#FileMode

                                 Select this value with caution. See the warning below.

unixPermissionStr string - A 9-character string containing the unix permission
                           bits expressed as three groups of 3-characters each.

                           The 9-characters are constituents of the the three Symbolic
                           Groups: Owners/Users, Groups & Others. Each group has three
                           characters which may be 'r', 'w', 'x'. If a permission is not
                           set, that character position contains a '-'.

 'unixPermissionTextStr'
      9-Character          File Access
      Notation             Permission Descriptions
      ---------            File - no permissions
      rwx------            File - read, write, & execute only for owner
      rwxrwx---            File - read, write, & execute for owner and group
      rwxrwxrwx            File - read, write, & execute for owner, group and others
      --x--x--x            File - execute
      -w--w--w-            File - write
      -wx-wx-wx            File - write & execute
      r--r--r--            File - read
      r-xr-xr-x            File - read & execute
      rw-rw-rw-            File - read & write
      rwxr-----            File - Owner can read, write, & execute. Group can only read;

Note: drwxrwxrwx - identifies permissions for directory
                   value = 020000000777

------------------------------------------------------------------------

Warning:

Incorrect or invalid File Permissions can cause extensive damage. If you don't know what you are doing, you would be well advised to use one of the other methods in this type which provide additional safeguards.

If you decide to proceed, be guided by the wisdom of Davy Crockett:

"Be always sure you are right - then go ahead."

func (*FilePermissionConfig) SetFileModeByOctalDigits

func (fPerm *FilePermissionConfig) SetFileModeByOctalDigits(octalFileModeCode int) error

SetFileModeByOctalDigits - Sets the value of the current FilePermissionConfig instance by initializing the internal FileMode data field (FilePermissionConfig.fileMode) to the value represented by input parameter, 'octalFileModeCode'. Any previous internal FileMode value is overwritten.

------------------------------------------------------------------------

Input Parameter:

octalFileModeCode int - This parameter contains the integer value of the
                        of the permission code which will be used to
                        initialize the current FilePermissionConfig instance
                        (FilePermissionConfig.fileMode). The integer digits
                        in 'octalFileModeCode' represent the octal value
                        for the file permission as indicated by the following
                        examples.
 ____________________________________________________________________________

          Input Parameter
              integer            Equivalent
 Octal    'octalFileModeCode'    Symbolic      File Access
 Digits        value             Notation      Permission Descriptions
 0000 	         0               ----------    File - no permissions
 0700 	       700               -rwx------    File - read, write, & execute only for owner
 0770 	       770               -rwxrwx---    File - read, write, & execute for owner and group
 0777 	       777               -rwxrwxrwx    File - read, write, & execute for owner, group and others
 0111 	       111               ---x--x--x    File - execute
 0222 	       222               --w--w--w-    File - write
 0333 	       333               --wx-wx-wx    File - write & execute
 0444 	       444               -r--r--r--    File - read
 0555 	       555               -r-xr-xr-x    File - read & execute
 0666 	       666               -rw-rw-rw-    File - read & write
 0740 	       740               -rwxr-----    File - Owner can read, write, & execute. Group can only read;
                                                      others have no permissions

 20000000777   20000000777       drwxrwxrwx    Directory - read, write, & execute for owner, group and others

 See method FilePermissionConfig.SetFileModeByTextCode() for more documentation

------------------------------------------------------------------------

Warning:

In the Go Programming Language, if you initialize an integer with a leading zero (e.g. x:= int(0777)), than number ('0777') is treated as an octal value and converted to a decimal value. Therefore, x:= int(0777) will mean that 'x' is set equal to 511. If you set x:= int(777), x will be set equal to '777'. For purposes of this method enter the octal code as x:= int(777).

------------------------------------------------------------------------

Return Value:

error - If the input parameter 'octalFileModeCode' contains an invalid Entry Type,
        an error will be returned.

        Entry Types prefixes all os File Mode Codes used for permissions. Valid
        Entry Types must include a valid os 'Mode Constant' as a code prefix.
        Valid os mode constants are provided by the the OsFilePermissionCode
        Type which is an enumeration of valid os mode constants.

func (*FilePermissionConfig) SetFileModeByTextCode

func (fPerm *FilePermissionConfig) SetFileModeByTextCode(modeStr string) error

SetFileModeByTextCode - Sets the internal FileMode data field using input parameter 'modeStr'. 'modeStr' is a 10-character string containing the read, write and execute permissions for the the three groups, 'Owner/User', 'Group' and 'Other'.

The text codes used in the 'modeStr' mimic the Unix permission codes.

Reference:
  https://www.cyberciti.biz/faq/explain-the-nine-permissions-bits-on-files/.
  https://en.wikipedia.org/wiki/File_system_permissions

The first character of the 'modeStr' designates the 'Entry Type'. Currently, only two 'Entry Type' characters are supported. Therefore, the first character in 'modeStr' must consist of a hyphen ("-") designating a file, or a "d" designating a directory.

The remaining nine characters in the 'modeStr' are styled as unix permission bits. These nine characters are divided into three group fields each containing 3-permission characters. Each character field may be populated with a 'r' (Read-Permission), 'w' (Write-Permission), 'x' (Execute-Permission) or '-' signaling no permission or no access allowed. A typical 'modeStr' authorizing permission for full access to a file would be styled as:

"-rwxrwxrwx"

Groups: - Owner, Group, Other
From left to right

Char index 0     = Entry Type. Must be either a "-" or a "d"
Char indexes 4-6 = Group  "rwx"  Authorizing 'Read', 'Write' & Execute Permissions for 'Group'
Char indexes 1-3 = Owner  "rwx"  Authorizing 'Read', 'Write' & Execute Permissions for 'Owner'
Char indexes 7-9 = Other  "rwx"  Authorizing 'Read', 'Write' & Execute Permissions for 'Other'

The Symbolic notation provided by input parameter 'modeStr' MUST conform to the options presented below. The first character or 'Entry Type' is listed as "-". However, in practice, the caller may set the first character as either a "-", specifying a file, or a "d", specifying a directory. No other first character types are currently supported.

After the first character, the remaining 9-characters are constituents of the the three Symbolic Groups: Owners/Users, Groups & Others. Each group has three characters which may be 'r', 'w', 'x'. If a permission is not set, the character position contains a '-'.

'modeStr'
Symbolic    Octal           File Access
Notation    Notation        Permission Descriptions
----------   0000           File - no permissions
-rwx------   0700           File - read, write, & execute only for owner
-rwxrwx---   0770           File - read, write, & execute for owner and group
-rwxrwxrwx   0777           File - read, write, & execute for owner, group and others
---x--x--x   0111           File - execute
--w--w--w-   0222           File - write only
--wx-wx-wx   0333           File - write & execute
-r--r--r--   0444           File - read only
-r-xr-xr-x   0555           File - read & execute
-rw-rw-rw-   0666           File - read & write
-rwxr-----   0740           File - Owner can read, write, & execute. Group can only read;
                            File - others have no permissions
drwxrwxrwx   20000000777    File - Directory - read, write, & execute for owner, group and others

------------------------------------------------------------------------

Input Parameter:

modeStr  string - 'modeStr' must conform to the symbolic notation options shown
                  above. Failure to comply with this requirement will generate an
                  error. As indicated, 'modeStr' must consist of 10-characters.
                  The first character in 'modeStr' may be '-' specifying a fle or
                  'd' specifying a directory.

Reference:
How to use special permissions: the setuid, setgid and sticky bits
https://linuxconfig.org/how-to-use-special-permissions-the-setuid-setgid-and-sticky-bits

type FileSelectCriterionMode

type FileSelectCriterionMode int

FileSelectCriterionMode - An enumeration which serves as parameters for file selection methods. File Selection criteria can either be And'ed or Or'ed together. The FileSelectionCriteriaMode determines which operation will be applied to file selection criteria.

                  File Select
 Method          Criterion Mode
  Name               Constant       Description
______________________________________________________________________
None()                  0           Signals that no selection is present.
                                    Same as NOOP or No Selection Criterion

ANDSelect()             1           File Selection Criterion are And'ed together.
                                    If there are three file selection criterion then
                                    all three must be satisfied before a file is
                                    selected.

ORSelect()              2           File Selection Criterion are Or'd together.
                                    If there are three file selection criterion
                                    then satisfying any one of the three criterion
                                    will cause the file to be selected.

'FileSelectCriterionMode' has been adapted to function as an enumeration describing the application of criteria used to select files. Since Go does not directly support enumerations, the 'FileSelectCriterionMode' type has been configured to function in a manner similar to classic enumerations found in other languages like C#. For additional information, reference:

Jeffrey Richter Using Reflection to implement enumerated types
       https://www.youtube.com/watch?v=DyXJy_0v0_U
var FileSelectMode FileSelectCriterionMode

PathValidStatus - public global variable of type FileSelectCriterionMode.

This variable serves as an easier, short hand technique for accessing FileSelectCriterionMode values.

Usage:

FileSelectMode.None()
FileSelectMode.ANDSelect()
FileSelectMode.ORSelect()

func (FileSelectCriterionMode) ANDSelect

ANDSelect - File Selection Criterion are And'ed together. If there are three file selection criterion then all three must be satisfied before a file is selected.

This method is part of the standard enumeration.

func (FileSelectCriterionMode) None

None - Signals that no selection is present. Same as NOOP or No Selection Criterion

This method is part of the standard enumeration.

func (FileSelectCriterionMode) ORSelect

ORSelect() - File Selection Criterion are Or'd together. If there are three file selection criterion then satisfying any one of the three criterion will cause the file to be selected. FileSelectMode.ORSelect()

This method is part of the standard enumeration.

func (FileSelectCriterionMode) ParseString

func (fSel FileSelectCriterionMode) ParseString(
	valueString string,
	caseSensitive bool) (FileSelectCriterionMode, error)

ParseString - Receives a string and attempts to match it with the string value of a supported enumeration. If successful, a new instance of FileSelectCriterionMode is returned set to the value of the associated enumeration.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Input Parameters

valueString   string - A string which will be matched against the
                       enumeration string values. If 'valueString'
                       is equal to one of the enumeration names, this
                       method will proceed to successful completion

caseSensitive   bool - If 'true' the search for enumeration names
                       will be case sensitive and will require an
                       exact match. Therefore, 'movesourcefiletodestination' will NOT
                       match the enumeration name, 'MoveSourceFileToDestinationFile'.

                       If 'false' a case insensitive search is conducted
                       for the enumeration name. In this case, 'movesourcefiletodestination'
                       will match match enumeration name 'MoveSourceFileToDestinationFile'.

------------------------------------------------------------------------

Return Values

FileSelectCriterionMode - Upon successful completion, this method will return a new
                          instance of FileSelectCriterionMode set to the value of the
                          enumeration matched by the string search performed on input
                          parameter, 'valueString'.

error                   - If this method completes successfully, the returned error
                          Type is set equal to 'nil'. If an error condition is encountered,
                          this method will return an error Type which encapsulates an
                          appropriate error message.

------------------------------------------------------------------------

Usage

 t, err := FileSelectCriterionMode(0).ParseString("MoveSourceFileToDestinationFile", true)
                                      Or
 t, err := FileSelectCriterionMode(0).ParseString("movesourcefiletodestination", false)

 For all of the cases shown above,
	    t is now equal to FileSelectCriterionMode(0).MoveSourceFileToDestinationFile()

func (FileSelectCriterionMode) StatusIsValid

func (fSel FileSelectCriterionMode) StatusIsValid() error

StatusIsValid - If the value of the current FileSelectCriterionMode is 'invalid', this method will return an error. If the FileSelectCriterionMode is 'valid', this method will return a value of 'nil'.

This is a standard utility method and is not part of the valid enumerations for this type.

func (FileSelectCriterionMode) String

func (fSel FileSelectCriterionMode) String() string

String - Returns a string with the name of the enumeration associated with this instance of 'FileSelectCriterionMode'. This is a standard utility method and is not part of the valid enumerations for this type.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Return Value:

string - The string label or description for the current enumeration
         value. If, the FileSelectCriterionMode value is invalid,
         this method will return an empty string.

------------------------------------------------------------------------

Usage

t:= FileSelectCriterionMode(0).ORSelect()
str := t.String()
    str is now equal to 'ORSelect'

func (FileSelectCriterionMode) Value

Value - This is a utility method which is not part of the enumerations supported by this type. It returns the numeric value of the enumeration associated with the current FileSelectCriterionMode instance.

This is a standard utility method and is not part of the valid enumerations for this type.

type FileSelectionCriteria

type FileSelectionCriteria struct {
	// FileNamePatterns - a string array containing one or more file matching
	// patterns. Example '*.txt' '*.log' 'common*.*'
	FileNamePatterns []string

	// FilesOlderThan - Used to select files with a modification less than this date time
	FilesOlderThan time.Time

	// FilesNewerThan - // Used to select files with a modification greater than this date time
	FilesNewerThan time.Time

	// SelectByFileMode - Used to select files with equivalent os.FileMode values.
	// To select by File Mode, set the FilePermissionCfg type to the desired value
	//  Examples:
	//    fsc := FileSelectionCriteria{}
	//
	//    err = fsc.SelectByFileMode.SetByFileMode(os.FileMode(0666))
	//    err = fsc.SelectByFileMode.SetFileModeByTextCode("-r--r--r--")
	//
	// Note: os.FileMode is an uint32 type.
	SelectByFileMode FilePermissionConfig

	// SelectCriterionMode - Can be one of three values:
	//
	// FileSelectMode.None()      = No Operation - No File Select Criterion
	//                                   mode selected
	//
	// FileSelectMode.ANDSelect() = select a file only if ALL
	//                                   the selection criterion are satisfied.
	//
	// FileSelectMode.ORSelect()  = select a file if only ONE
	//                                   of the selection criterion are satisfied.
	//
	// SEE TYPE 'FileSelectCriterionMode'
	SelectCriterionMode FileSelectCriterionMode
}

FileSelectionCriteria - Used is selecting file names. These data fields specify the criterion used to determine if a file should be selected for some type of operation. Example: find files or delete files operations

func (*FileSelectionCriteria) ArePatternsActive

func (fsc *FileSelectionCriteria) ArePatternsActive() bool

ArePatternsActive - surveys the FileNamePatterns string array to determine if there currently any active search file pattern string.

A search file pattern is considered active if the string length of the pattern string is greater than zero.

type GlobalPathFileOpsSys

type GlobalPathFileOpsSys struct {
	Input  string
	Output string
}

func (GlobalPathFileOpsSys) GetArchitecture

func (pfoSys GlobalPathFileOpsSys) GetArchitecture() string

GetArchitecture - Returns a string describing the current architecture under which this package is running.

This method returns the value of the go system variable GOARCH Reference

https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63

Current GOARCH architecture values as of go version 1.8:

386
amd64
amd64p32
arm
armbe
arm64
arm64be
ppc64
ppc64le
mips
mipsle
mips64
mips64le
mips64p32
mips64p32le
ppc
s390
s390x
sparc
sparc64

func (GlobalPathFileOpsSys) GetOperatingSystem

func (pfoSys GlobalPathFileOpsSys) GetOperatingSystem() string

GetOperatingSystem - Returns a string describing the operating system under which this package is executing.

This method returns the value of the go system variable GOOS Reference

https://gist.github.com/asukakenji/f15ba7e588ac42795f421b48b8aede63

Current GOOS operating system values as of go version 1.8:

android
darwin
dragonfly
freebsd
linux
nacl
netbsd
openbsd
plan9
solaris
windows
zos

func (GlobalPathFileOpsSys) IsLinuxOperatingSystem

func (pfoSys GlobalPathFileOpsSys) IsLinuxOperatingSystem() bool

IsLinuxOperatingSystem - Returns a boolean value indicating whether the current operating system under which the 'pathfileops' package is running is 'windows'

func (GlobalPathFileOpsSys) IsWindowsOperatingSystem

func (pfoSys GlobalPathFileOpsSys) IsWindowsOperatingSystem() bool

IsWindowsOperatingSystem - Returns a boolean value indicating whether the current operating system under which the 'pathfileops' package is running is 'windows'

type OsFilePermissionCode

type OsFilePermissionCode os.FileMode

OsFilePermissionCode - An enumeration of the os File Mode constant values:

 Method           os.FileMode           Associated
  Name             Constant             Letter Code
______________________________________________________________________
ModeNone()        os.ModeNone           "-" is a file
ModeDir()         os.ModeDir            "d" is a directory
ModeAppend()      os.ModeAppend         "a" append-only
ModeExclusive()   os.ModeExclusive      "l" exclusive use
ModeTemporary()   os.ModeTemporary      "T" temporary file; Plan 9 only
ModeSymlink()     os.ModeSymlink        "L" symbolic link
ModeDevice()      os.ModeDevice         "D" device file
ModeNamedPipe()   os.ModeNamedPipe      "p" named pipe (FIFO)
ModeSocket()      os.ModeSocket         "S" Unix domain socket
ModeSetuid()      os.ModeSetuid         "u" setuid
ModeSetgid()      os.ModeSetgid         "g" setgid
ModeCharDevice()  os.ModeCharDevice     "c" Unix character device, when ModeDevice is set
ModeSticky()      os.ModeSticky         "t" sticky
ModeIrregular()   os.ModeIrregular      "?" non-regular file; nothing else is known about this file

For more information on os Mode Constants Reference: https://golang.org/pkg/os/#pkg-constants

OsFilePermissionCode has been adapted to function as an enumeration of valid File Permission Code values. Since Go does not directly support enumerations, the 'OsFilePermissionCode' type has been configured to function in a manner similar to classic enumerations found in other languages like C#. For additional information, reference:

Jeffrey Richter Using Reflection to implement enumerated types
       https://www.youtube.com/watch?v=DyXJy_0v0_U

func (OsFilePermissionCode) Equal

func (osPerm OsFilePermissionCode) Equal(osPerm2 OsFilePermissionCode) bool

Equal - Compares the current OsFilePermissionCode instance to another OsFilePermission instance passed as an input parameter. If the two are equal in all respects, this method returns 'true'.

func (OsFilePermissionCode) GetFileModeLetterCode

func (osPerm OsFilePermissionCode) GetFileModeLetterCode() (string, error)

GetFileModeLetterCode - Returns the single alphabetic character associated with this os.FileMode. All os.FileMode's are associated with a single letter used in unix permission strings.

                     Letter
File Mode             Code     Description
__________________________________________
os.ModeNone           "-"      is a file
os.ModeDir            "d"      is a directory
os.ModeAppend         "a"      append-only
os.ModeExclusive      "l"      exclusive use
os.ModeTemporary      "T"      temporary file; Plan 9 only
os.ModeSymlink        "L"      symbolic link
os.ModeDevice         "D"      device file
os.ModeNamedPipe      "p"      named pipe (FIFO)
os.ModeSocket         "S"      Unix domain socket
os.ModeSetuid         "u"      setuid
os.ModeSetgid         "g"      setgid
os.ModeCharDevice     "c"      Unix character device, when ModeDevice is set
os.ModeSticky         "t"      sticky
os.ModeIrregular      "?"      non-regular file; nothing else is known about this file

func (OsFilePermissionCode) GetNewFromFileMode

func (osPerm OsFilePermissionCode) GetNewFromFileMode(
	fMode os.FileMode) (OsFilePermissionCode, error)

GetNewFromFileMode - Creates and returns a new OsFilePermissionCode instance generated from the os.FileMode type input parameter ('fMode'). If the input os.FileMode value is invalid, an error is returned.

func (OsFilePermissionCode) GetNewFromLetterCode

func (osPerm OsFilePermissionCode) GetNewFromLetterCode(
	letterCode string) (OsFilePermissionCode, error)

GetNewFromLetterCode - Creates a new OsFilePermissionCode instance based on an associated 'letter code'. The letter code consists of a single character representing an os.FileMode. This single character is useful in configuring unix permission strings.

func (OsFilePermissionCode) IsValid

func (osPerm OsFilePermissionCode) IsValid() error

IsValid - If the value of the current OsFilePermissionCode instance is 'invalid', this method will return an error.

If the OsFilePermissionCode instance is 'valid', this method will return a value of 'nil'.

This is a standard utility method and is not part of the valid enumerations for this type.

func (OsFilePermissionCode) ModeAppend

func (osPerm OsFilePermissionCode) ModeAppend() os.FileMode

ModeAppend Letter Code= "a" append-only - alias for os.ModeAppend

func (OsFilePermissionCode) ModeCharDevice

func (osPerm OsFilePermissionCode) ModeCharDevice() os.FileMode

ModeCharDevice Letter Code= "c" Unix character device, when ModeDevice is set alias for os.ModeCharDevice

func (OsFilePermissionCode) ModeDevice

func (osPerm OsFilePermissionCode) ModeDevice() os.FileMode

ModeDevice Letter Code= "D" device file - alias for os.ModeDevice

func (OsFilePermissionCode) ModeDir

func (osPerm OsFilePermissionCode) ModeDir() os.FileMode

ModeDir Letter Code= "d" is a directory - alias for os.ModeDir

func (OsFilePermissionCode) ModeExclusive

func (osPerm OsFilePermissionCode) ModeExclusive() os.FileMode

ModeExclusive Letter Code= "l" exclusive use - alias for os.ModeExclusive

func (OsFilePermissionCode) ModeIrregular

func (osPerm OsFilePermissionCode) ModeIrregular() os.FileMode

ModeIrregular Letter Code= "?" non-regular file; nothing else is known about this file alias for os.ModeIrregular

func (OsFilePermissionCode) ModeNamedPipe

func (osPerm OsFilePermissionCode) ModeNamedPipe() os.FileMode

ModeNamedPipe Letter Code= "p" named pipe (FIFO) - alias for os.ModeNamedPipe

func (OsFilePermissionCode) ModeNone

func (osPerm OsFilePermissionCode) ModeNone() os.FileMode

ModeNone "-" No Permission Set The is no os constant for 'None'. However since the zero value is used extensively to identity a 'file' within the context of permission descriptions, it is added here. 'ModeNone' therefore represents both a zero value and the 'file' designation.

func (OsFilePermissionCode) ModeSetgid

func (osPerm OsFilePermissionCode) ModeSetgid() os.FileMode

ModeSetgid Letter Code= "g" setgid - alias for os.ModeSetgid Unlike the setuid bit, the setgid bit has effect on both files and directories. In the first case, the file which has the setgid bit set, when executed, instead of running with the privileges of the group of the user who started it, runs with those of the group which owns the file: in other words, the group ID of the process will be the same of that of the file.

When used on a directory, instead, the setgid bit alters the standard behavior so that the group of the files created inside said directory, will not be that of the user who created them, but that of the parent directory itself. This is often used to ease the sharing of files (files will be modifiable by all the users that are part of said group).

func (OsFilePermissionCode) ModeSetuid

func (osPerm OsFilePermissionCode) ModeSetuid() os.FileMode

ModeSetuid Letter Code= "u" setuid - alias for os.ModeSetuid When the setuid bit is used, the behavior described above it's modified so that when an executable is launched, it does not run with the privileges of the user who launched it, but with that of the file owner instead. So, for example, if an executable has the setuid bit set on it, and it's owned by root, when launched by a normal user, it will run with root privileges. It should be clear why this represents a potential security risk, if not used correctly.

func (OsFilePermissionCode) ModeSocket

func (osPerm OsFilePermissionCode) ModeSocket() os.FileMode

ModeSocket Letter Code= "S" Unix domain socket - alias for os.ModeSocket

func (OsFilePermissionCode) ModeSticky

func (osPerm OsFilePermissionCode) ModeSticky() os.FileMode

ModeSticky Letter Code= "t" sticky - alias for os.ModeSticky The sticky bit works in a different way: while it has no effect on files, when used on a directory, all the files in said directory will be modifiable only by their owners. A typical case in which it is used, involves the /tmp directory. Typically this directory is writable by all users on the system, so to make impossible for one user to delete the files of another one.

func (osPerm OsFilePermissionCode) ModeSymlink() os.FileMode

ModeSymlink Letter Code= "L" symbolic link - alias for os.ModeSymlink

func (OsFilePermissionCode) ModeTemporary

func (osPerm OsFilePermissionCode) ModeTemporary() os.FileMode

ModeTemporary Letter Code= "T" temporary file; Plan 9 only - alias for os.ModeTemporary

func (OsFilePermissionCode) ParseString

func (osPerm OsFilePermissionCode) ParseString(
	valueString string,
	caseSensitive bool) (OsFilePermissionCode, error)

ParseString - Receives a string and attempts to match it with the string value of a supported enumeration. If successful, a new instance of OsFilePermissionCode is returned set to the value of the associated enumeration.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Input Parameters:

valueString   string - A string which will be matched against the
                       enumeration string values. If 'valueString'
                       is equal to one of the enumeration names, this
                       method will proceed to successful completion

caseSensitive   bool - If 'true' the search for enumeration names
                       will be case sensitive and will require an
                       exact match. Therefore, 'modedir' will NOT
                       match the enumeration name, 'ModeDir'.

                       If 'false' a case insensitive search is conducted
                       for the enumeration name. In this case, 'modedir'
                       will match match enumeration name 'ModeDir'.

------------------------------------------------------------------------

Return Values:

OsFilePermissionCode - Upon successful completion, this method will return a new
                       instance of OsFilePermissionCode set to the value of the
                       enumeration matched by the string search performed on
                       input parameter,'valueString'.

error                - If this method completes successfully, the returned error
                       Type is set equal to 'nil'. If an error condition is encountered,
                       this method will return an error Type which encapsulates an
                       appropriate error message.

------------------------------------------------------------------------

Usage:

	t, err := OsFilePermissionCode(0).ParseString("ModeDir", true)
                           OR
	t, err := OsFilePermissionCode(0).ParseString("ModeDir()", true)
                           OR
	t, err := OsFilePermissionCode(0).ParseString("Dir()", true)
                           OR
	t, err := OsFilePermissionCode(0).ParseString("Dir", true)
                           OR
	t, err := OsFilePermissionCode(0).ParseString("modedir", false)

	For all of the cases shown above,
 t is now equal to OsFilePermissionCode(0).ModeDir()

func (OsFilePermissionCode) String

func (osPerm OsFilePermissionCode) String() string

String - Returns a string with the name of the enumeration associated with this instance of 'OsFilePermissionCode'.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Return Value:

string - The string label or description for the current enumeration
         value. If, the OsFilePermissionCode value is invalid, this
         method will return an empty string.

------------------------------------------------------------------------

Usage

t:= OsFilePermissionCode(0).ModeDir()
str := t.String()
    str is now equal to "ModeDir"

func (OsFilePermissionCode) Value

func (osPerm OsFilePermissionCode) Value() os.FileMode

Value - Returns the value of the OsFilePermissionCode instance as type os.FileMode.

This is a standard utility method and is not part of the valid enumerations for this type.

type PathExistsStatusCode

type PathExistsStatusCode int

PathExistsStatusCode - This type is an enumeration of file path existence status codes. These status codes describe the state of a file or directory on disk. The existence of a path or directory is usually determined by the method os.Stat() which establishes whether or not a file or directory currently exists on disk.

                  Path Existence
 Method            Status Code
  Name               Constant       Description
______________________________________________________________________
Unknown()              -1           Path file existence has NOT been
                                      tested and status is 'Unknown'.

DoesNotExist()          0           Path file existence HAS been tested
                                      and path file name does NOT exist on
                                      disk.

Exists()               +1           Path file existence HAD been tested
                                      and path file name DOES exist on
                                      disk.

PathExistsStatusCode has been adapted to function as an enumeration of valid Path Existence Status Code values. Since Go does not directly support enumerations, the 'PathExistsStatusCode' type has been configured to function in a manner similar to classic enumerations found in other languages like C#. For additional information, reference:

Jeffrey Richter Using Reflection to implement enumerated types
       https://www.youtube.com/watch?v=DyXJy_0v0_U
var PathExistsStatus PathExistsStatusCode

PathExistsStatus - public global variable of type 'PathExistsStatusCode'.

This variable serves as an easier, short hand technique for accessing PathExistsStatusCode values.

Usage:

PathExistsStatus.Unknown()
PathExistsStatus.Invalid()
PathExistsStatus.Valid()

func (PathExistsStatusCode) DoesNotExist

func (pathExist PathExistsStatusCode) DoesNotExist() PathExistsStatusCode

DoesNotExist - This Path Existence Status code signals that the test for existence on disk HAS been performed and that the subject file or directory DOES NOT EXIST on disk.

func (PathExistsStatusCode) Exists

func (pathExist PathExistsStatusCode) Exists() PathExistsStatusCode

Exists - This Path Existence Status code signals that the test for existence on disk HAS been performed and that the subject file or directory DOES EXIST on disk.

func (PathExistsStatusCode) ParseString

func (pathExist PathExistsStatusCode) ParseString(
	valueString string, caseSensitive bool) (PathExistsStatusCode, error)

ParseString - Receives a string and attempts to match it with the string value of the supported enumeration. If successful, a new instance of PathExistsStatusCode is returned set to the value of the associated enumeration.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Input Parameters:

valueString   string - A string which will be matched against the
                       enumeration string values. If 'valueString'
                       is equal to one of the enumeration names, this
                       method will proceed to successful completion

caseSensitive   bool - If 'true' the search for enumeration names
                       will be case sensitive and will require an
                       exact match. Therefore, 'exists' will NOT
                       match the enumeration name, 'Exists'.

                       If 'false' a case insensitive search is conducted
                       for the enumeration name. In this case, 'exists'
                       will match match enumeration name 'Exists'.

------------------------------------------------------------------------

Return Values:

PathExistsStatusCode - Upon successful completion, this method will return a new
                       instance of PathExistsStatusCode set to the value of the
                       enumeration matched by the string search performed on
                       input parameter,'valueString'.

error                - If this method completes successfully, the returned error
                       Type is set equal to 'nil'. If an error condition is encountered,
                       this method will return an error Type which encapsulates an
                       appropriate error message.

------------------------------------------------------------------------

Usage:

	t, err := PathExistsStatusCode(0).ParseString("Exists", true)
                           OR
	t, err := PathExistsStatusCode(0).ParseString("Exists()", true)
                           OR
	t, err := PathExistsStatusCode(0).ParseString("exists", false)

	For all of the cases shown above,
 t is now equal to PathExistsStatusCode(0).Exists()

func (PathExistsStatusCode) StatusCodesEqual

func (pathExist PathExistsStatusCode) StatusCodesEqual(statusCode PathExistsStatusCode) bool

StatusCodesEqual - Compares the current PathExistsStatusCode instance to another PathExistsStatusCode instance passed as an input parameter. If the two are equal in all respects, this method returns 'true'. Otherwise, this method returns 'false'.

func (PathExistsStatusCode) StatusIsValid

func (pathExist PathExistsStatusCode) StatusIsValid() error

StatusIsValid - If the value of the current PathExistsStatusCode instance is 'invalid', this method will return an error.

If the PathExistsStatusCode is instance is 'valid', this method will return a value of 'nil'.

This is a standard utility method and is not part of the valid enumerations for this type.

func (PathExistsStatusCode) String

func (pathExist PathExistsStatusCode) String() string

String - Returns a string with the name of the enumeration associated with this instance of 'PathExistsStatusCode'.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Return Value:

string - The string label or description for the current enumeration
         value. If, the PathExistsStatusCode value is invalid, this
         method will return an empty string.

------------------------------------------------------------------------

Usage

t:= PathExistsStatusCode(0).DoesNotExist()
str := t.String()
    str is now equal to "DoesNotExist"

func (PathExistsStatusCode) Unknown

func (pathExist PathExistsStatusCode) Unknown() PathExistsStatusCode

Unknown - This file path status code signals that the existence of the file or directory on disk has not yet been established. That is, the test for existence has not yet been performed.

func (PathExistsStatusCode) Value

func (pathExist PathExistsStatusCode) Value() PathExistsStatusCode

Value - Returns the value of the PathExistsStatusCode instance as type PathExistsStatusCode.

This is a standard utility method and is not part of the valid enumerations for this type.

type PathFileTypeCode

type PathFileTypeCode int

PathFileTypeCode - This type is an enumeration describing the status of a path or path/file name.

                    Path File
 Method             Type Code
  Name              Constant        Description
______________________________________________________________________
None()                  0           Path/file name type has NOT been
                                      tested and its status not known.

Path()                  1           Tests have established that the
                                      Path/file name string is a
                                      directory path which does NOT
                                      contain a file name.

PathFile()              2           Tests have established that the
                                      Path/file name string includes
                                      both a directory path AND a file
                                      name.

File()                  3           Tests have established that the
                                      Path/file name string consists
                                      solely of a file name and does
                                      NOT include a directory path.

Volume()                4           Tests have established that the
                                      Path/file name string consists
                                      solely of a volume name and does
                                      NOT include a directory path or
                                      file name.

Indeterminate()         5           Tests have been conducted on the
                                      Path/file name string, but the
                                      string cannot be classified and
                                      its status cannot be determined
                                      with certainty.

'PathFileTypeCode' has been adapted to function as an enumeration describing the type of a path/file name string. Since Go does not directly support enumerations, the 'PathFileTypeCode' type has been configured to function in a manner similar to classic enumerations found in other languages like C#. For additional information, reference:

Jeffrey Richter Using Reflection to implement enumerated types
       https://www.youtube.com/watch?v=DyXJy_0v0_U
var PathFileType PathFileTypeCode

PathFileType - public global variable of type PathFileTypeCode.

This variable serves as an easier, short hand technique for accessing PathFileTypeCode values.

Usage:

PathFileTypeCode.None()
PathFileTypeCode.Path()
PathFileTypeCode.File()
PathFileTypeCode.Volume()
PathFileTypeCode.Indeterminate()

func (PathFileTypeCode) File

func (pfTyp PathFileTypeCode) File() PathFileTypeCode

File - This code signals that the subject path string consists only of a file name and does NOT include a directory path.

This method is part of the standard enumeration.

func (PathFileTypeCode) Indeterminate

func (pfTyp PathFileTypeCode) Indeterminate() PathFileTypeCode

Indeterminate - This code signals that after tests, the status of the subject path string cannot be established. This code covers edge cases where it cannot be determined whether the string is a Path and File or a directory path.

This method is part of the standard enumeration.

func (PathFileTypeCode) None

func (pfTyp PathFileTypeCode) None() PathFileTypeCode

None - 'None' signals that the PathFileTypeCode has not been set or initialized.

This method is part of the standard enumeration.

func (PathFileTypeCode) ParseString

func (pfTyp PathFileTypeCode) ParseString(
	valueString string,
	caseSensitive bool) (PathFileTypeCode, error)

ParseString - Receives a string and attempts to match it with the string value of the supported enumeration. If successful, a new instance of PathFileTypeCode is returned set to the value of the associated enumeration.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Input Parameters:

valueString   string - A string which will be matched against the
                       enumeration string values. If 'valueString'
                       is equal to one of the enumeration names, this
                       method will proceed to successful completion

caseSensitive   bool - If 'true' the search for enumeration names
                       will be case sensitive and will require an
                       exact match. Therefore, 'valid' will NOT
                       match the enumeration name, 'Valid'.

                       If 'false' a case insensitive search is
                       conducted for the enumeration name. In
                       this case, 'valid' will match the
                       enumeration name 'Valid'.

------------------------------------------------------------------------

Return Values:

PathFileTypeCode    - Upon successful completion, this method will return a new
                      instance of PathExistsStatusCode set to the value of the
                      enumeration matched by the string search performed on
                      input parameter,'valueString'.

error               - If this method completes successfully, the returned error
                      Type is set equal to 'nil'. If an error condition is encountered,
                      this method will return an error Type which encapsulates an
                      appropriate error message.

------------------------------------------------------------------------

Usage:

	t, err := PathFileTypeCode(0).ParseString("File", true)
                           OR
	t, err := PathValidityStatusCode(0).ParseString("File()", true)
                           OR
	t, err := PathValidityStatusCode(0).ParseString("file", false)

	For all of the cases shown above,
 t is now equal to PathValidityStatusCode(0).File()

func (PathFileTypeCode) Path

func (pfTyp PathFileTypeCode) Path() PathFileTypeCode

Path - This code signals that the subject path string has been classified as a directory path.

This method is part of the standard enumeration.

func (PathFileTypeCode) PathFile

func (pfTyp PathFileTypeCode) PathFile() PathFileTypeCode

PathFile - This code signals that subject path string has been classified as a file path meaning that the path string consists of both a directory path and a file name.

This method is part of the standard enumeration.

func (PathFileTypeCode) StatusValue

func (pfTyp PathFileTypeCode) StatusValue() PathFileTypeCode

StatusValue - Returns the value of the PathFileTypeCode instance as type PathFileTypeCode.

This is a standard utility method and is not part of the valid enumerations for this type.

func (PathFileTypeCode) String

func (pfTyp PathFileTypeCode) String() string

String - Returns a string with the name of the enumeration associated with this instance of 'PathFileTypeCode'.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Return Value:

string - The string label or description for the current enumeration
         value. If, the PathFileTypeCode value is invalid, this
         method will return an empty string.

------------------------------------------------------------------------

Usage

t:= PathFileTypeCode(0).PathFile()
str := t.String()
    str is now equal to "PathFile"

func (PathFileTypeCode) Volume

func (pfTyp PathFileTypeCode) Volume() PathFileTypeCode

Volume - The code signals that the entire path string consists solely of a volume and does NOT include a directory path or file name.

This method is part of the standard enumeration.

type PathValidityStatusCode

type PathValidityStatusCode int

PathValidityStatusCode - This type is an enumeration describing the validity of a path or path/file name.

                  Path Validity
 Method            Status Code
  Name               Constant       Description
______________________________________________________________________
Unknown()              -1           Path/file name validity has NOT been
                                      tested and its status as 'Valid' or
                                      'invalid' is 'Unknown'.

Invalid()               0           Tests have verified that the Path/file
                                      name is 'Invalid'.

Valid()               +1            Tests have verified that the Path/file
                                      name is 'Valid'.

'PathValidityStatusCode' has been adapted to function as an enumeration describing the validity of a path/file name string. Since Go does not directly support enumerations, the 'PathValidityStatusCode' type has been configured to function in a manner similar to classic enumerations found in other languages like C#. For additional information, reference:

Jeffrey Richter Using Reflection to implement enumerated types
       https://www.youtube.com/watch?v=DyXJy_0v0_U
var PathValidStatus PathValidityStatusCode

PathValidStatus - public global variable of type PathValidityStatusCode.

This variable serves as an easier, short hand technique for accessing PathValidityStatusCode values.

Usage:

PathValidStatus.Unknown()
PathValidStatus.Invalid()
PathValidStatus.Valid()

func (PathValidityStatusCode) Invalid

func (pathValid PathValidityStatusCode) Invalid() PathValidityStatusCode

Invalid - This status code signals that a validity test was performed on the subject file/directory path string and it was found to be 'Invalid'.

This method is part of the standard enumeration.

func (PathValidityStatusCode) ParseString

func (pathValid PathValidityStatusCode) ParseString(
	valueString string, caseSensitive bool) (PathValidityStatusCode, error)

ParseString - Receives a string and attempts to match it with the string value of the supported enumeration. If successful, a new instance of PathValidityStatusCode is returned set to the value of the associated enumeration.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Input Parameters:

valueString   string - A string which will be matched against the
                       enumeration string values. If 'valueString'
                       is equal to one of the enumeration names, this
                       method will proceed to successful completion

caseSensitive   bool - If 'true' the search for enumeration names
                       will be case sensitive and will require an
                       exact match. Therefore, 'valid' will NOT
                       match the enumeration name, 'Valid'.

                       If 'false' a case insensitive search is
                       conducted for the enumeration name. In
                       this case, 'valid' will match the
                       enumeration name 'Valid'.

------------------------------------------------------------------------

Return Values:

PathValidityStatusCode -  Upon successful completion, this method will return a new
                          instance of PathExistsStatusCode set to the value of the
                          enumeration matched by the string search performed on
                          input parameter,'valueString'.

error                   - If this method completes successfully, the returned error
                          Type is set equal to 'nil'. If an error condition is encountered,
                          this method will return an error Type which encapsulates an
                          appropriate error message.

------------------------------------------------------------------------

Usage:

t, err := PathValidityStatusCode(0).ParseString("Valid", true)
                          OR
t, err := PathValidityStatusCode(0).ParseString("Valid()", true)
                          OR
t, err := PathValidityStatusCode(0).ParseString("valid", false)

For all of the cases shown above,
t is now equal to PathValidityStatusCode(0).Valid()

func (PathValidityStatusCode) StatusIsValid

func (pathValid PathValidityStatusCode) StatusIsValid() error

StatusIsValid - If the value of the current PathValidityStatusCode instance is 'invalid', this method will return an error.

If the PathValidityStatusCode is instance is 'valid', this method will return a value of 'nil'.

This is a standard utility method and is not part of the valid enumerations for this type.

func (PathValidityStatusCode) StatusValue

func (pathValid PathValidityStatusCode) StatusValue() PathValidityStatusCode

Value - Returns the value of the PathExistsStatusCode instance as type PathExistsStatusCode.

This is a standard utility method and is not part of the valid enumerations for this type.

func (PathValidityStatusCode) String

func (pathValid PathValidityStatusCode) String() string

String - Returns a string with the name of the enumeration associated with this instance of 'PathValidityStatusCode'.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Return Value:

string - The string label or description for the current enumeration
         value. If, the PathValidityStatusCode value is not found,
         this method will return an empty string.

------------------------------------------------------------------------

Usage

t:= PathValidityStatusCode(0).Invalid()
str := t.String()
    str is now equal to "Invalid"

func (PathValidityStatusCode) Unknown

func (pathValid PathValidityStatusCode) Unknown() PathValidityStatusCode

func (PathValidityStatusCode) Valid

Invalid - This status code signals that a validity test was performed on the subject file/directory path string and it was found to be a 'Valid' path/file name.

This method is part of the standard enumeration.

type PreProcessPathCode

type PreProcessPathCode int
var PreProcPathCode PreProcessPathCode

func (PreProcessPathCode) AbsolutePath

func (preProcPathCde PreProcessPathCode) AbsolutePath() PreProcessPathCode

AbsolutePath - Convert path string to an absolute path.

func (PreProcessPathCode) None

func (preProcPathCde PreProcessPathCode) None() PreProcessPathCode

None - Take No Action

func (PreProcessPathCode) ParseString

func (preProcPathCde PreProcessPathCode) ParseString(
	valueString string,
	caseSensitive bool) (PreProcessPathCode, error)

func (PreProcessPathCode) PathSeparator

func (preProcPathCde PreProcessPathCode) PathSeparator() PreProcessPathCode

PathSeparator - Convert path separators to the default value for the host operating system.

func (PreProcessPathCode) String

func (preProcPathCde PreProcessPathCode) String() string

String - Returns a string with the name of the enumeration associated with this instance of 'PreProcessPathCode'.

This is a standard utility method and is not part of the valid enumerations for this type.

------------------------------------------------------------------------

Return Value:

string - The string label or description for the current enumeration
         value. If, the PreProcessPathCode value is invalid, this
         method will return an empty string.

------------------------------------------------------------------------

Usage

t:= PreProcessPathCode(0).AbsolutePath()
str := t.String()
    str is now equal to "AbsolutePath"

func (PreProcessPathCode) Value

func (preProcPathCde PreProcessPathCode) Value() PreProcessPathCode

Value - Returns the value of the PathFileTypeCode instance as type PathFileTypeCode.

type SortDirMgrByAbsPathCaseInSensitive

type SortDirMgrByAbsPathCaseInSensitive []DirMgr

SortDirMgrByAbsPathCaseInSensitive - Sort by Directory Managers by absolute path. This sorting operation is performed as a 'Case Insensitive' sort meaning the upper and lower case characters are not significant. All sort comparisons are therefore made using the lower case version of the absolute path.

This method is designed to be used with the 'Go' Sort package:

https://golang.org/pkg/sort/

Example Usage:

sort.Sort(SortDirMgrByAbsPathCaseInSensitive(DirMgrArray))

func (SortDirMgrByAbsPathCaseInSensitive) Len

func (sortAbsPathInSens SortDirMgrByAbsPathCaseInSensitive) Len() int

Len - Required by the sort.Interface

func (SortDirMgrByAbsPathCaseInSensitive) Less

func (sortAbsPathInSens SortDirMgrByAbsPathCaseInSensitive) Less(i, j int) bool

Less - required by the sort.Interface

func (SortDirMgrByAbsPathCaseInSensitive) Swap

func (sortAbsPathInSens SortDirMgrByAbsPathCaseInSensitive) Swap(i, j int)

Swap - Required by the sort.Interface

type SortDirMgrByAbsPathCaseSensitive

type SortDirMgrByAbsPathCaseSensitive []DirMgr

SortDirMgrByAbsPathCaseSensitive - Sorts and array of Directory Managers (DirMgr) by absolute path. This sorting operation is performed as a 'Case Sensitive' sort meaning the upper and lower case characters are significant.

This method is designed to be used with the 'Go' Sort package:

https://golang.org/pkg/sort/

Example Usage:

sort.Sort(SortDirMgrByAbsPathCaseSensitive(DirMgrArray))

func (SortDirMgrByAbsPathCaseSensitive) Len

func (sortAbsPathSens SortDirMgrByAbsPathCaseSensitive) Len() int

Len - Required by the sort.Interface

func (SortDirMgrByAbsPathCaseSensitive) Less

func (sortAbsPathSens SortDirMgrByAbsPathCaseSensitive) Less(i, j int) bool

Less - required by the sort.Interface

func (SortDirMgrByAbsPathCaseSensitive) Swap

func (sortAbsPathSens SortDirMgrByAbsPathCaseSensitive) Swap(i, j int)

Swap - Required by the sort.Interface

type SortFileMgrByAbsPathCaseInSensitive

type SortFileMgrByAbsPathCaseInSensitive []FileMgr

SortFileMgrByAbsPathCaseInSensitive - Sort by File Managers by absolute path, filename and file extension. This sorting operation is performed as a 'Case Insensitive' sort meaning the upper and lower case characters are not significant. All sort comparisons are therefore made by using lower case versions of the absolute path, filename and file extension.

This method is designed to be used with the 'Go' Sort package:

https://golang.org/pkg/sort/

Example Usage:

sort.Sort(SortFileMgrByAbsPathCaseInSensitive(FileMgrArray))

func (SortFileMgrByAbsPathCaseInSensitive) Len

func (sortAbsPathInSens SortFileMgrByAbsPathCaseInSensitive) Len() int

Len - Required by the sort.Interface

func (SortFileMgrByAbsPathCaseInSensitive) Less

func (sortAbsPathInSens SortFileMgrByAbsPathCaseInSensitive) Less(i, j int) bool

Less - required by the sort.Interface

func (SortFileMgrByAbsPathCaseInSensitive) Swap

func (sortAbsPathInSens SortFileMgrByAbsPathCaseInSensitive) Swap(i, j int)

Swap - Required by the sort.Interface

type SortFileMgrByAbsPathCaseSensitive

type SortFileMgrByAbsPathCaseSensitive []FileMgr

SortFileMgrByAbsPathCaseSensitive - Sorts an array of File Managers (FileMgr) by absolute path, filename and file extension. This sorting operation is performed as a 'Case Sensitive' sort meaning the upper and lower case characters are significant.

This method is designed to be used with the 'Go' Sort package:

https://golang.org/pkg/sort/

Example Usage:

sort.Sort(SortFileMgrByAbsPathCaseSensitive(FileMgrArray))

func (SortFileMgrByAbsPathCaseSensitive) Len

func (sortAbsPathSens SortFileMgrByAbsPathCaseSensitive) Len() int

Len - Required by the sort.Interface

func (SortFileMgrByAbsPathCaseSensitive) Less

func (sortAbsPathSens SortFileMgrByAbsPathCaseSensitive) Less(i, j int) bool

Less - required by the sort.Interface

func (SortFileMgrByAbsPathCaseSensitive) Swap

func (sortAbsPathSens SortFileMgrByAbsPathCaseSensitive) Swap(i, j int)

Swap - Required by the sort.Interface

type ValidPathStrDto

type ValidPathStrDto struct {
	// contains filtered or unexported fields
}

ValidPathStrDto - Used to transfer file/path string attributes and associated errors.

func (*ValidPathStrDto) AbsolutePathDoesExist

func (vpDto *ValidPathStrDto) AbsolutePathDoesExist() PathExistsStatusCode

func (*ValidPathStrDto) GetAbsPath

func (vpDto *ValidPathStrDto) GetAbsPath() string

GetAbsPath - "getter" method for internal field, ValidPathStrDto.absPathStr .

func (*ValidPathStrDto) GetAbsPathFileInfo

func (vpDto *ValidPathStrDto) GetAbsPathFileInfo() FileInfoPlus

GetAbsPathFileInfo - "getter" method for internal field, ValidPathStrDto.absPathFInfoPlus .

func (*ValidPathStrDto) GetAbsPathStrLen

func (vpDto *ValidPathStrDto) GetAbsPathStrLen() int

GetAbsPathStrLen - "getter" method for internal field, ValidPathStrDto.absPathStrLength .

func (*ValidPathStrDto) GetError

func (vpDto *ValidPathStrDto) GetError() error

GetError - "getter" method for internal field, ValidPathStrDto.err . Process errors occurring during operations performed on the current ValidPathStrDto instance are recorded here.

func (*ValidPathStrDto) GetOriginalPathStr

func (vpDto *ValidPathStrDto) GetOriginalPathStr() string

GetOriginalPathStr - "getter" method for internal field, ValidPathStrDto.originalPathStr .

func (*ValidPathStrDto) GetPath

func (vpDto *ValidPathStrDto) GetPath() string

GetPath - "getter" method for internal field, ValidPathStrDto.pathStr .

func (*ValidPathStrDto) GetPathFileInfo

func (vpDto *ValidPathStrDto) GetPathFileInfo() FileInfoPlus

GetPathFileInfo - "getter" method for internal field, ValidPathStrDto.pathFInfoPlus .

func (*ValidPathStrDto) GetPathIsValid

func (vpDto *ValidPathStrDto) GetPathIsValid() PathValidityStatusCode

GetPathIsValid - "getter" method for internal field, ValidPathStrDto.pathIsValid .

                                      Int
   Enumeration Value                 Value         Definition
----------------------------------------------------------------------------
PathValidityStatusCode(0).Unknown()   -1  Path/file name validity has NOT been
                                          tested and its status as 'Valid' or
                                          'Invalid' is Unknown.

PathValidityStatusCode(0).Invalid()    0  Tests have verified that the Path/file
                                          name is 'Invalid'.

PathValidityStatusCode(0).Valid()     +1  Tests have verified that the Path/file
                                          name is 'Valid'.

func (*ValidPathStrDto) GetPathStrLen

func (vpDto *ValidPathStrDto) GetPathStrLen() int

GetPathStrLen - "getter" method for internal field, ValidPathStrDto.pathStrLength .

func (*ValidPathStrDto) GetPathType

func (vpDto *ValidPathStrDto) GetPathType() PathFileTypeCode

GetPathType - "getter" method for internal field, ValidPathStrDto.pathType .

func (*ValidPathStrDto) GetPathVolumeIndex

func (vpDto *ValidPathStrDto) GetPathVolumeIndex() int

GetPathVolumeIndex - "getter" method for internal field, ValidPathStrDto.pathVolumeIndex .

func (*ValidPathStrDto) GetPathVolumeName

func (vpDto *ValidPathStrDto) GetPathVolumeName() string

GetPathVolumeName - "getter" method for internal field, ValidPathStrDto.pathVolumeName .

func (*ValidPathStrDto) GetPathVolumeStrLength

func (vpDto *ValidPathStrDto) GetPathVolumeStrLength() int

GetPathVolumeStrLength - "getter" method for internal field, ValidPathStrDto.pathVolumeStrLength .

func (*ValidPathStrDto) IsDtoValid

func (vpDto *ValidPathStrDto) IsDtoValid(ePrefix string) error

IsDtoValid - Performs an analysis of the internal data structures for the current ValidPathStrDto instance to determine its validity.

If the current ValidPathStrDto is invalid, this method will return an error. If the instance is valid, this method will return 'nil'.

func (*ValidPathStrDto) IsInitialized

func (vpDto *ValidPathStrDto) IsInitialized() bool

IsInitialized - Returns a boolean value indicating whether the current instance of ValidPathStrDto has been initialized.

func (ValidPathStrDto) New

func (vpDto ValidPathStrDto) New() ValidPathStrDto

func (*ValidPathStrDto) PathDoesExist

func (vpDto *ValidPathStrDto) PathDoesExist() PathExistsStatusCode

PathDoesExist - Returns a boolean value indicating whether the path defined by this ValidPathStrDto instance actually exists on disk.

                                      Int
   Enumeration Value                 Value         Definition
----------------------------------------------------------------------------
PathExistsStatusCode(0).Unknown()     -1    Path file existence has NOT been
                                            tested and status is 'Unknown'.

PathExistsStatusCode(0).DoesNotExist() 0    Path file existence HAS been tested
                                            and path file name does NOT exist on
                                            disk.

PathExistsStatusCode(0).Exists()      +1    Path file existence HAD been tested
                                            and path file name DOES exist on
                                            disk.

func (*ValidPathStrDto) SetAbsPath

func (vpDto *ValidPathStrDto) SetAbsPath(absPathStr string)

SetAbsPath - "setter" method for internal data fields vpDto.absPathStr and vpDto.absPathStrLength.

func (*ValidPathStrDto) SetAbsPathDoesExistStatus

func (vpDto *ValidPathStrDto) SetAbsPathDoesExistStatus(
	absPathExistStatus PathExistsStatusCode) error

SetAbsPathDoesExistStatus - Input parameter 'absPathExistStatus' is used to set the internal field vpDto.absPathDoesExist which is of type PathExistsStatusCode.

                                      Int
   Enumeration Value                 Value         Definition
----------------------------------------------------------------------------
PathExistsStatusCode(0).Unknown()     -1    Path file existence has NOT been
                                            tested and status is 'Unknown'.

PathExistsStatusCode(0).DoesNotExist() 0    Path file existence HAS been tested
                                            and path file name does NOT exist on
                                            disk.

PathExistsStatusCode(0).Exists()      +1    Path file existence HAD been tested
                                            and path file name DOES exist on
                                            disk.

func (*ValidPathStrDto) SetAbsPathFileInfo

func (vpDto *ValidPathStrDto) SetAbsPathFileInfo(absFInfo FileInfoPlus)

SetAbsPath - "setter" method for internal data field vpDto.absPathFInfoPlus .

func (*ValidPathStrDto) SetError

func (vpDto *ValidPathStrDto) SetError(err error)

SetError - "setter" method for internal data field vpDto.err .

func (*ValidPathStrDto) SetIsInitialized

func (vpDto *ValidPathStrDto) SetIsInitialized(isInitialized bool)

SetIsInitialized - "setter" method for internal data field vpDto.isInitialized .

func (*ValidPathStrDto) SetOriginalPathStr

func (vpDto *ValidPathStrDto) SetOriginalPathStr(originalPathStr string)

SetOriginalPathStr - "setter" method for internal data field vpDto.originalPathStr .

func (*ValidPathStrDto) SetPath

func (vpDto *ValidPathStrDto) SetPath(pathStr string)

SetPath - "setter" method for internal data fields vpDto.pathStr and vpDto.pathStrLength.

func (*ValidPathStrDto) SetPathDoesExist

func (vpDto *ValidPathStrDto) SetPathDoesExist(
	pathDoesExist PathExistsStatusCode) error

SetOriginalPathStr - "setter" method for internal data field vpDto.pathDoesExist which is of type PathExistsStatusCode.

                                      Int
   Enumeration Value                 Value         Definition
----------------------------------------------------------------------------
PathExistsStatusCode(0).Unknown()     -1    Path file existence has NOT been
                                            tested and status is 'Unknown'.

PathExistsStatusCode(0).DoesNotExist() 0    Path file existence HAS been tested
                                            and path file name does NOT exist on
                                            disk.

PathExistsStatusCode(0).Exists()      +1    Path file existence HAD been tested
                                            and path file name DOES exist on
                                            disk.

func (*ValidPathStrDto) SetPathFileInfo

func (vpDto *ValidPathStrDto) SetPathFileInfo(fInfPlus FileInfoPlus)

SetPathFileInfo - "setter" method for internal data field vpDto.pathFInfoPlus .

func (*ValidPathStrDto) SetPathIsValid

func (vpDto *ValidPathStrDto) SetPathIsValid(
	pathIsValid PathValidityStatusCode) error

SetPathIsValid - "setter" method for internal data field vpDto.pathIsValid which is of type PathValidityStatusCode.

                  Path Validity
 Method            Status Code
  Name               Constant       Description
______________________________________________________________________

PathValidityStatusCode(0).Unknown()     -1  Path/file name validity has NOT been
                                            tested and its status as 'Valid' or
                                            'invalid' is 'Unknown'.

PathValidityStatusCode(0).Invalid()      0  Tests have verified that the Path/file
                                            name is 'Invalid'.

PathValidityStatusCode(0).Valid()       +1  Tests have verified that the Path/file
                                            name is 'Valid'.

func (*ValidPathStrDto) SetPathType

func (vpDto *ValidPathStrDto) SetPathType(pathType PathFileTypeCode)

SetOriginalPathStr - "setter" method for internal data field vpDto.pathDoesExist which is of type PathFileTypeCode.

                               Path File
         Method                Type Code
          Name                 Constant            Description
_______________________________________________________________________________
PathFileTypeCode(0).None()        0           Path/file name type has NOT been
                                              tested and its status not known.

PathFileTypeCode.Path()           1           Tests have established that the
                                              Path/file name string is a
                                              directory path which does NOT
                                              contain a file name.

PathFileTypeCode.PathFile()       2           Tests have established that the
                                              Path/file name string includes
                                              both a directory path AND a file
                                              name.

PathFileTypeCode.File()           3           Tests have established that the
                                              Path/file name string consists
                                              solely of a file name and does
                                              NOT include a directory path.

PathFileTypeCode.Volume()         4           Tests have established that the
                                              Path/file name string consists
                                              solely of a volume name and does
                                              NOT include a directory path or
                                              file name.

PathFileTypeCode.Indeterminate()  5           Tests have been conducted on the
                                              Path/file name string, but the
                                              string cannot be classified and
                                              its status cannot be determined
                                              with certainty.

func (*ValidPathStrDto) SetPathVolumeIndex

func (vpDto *ValidPathStrDto) SetPathVolumeIndex(volIndex int)

SetPathVolumeIndex - "setter" method for internal data field vpDto.pathVolumeIndex .

func (*ValidPathStrDto) SetPathVolumeName

func (vpDto *ValidPathStrDto) SetPathVolumeName(volumeNameStr string)

SetPathVolumeName - "setter" method for internal data fields vpDto.pathVolumeName and vpDto.pathVolumeStrLength .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL