C# Class Duality.PathHelper

Provides helper methods for handling Paths.
显示文件 Open project: BraveSirAndrew/duality

Public Methods

Method Description
CopyDirectory ( string sourcePath, string targetPath, bool overwrite = false, Predicate filter = null ) : bool

Deep-Copies the source directory to the target path.

FilesEqual ( string filePathA, string filePathB ) : bool

Determines whether the contents of two files are completely equal.

GetFileHash ( string filePath ) : int

Calculates a hash value from the full (byte by byte) content of a file.

GetFreePath ( string pathBase, string pathExt ) : string

Returns a path that isn't taken yet.

GetMutualDirectory ( string path, string path2 ) : string

Returns a mutual base path of two different paths.

GetValidFileName ( string fileName ) : string

Takes a string that is supposed to be a file name and converts it into an actually valid file name, replacing invalid characters by undercores.

IsPathLocatedIn ( string path, string baseDir ) : bool

Returns whether one path is a sub-path of another.

IsPathVisible ( string path ) : bool

Returns whether the specified file or directory is visible, i.e. not hidden.

MakeFilePathRelative ( string filePath, string relativeToDir = "." ) : string

Returns the relative path from one path to another.

Private Methods

Method Description
IsPathValid ( string path ) : bool

Method Details

CopyDirectory() public static method

Deep-Copies the source directory to the target path.
public static CopyDirectory ( string sourcePath, string targetPath, bool overwrite = false, Predicate filter = null ) : bool
sourcePath string
targetPath string
overwrite bool
filter Predicate
return bool

FilesEqual() public static method

Determines whether the contents of two files are completely equal.
public static FilesEqual ( string filePathA, string filePathB ) : bool
filePathA string
filePathB string
return bool

GetFileHash() public static method

Calculates a hash value from the full (byte by byte) content of a file.
public static GetFileHash ( string filePath ) : int
filePath string
return int

GetFreePath() public static method

Returns a path that isn't taken yet.
public static GetFreePath ( string pathBase, string pathExt ) : string
pathBase string The path to use as base for finding a available path.
pathExt string The (file) extension to add to the new path.
return string

GetMutualDirectory() public static method

Returns a mutual base path of two different paths.
public static GetMutualDirectory ( string path, string path2 ) : string
path string The first path.
path2 string The second path.
return string

GetValidFileName() public static method

Takes a string that is supposed to be a file name and converts it into an actually valid file name, replacing invalid characters by undercores.
public static GetValidFileName ( string fileName ) : string
fileName string A string that is supposed to be a file name.
return string

IsPathLocatedIn() public static method

Returns whether one path is a sub-path of another.
public static IsPathLocatedIn ( string path, string baseDir ) : bool
path string The supposed sub-path.
baseDir string The (directory) path in which the supposed sub-path might be located in.
return bool

IsPathVisible() public static method

Returns whether the specified file or directory is visible, i.e. not hidden.
public static IsPathVisible ( string path ) : bool
path string
return bool

MakeFilePathRelative() public static method

Returns the relative path from one path to another.
public static MakeFilePathRelative ( string filePath, string relativeToDir = "." ) : string
filePath string The path to make relative.
relativeToDir string The path to make it relative to.
return string