C# 클래스 ClrPlus.Platform.FilesystemExtensions

Functions related to handling things regarding files and filesystems.
파일 보기 프로젝트 열기: perpetual-motion/clrplus

공개 프로퍼티들

프로퍼티 타입 설명
OriginalTempFolder string

공개 메소드들

메소드 설명
CanonicalizePath ( this path, bool IsPotentiallyRelativePath = true ) : string

This takes a string that is representative of a filename and tries to create a path that can be considered the 'canonical' path. path on drives that are mapped as remote shares are rewritten as their \\server\share\path

CanonicalizePathIfLocalAndExists ( this filename ) : string
CanonicalizePathWithWildcards ( this path ) : string

cleans up a path if it is a filesystem path, uri or wildcard. returns the original unmodified path if it is not.

ChangeFileExtensionTo ( this currentFilename, string newExtension ) : string

Changes the file extension to another extension.

CreateWritableWorkingCopy ( this filename ) : string

This makes a temporary copy of a file that we can work with.

DirectoryEnumerateFilesSmarter ( this path, SearchOption searchOption ) : IEnumerable
DirectoryEnumerateFilesSmarter ( this path, string searchPattern, SearchOption searchOption ) : IEnumerable

Enumerates files in a directory, smarter than Direcotry.EnumerateFiles (ie, doesn't throw, when it can't access something)

DirectoryExistsAndIsAccessible ( this path ) : bool

Directories the exists and is accessible.

EnsureFileIsLocal ( this filename, string localFolder = null ) : string
FileIsLocalAndExists ( this filename ) : bool
FindFilesSmarter ( this pathMask, string subpathMask = null ) : IEnumerable

A front end to DirectoryEnumerateFilesSmarter that allows for wildcards in the path or serarch mask (and expands it out to a full path first.) it also constrains the path as much as possible to keep from enumerating directories that will never match files.

FindFilesSmarter ( this pathMasks ) : IEnumerable

finds matches for a collection of filenames using FindFilesSmarter (above)

FindFilesSmarterComplex ( this pathMask, string pathPrefix = null ) : IEnumerable

always call IsWildcardMatch with a prefix!!!!

FindFilesSmarterComplex ( this pathMasks, string pathPrefix = null ) : IEnumerable
FixFilepathSlashes ( this filepath ) : string

Replaces Unix style file path separators (/) with Windows style (\).

FormatFilename ( this filename ) : string

Generates a filename on a somewhat different template.

{date} - the current date (y-m-d) {date-long} - the date in long format {time} - the current time (Hh:mm:ss) {time-long} - the current time in long fmt {ticks} - the current timestamp as tics {counter} - a running counter

GenerateTemplatedFilename ( this filename, string filenameHint ) : string

Generates a filename based of a template that can contain many different values

{filename} - substitutes for the original filename, no extension {ext} original extension {folder} - original folder {subfolder} - original folder without leading / {count} - a running count of the files downloaded. {date} - the current date (y-m-d) {date-long} - the date in long format {time} - the current time (Hh:mm:ss) {time-long} - the current time in long fmt {ticks} - the current timestamp as tics

GenerateTemporaryFilename ( this filename ) : string
GetAllCustomFilePaths ( this filename, string currentDirectory ) : IEnumerable
GetCustomFilePath ( this filename, string currentDirectory = null ) : string
GetCustomFilePathOrWalkUp ( this filename, string currentDirectory = null ) : string
GetDirectoryStack ( this currentDirectory ) : IEnumerable
GetFileInTempFolder ( this filename ) : string
GetFileMD5 ( this filename ) : string

Returns the MD5 Hash of a file as an uppercase hex string

GetFileSHA1 ( this filename ) : string
GetFullPath ( this path ) : string

Returns the full path of a string. Short circuts the process if the string is a known full path already. (ie, the result of a preivious GetFullPath())

GetMinimalPaths ( this paths ) : IEnumerable
GetMinimalPathsToDictionary ( this paths ) : string>.IDictionary
GetSubPath ( this parentPath, string childPath ) : string

Gets the portion of the childPath that is a sub path of the parentPath Returns string.Empty if the childPath is not a sub path of the parent.

IsFolderEmpty ( string foldername ) : bool?
IsSimpleSubPath ( this path ) : bool

