C# Class NAnt.Core.Util.FileUtils

Provides modified version for Copy and Move from the File class that allow for filter chain processing.
显示文件 Open project: skolima/NAnt

Public Methods

Method Description
CombinePaths ( string path1, string path2 ) : string

Combines two path strings.

On *nix, processing is delegated to System.IO.Path.Combine(string, string).

On Windows, this method normalized the paths to avoid running into the 260 character limit of a path and converts forward slashes in both path1 and path2 to the platform's directory separator character.

CopyFile ( string sourceFileName, string destFileName, FilterChain filterChain, Encoding inputEncoding, Encoding outputEncoding ) : void

Copies a file filtering its content through the filter chain.

GetFullPath ( string path ) : string

Returns Absolute Path (Fix for 260 Char Limit of Path.GetFullPath(...))

GetHomeDirectory ( ) : string

Returns the home directory of the current user.

GetTempDirectory ( ) : DirectoryInfo

Returns a uniquely named empty temporary directory on disk.

MoveFile ( string sourceFileName, string destFileName, FilterChain filterChain, Encoding inputEncoding, Encoding outputEncoding ) : void

Moves a file filtering its content through the filter chain.

ReadFile ( string fileName, FilterChain filterChain, Encoding inputEncoding ) : string

Reads a file filtering its content through the filter chain.

If inputEncoding is , then the system's ANSI code page will be used to read the file.

ResolveFile ( string directories, string fileName, bool recursive ) : string

Scans a list of directories for the specified filename.

The directories are scanned in the order in which they are defined.

Private Methods

Method Description
FileUtils ( ) : System
ScanDirectory ( string directory, string fileName, bool recursive ) : string

Method Details

CombinePaths() public static method

Combines two path strings.

On *nix, processing is delegated to System.IO.Path.Combine(string, string).

On Windows, this method normalized the paths to avoid running into the 260 character limit of a path and converts forward slashes in both path1 and path2 to the platform's directory separator character.

public static CombinePaths ( string path1, string path2 ) : string
path1 string The first path.
path2 string The second path.
return string

CopyFile() public static method

Copies a file filtering its content through the filter chain.
public static CopyFile ( string sourceFileName, string destFileName, FilterChain filterChain, Encoding inputEncoding, Encoding outputEncoding ) : void
sourceFileName string The file to copy
destFileName string The file to copy to
filterChain NAnt.Core.Filters.FilterChain Chain of filters to apply when copying, or is no filters should be applied.
inputEncoding System.Text.Encoding The encoding used to read the soure file.
outputEncoding System.Text.Encoding The encoding used to write the destination file.
return void

GetFullPath() public static method

Returns Absolute Path (Fix for 260 Char Limit of Path.GetFullPath(...))
path is a zero-length string, contains only white space or contains one or more invalid characters as defined by . is .
public static GetFullPath ( string path ) : string
path string The file or directory for which to obtain absolute path information.
return string

GetHomeDirectory() public static method

Returns the home directory of the current user.
public static GetHomeDirectory ( ) : string
return string

GetTempDirectory() public static method

Returns a uniquely named empty temporary directory on disk.
public static GetTempDirectory ( ) : DirectoryInfo
return System.IO.DirectoryInfo

MoveFile() public static method

Moves a file filtering its content through the filter chain.
public static MoveFile ( string sourceFileName, string destFileName, FilterChain filterChain, Encoding inputEncoding, Encoding outputEncoding ) : void
sourceFileName string The file to move.
destFileName string The file to move move to.
filterChain NAnt.Core.Filters.FilterChain Chain of filters to apply when moving, or is no filters should be applied.
inputEncoding System.Text.Encoding The encoding used to read the soure file.
outputEncoding System.Text.Encoding The encoding used to write the destination file.
return void

ReadFile() public static method

Reads a file filtering its content through the filter chain.
If inputEncoding is , then the system's ANSI code page will be used to read the file.
public static ReadFile ( string fileName, FilterChain filterChain, Encoding inputEncoding ) : string
fileName string The file to read.
filterChain NAnt.Core.Filters.FilterChain Chain of filters to apply when reading, or is no filters should be applied.
inputEncoding System.Text.Encoding The encoding used to read the file.
return string

ResolveFile() public static method

Scans a list of directories for the specified filename.
The directories are scanned in the order in which they are defined.
public static ResolveFile ( string directories, string fileName, bool recursive ) : string
directories string The list of directories to search.
fileName string The name of the file to look for.
recursive bool Specifies whether the directory should be searched recursively.
return string