C# Class Duality.PathHelper

Provides helper methods for handling Paths.
Afficher le fichier Open project: BraveSirAndrew/duality

Méthodes publiques

Méthode 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

Méthode Description
IsPathValid ( string path ) : bool

Method Details

CopyDirectory() public static méthode

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
Résultat bool

FilesEqual() public static méthode

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

GetFileHash() public static méthode

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

GetFreePath() public static méthode

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.
Résultat string

GetMutualDirectory() public static méthode

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.
Résultat string

GetValidFileName() public static méthode

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.
Résultat string

IsPathLocatedIn() public static méthode

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.
Résultat bool

IsPathVisible() public static méthode

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

MakeFilePathRelative() public static méthode

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.
Résultat string