Tells whether a given path is a simple subpath. A simple subpath has the following characteristics: - No drive letter or colon - Does not start with a slash - Does not contain any path part sections consisting of just "." or ".." - Does not contain wildcards

IsSubPath ( this rootPath, string childPath ) : bool

Determines if the childPath is a sub path of the rootPath

MarkFileTemporary ( this filename ) : string
NameWithoutExt ( this fi ) : string

Gets the name of a file minus it's extension, ie: if the file name is "test.exe", returns "test".

NormalizePath ( this path ) : string

Translates paths starting with \??\ to regular paths.

ReadAllBytesFromFile ( this ms, string path ) : void

Reads the contents of a file into a memory stream.

RelativePathTo ( this currentDirectory, string pathToMakeRelative ) : string

Gets the relative path between two paths.

RemoveDeadLnks ( string folder ) : void
RemoveEssentiallyEmptyFolders ( string folderName ) : bool
RemoveInvalidSymlinks ( string directory = null, int maxdepth = 3 ) : void
RemoveTemporaryFiles ( ) : void
ResetTempFolder ( ) : void
TryHardToDelete ( this location ) : void
TryHardToMakeFileWriteable ( this filename ) : void

This makes sure a file is writable by moving the original, copying this one back then deleting the original (or at least tryinghardtodelete the original). This allows us to modify locked files in place.

TryToHandlePendingRenames ( bool force = false ) : void
WalkUpPath ( this filename, string currentDirectory = null ) : string
WalkUpPaths ( this filenames, string currentDirectory = null ) : string
Write ( this fileStream, byte data ) : int

Writes the whole byte array to a filestream. (lazy!)

WriteAllBytesToFile ( this ms, string path ) : void

Writes all bytes from the contents of a memorystream to file (as a binary file).

비공개 메소드들

메소드 설명
FilesystemExtensions ( ) : System
GetNextPart ( this path ) : string>.Tuple

Gets the next part. Note: Make Eric document this?

메소드 상세

CanonicalizePath() 공개 정적인 메소드

This takes a string that is representative of a filename and tries to create a path that can be considered the 'canonical' path. path on drives that are mapped as remote shares are rewritten as their \\server\share\path
public static CanonicalizePath ( this path, bool IsPotentiallyRelativePath = true ) : string
path this
IsPotentiallyRelativePath bool
리턴 string

CanonicalizePathIfLocalAndExists() 공개 정적인 메소드

public static CanonicalizePathIfLocalAndExists ( this filename ) : string
filename this
리턴 string

CanonicalizePathWithWildcards() 공개 정적인 메소드

cleans up a path if it is a filesystem path, uri or wildcard. returns the original unmodified path if it is not.
public static CanonicalizePathWithWildcards ( this path ) : string
path this
리턴 string

ChangeFileExtensionTo() 공개 정적인 메소드

Changes the file extension to another extension.
public static ChangeFileExtensionTo ( this currentFilename, string newExtension ) : string
currentFilename this The current filename.
newExtension string The new extension.
리턴 string

CreateWritableWorkingCopy() 공개 정적인 메소드

This makes a temporary copy of a file that we can work with.
public static CreateWritableWorkingCopy ( this filename ) : string
filename this
리턴 string

DirectoryEnumerateFilesSmarter() 공개 정적인 메소드

public static DirectoryEnumerateFilesSmarter ( this path, SearchOption searchOption ) : IEnumerable
path this
searchOption SearchOption
리턴 IEnumerable

DirectoryEnumerateFilesSmarter() 공개 정적인 메소드

Enumerates files in a directory, smarter than Direcotry.EnumerateFiles (ie, doesn't throw, when it can't access something)
public static DirectoryEnumerateFilesSmarter ( this path, string searchPattern, SearchOption searchOption ) : IEnumerable
path this The path.
searchPattern string The search pattern.
searchOption SearchOption The search option.
리턴 IEnumerable

DirectoryExistsAndIsAccessible() 공개 정적인 메소드

Directories the exists and is accessible.
public static DirectoryExistsAndIsAccessible ( this path ) : bool
path this The path.
리턴 bool

EnsureFileIsLocal() 공개 정적인 메소드

public static EnsureFileIsLocal ( this filename, string localFolder = null ) : string
filename this
localFolder string
리턴 string

FileIsLocalAndExists() 공개 정적인 메소드

public static FileIsLocalAndExists ( this filename ) : bool
filename this
리턴 bool

FindFilesSmarter() 공개 정적인 메소드

A front end to DirectoryEnumerateFilesSmarter that allows for wildcards in the path or serarch mask (and expands it out to a full path first.) it also constrains the path as much as possible to keep from enumerating directories that will never match files.
public static FindFilesSmarter ( this pathMask, string subpathMask = null ) : IEnumerable
pathMask this The path mask.
subpathMask string the sub path mask.
리턴 IEnumerable

FindFilesSmarter() 공개 정적인 메소드

finds matches for a collection of filenames using FindFilesSmarter (above)
public static FindFilesSmarter ( this pathMasks ) : IEnumerable
pathMasks this The path masks.
리턴 IEnumerable

FindFilesSmarterComplex() 공개 정적인 메소드

always call IsWildcardMatch with a prefix!!!!
public static FindFilesSmarterComplex ( this pathMask, string pathPrefix = null ) : IEnumerable
pathMask this
pathPrefix string
리턴 IEnumerable

FindFilesSmarterComplex() 공개 정적인 메소드

public static FindFilesSmarterComplex ( this pathMasks, string pathPrefix = null ) : IEnumerable
pathMasks this
pathPrefix string
리턴 IEnumerable

FixFilepathSlashes() 공개 정적인 메소드

Replaces Unix style file path separators (/) with Windows style (\).
public static FixFilepathSlashes ( this filepath ) : string
filepath this The filepath.
리턴 string

FormatFilename() 공개 정적인 메소드

Generates a filename on a somewhat different template.
{date} - the current date (y-m-d) {date-long} - the date in long format {time} - the current time (Hh:mm:ss) {time-long} - the current time in long fmt {ticks} - the current timestamp as tics {counter} - a running counter
public static FormatFilename ( this filename ) : string
filename this The filename.
리턴 string

GenerateTemplatedFilename() 공개 정적인 메소드

Generates a filename based of a template that can contain many different values
{filename} - substitutes for the original filename, no extension {ext} original extension {folder} - original folder {subfolder} - original folder without leading / {count} - a running count of the files downloaded. {date} - the current date (y-m-d) {date-long} - the date in long format {time} - the current time (Hh:mm:ss) {time-long} - the current time in long fmt {ticks} - the current timestamp as tics
public static GenerateTemplatedFilename ( this filename, string filenameHint ) : string
filename this The filename.
filenameHint string The filename hint.
리턴 string

GenerateTemporaryFilename() 공개 정적인 메소드

public static GenerateTemporaryFilename ( this filename ) : string
filename this
리턴 string

GetAllCustomFilePaths() 공개 정적인 메소드

public static GetAllCustomFilePaths ( this filename, string currentDirectory ) : IEnumerable
filename this
currentDirectory string
리턴 IEnumerable

GetCustomFilePath() 공개 정적인 메소드

public static GetCustomFilePath ( this filename, string currentDirectory = null ) : string
filename this
currentDirectory string
리턴 string

GetCustomFilePathOrWalkUp() 공개 정적인 메소드

public static GetCustomFilePathOrWalkUp ( this filename, string currentDirectory = null ) : string
filename this
currentDirectory string
리턴 string

GetDirectoryStack() 공개 정적인 메소드

public static GetDirectoryStack ( this currentDirectory ) : IEnumerable
currentDirectory this
리턴 IEnumerable

GetFileInTempFolder() 공개 정적인 메소드

public static GetFileInTempFolder ( this filename ) : string
filename this
리턴 string

GetFileMD5() 공개 정적인 메소드

Returns the MD5 Hash of a file as an uppercase hex string
public static GetFileMD5 ( this filename ) : string
filename this the filename to retrive the hash for
리턴 string

GetFileSHA1() 공개 정적인 메소드

public static GetFileSHA1 ( this filename ) : string
filename this
리턴 string

GetFullPath() 공개 정적인 메소드

Returns the full path of a string. Short circuts the process if the string is a known full path already. (ie, the result of a preivious GetFullPath())
public static GetFullPath ( this path ) : string
path this The path.
리턴 string

GetMinimalPaths() 공개 정적인 메소드

public static GetMinimalPaths ( this paths ) : IEnumerable
paths this
리턴 IEnumerable

GetMinimalPathsToDictionary() 공개 정적인 메소드

public static GetMinimalPathsToDictionary ( this paths ) : string>.IDictionary
paths this
리턴 string>.IDictionary

GetSubPath() 공개 정적인 메소드

Gets the portion of the childPath that is a sub path of the parentPath Returns string.Empty if the childPath is not a sub path of the parent.
public static GetSubPath ( this parentPath, string childPath ) : string
parentPath this The parent path.
childPath string The child path.
리턴 string

IsFolderEmpty() 공개 정적인 메소드

public static IsFolderEmpty ( string foldername ) : bool?
foldername string
리턴 bool?

IsSimpleSubPath() 공개 정적인 메소드

Tells whether a given path is a simple subpath. A simple subpath has the following characteristics: - No drive letter or colon - Does not start with a slash - Does not contain any path part sections consisting of just "." or ".." - Does not contain wildcards
public static IsSimpleSubPath ( this path ) : bool
path this the path to check
리턴 bool

IsSubPath() 공개 정적인 메소드

Determines if the childPath is a sub path of the rootPath
public static IsSubPath ( this rootPath, string childPath ) : bool
rootPath this The root path.
childPath string The child path.
리턴 bool

MarkFileTemporary() 공개 정적인 메소드

public static MarkFileTemporary ( this filename ) : string
filename this
리턴 string

NameWithoutExt() 공개 정적인 메소드

Gets the name of a file minus it's extension, ie: if the file name is "test.exe", returns "test".
public static NameWithoutExt ( this fi ) : string
fi this The fi.
리턴 string

NormalizePath() 공개 정적인 메소드

Translates paths starting with \??\ to regular paths.
public static NormalizePath ( this path ) : string
path this The path.
리턴 string

ReadAllBytesFromFile() 공개 정적인 메소드

Reads the contents of a file into a memory stream.
public static ReadAllBytesFromFile ( this ms, string path ) : void
ms this The ms.
path string The path.
리턴 void

RelativePathTo() 공개 정적인 메소드

Gets the relative path between two paths.
public static RelativePathTo ( this currentDirectory, string pathToMakeRelative ) : string
currentDirectory this The current directory.
pathToMakeRelative string The path to make relative.
리턴 string

RemoveDeadLnks() 공개 정적인 메소드

public static RemoveDeadLnks ( string folder ) : void
folder string
리턴 void

RemoveEssentiallyEmptyFolders() 공개 정적인 메소드

public static RemoveEssentiallyEmptyFolders ( string folderName ) : bool
folderName string
리턴 bool

RemoveInvalidSymlinks() 공개 정적인 메소드

public static RemoveInvalidSymlinks ( string directory = null, int maxdepth = 3 ) : void
directory string
maxdepth int
리턴 void

RemoveTemporaryFiles() 공개 정적인 메소드

public static RemoveTemporaryFiles ( ) : void
리턴 void

ResetTempFolder() 공개 정적인 메소드

public static ResetTempFolder ( ) : void
리턴 void

TryHardToDelete() 공개 정적인 메소드

public static TryHardToDelete ( this location ) : void
location this
리턴 void

TryHardToMakeFileWriteable() 공개 정적인 메소드

This makes sure a file is writable by moving the original, copying this one back then deleting the original (or at least tryinghardtodelete the original). This allows us to modify locked files in place.
public static TryHardToMakeFileWriteable ( this filename ) : void
filename this
리턴 void

TryToHandlePendingRenames() 공개 정적인 메소드

public static TryToHandlePendingRenames ( bool force = false ) : void
force bool
리턴 void

WalkUpPath() 공개 정적인 메소드

public static WalkUpPath ( this filename, string currentDirectory = null ) : string
filename this
currentDirectory string
리턴 string

WalkUpPaths() 공개 정적인 메소드

public static WalkUpPaths ( this filenames, string currentDirectory = null ) : string
filenames this
currentDirectory string
리턴 string

Write() 공개 정적인 메소드

Writes the whole byte array to a filestream. (lazy!)
public static Write ( this fileStream, byte data ) : int
fileStream this The file stream.
data byte The data.
리턴 int

WriteAllBytesToFile() 공개 정적인 메소드

Writes all bytes from the contents of a memorystream to file (as a binary file).
public static WriteAllBytesToFile ( this ms, string path ) : void
ms this The ms.
path string The path.
리턴 void

프로퍼티 상세

OriginalTempFolder 공개적으로 정적으로 프로퍼티

public static string OriginalTempFolder
리턴 string