Show: Delphi C++
Display Preferences

System.IOUtils.TPath

From XE2 API Documentation
Jump to: navigation, search

Delphi

  TPath = record
  private
    const
      FCCurrentDir: string = '.'; // DO NOT LOCALIZE
      FCParentDir: string = '..'; // DO NOT LOCALIZE
      FCExtendedPrefix: string = '\\?\'; // DO NOT LOCALIZE
      FCExtendedUNCPrefix: string = '\\?\UNC\'; // DO NOT LOCALIZE
    class var
      FAltDirectorySeparatorChar: Char;
      FDirectorySeparatorChar: Char;
      FPathSeparator: Char;
      FVolumeSeparatorChar: Char;
      FExtensionSeparatorChar: Char;
      FInvalidPathChars: TCharArray;
      FInvalidFileNameChars: TCharArray;
      FPathWildcardChars: TCharArray;
      FFileNameWildCardChars: TCharArray;
    class procedure CheckPathLength(const Path: string; const MaxLength: Integer); static;
    class function GetExtensionSeparatorPos(const FileName: string): Integer; static;
{$IFDEF MSWINDOWS}
    class function HasPathValidColon(const Path: string): Boolean; static;
{$ENDIF MSWINDOWS}
    class function IsCharInOrderedArray(const AChar: Char;
        const AnArray: TCharArray): Boolean; static;
    class function IsPathWildcardChar(const AChar: Char): Boolean; inline; static;
    class function IsPathSeparator(const AChar: Char): Boolean; inline; static;
    class function IsFileNameWildcardChar(const AChar: Char): Boolean; inline; static;
{$IFDEF MSWINDOWS}
    class function GetPosAfterExtendedPrefix(const Path: string): Integer;
        overload; inline; static;
    class function GetPosAfterExtendedPrefix(const Path: string;
        out Prefix: TPathPrefixType): Integer; overload; static;
    class function PrefixExtendsPath(const Prefix: TPathPrefixType): Boolean; inline; static;
{$ENDIF MSWINDOWS}
    class function DoCombine(const Path1, Path2: string;
        const ValidateParams: Boolean): string; static;
    class function DoGetDirectoryName(FileName: string): string; static;
    class function DoGetFileName(const FileName: string;
        const ValidateParam: Boolean): string; static;
    class function DoGetFullPath(const Path: string): string; static;
    class function DoGetPathRoot(const Path: string): string; static;
    class function DoIsPathRooted(const Path: string;
        const ValidateParam: Boolean): Boolean; static;
    class function DoMatchesPattern(const FileName, Pattern: string): Boolean; inline; static;
  public
    class constructor Create;
    class function IsValidPathChar(const AChar: Char): Boolean; inline; static;
    class function IsValidFileNameChar(const AChar: Char): Boolean; inline; static;
    class function HasValidPathChars(const Path: string;
      const UseWildcards: Boolean): Boolean; static;
    class function HasValidFileNameChars(const FileName: string;
      const UseWildcards: Boolean): Boolean; static;
    class function GetExtendedPrefix(const Path: string): TPathPrefixType; static;
    class function IsDriveRooted(const Path: string): Boolean; static;
    class function IsExtendedPrefixed(const Path: string): Boolean; inline; static;
    class function IsRelativePath(const Path: string): Boolean; static;
    class function IsUNCPath(const Path: string): Boolean; inline; static;
    class function IsUNCRooted(const Path: string): Boolean; static;
    class function GetGUIDFileName(const UseSeparator: Boolean = False): string; static;
    class function DriveExists(const Path: string): Boolean; static;
    class function MatchesPattern(const FileName, Pattern: string;
        const CaseSensitive: Boolean): Boolean; static;
    class function ChangeExtension(const Path, Extension: string): string; static;
    class function Combine(const Path1, Path2: string): string; inline; static;
    class function GetDirectoryName(FileName: string): string; static;
    class function GetExtension(const FileName: string): string; static;
    class function GetFileName(const FileName: string): string; inline; static;
    class function GetFileNameWithoutExtension(const FileName: string): string; static;
    class function GetFullPath(const Path: string): string; static;
    class function GetInvalidFileNameChars: TCharArray; inline; static;
    class function GetInvalidPathChars: TCharArray; inline; static;
    class function GetPathRoot(const Path: string): string; static;
    class function GetRandomFileName: string; static;
    class function GetTempFileName: string; static;
    class function GetTempPath: string; static;
    class function GetHomePath: string; static;
    class function GetAttributes(const Path: string; FollowLink: Boolean = True): TFileAttributes; inline; static;
    class procedure SetAttributes(const Path: string;
        const Attributes: TFileAttributes); inline; static;
    class function HasExtension(const Path: string): Boolean; static;
    class function IsPathRooted(const Path: string): Boolean; inline; static;
    class property ExtensionSeparatorChar: Char read FExtensionSeparatorChar;
    class property AltDirectorySeparatorChar: Char read FAltDirectorySeparatorChar;
    class property DirectorySeparatorChar: Char read FDirectorySeparatorChar;
    class property PathSeparator: Char read FPathSeparator;
    class property VolumeSeparatorChar: Char read FVolumeSeparatorChar;
  end;

C++

struct DECLSPEC_DRECORD TPath{
private:
static System::UnicodeString FCCurrentDir;
static System::UnicodeString FCParentDir;
static System::UnicodeString FCExtendedPrefix;
static System::UnicodeString FCExtendedUNCPrefix;
static System::WideChar FAltDirectorySeparatorChar;
static System::WideChar FDirectorySeparatorChar;
static System::WideChar FPathSeparator;
static System::WideChar FVolumeSeparatorChar;
static System::WideChar FExtensionSeparatorChar;
static System::DynamicArray<System::WideChar> FInvalidPathChars;
static System::DynamicArray<System::WideChar> FInvalidFileNameChars;
static System::DynamicArray<System::WideChar> FPathWildcardChars;
static System::DynamicArray<System::WideChar> FFileNameWildCardChars;
static void __fastcall CheckPathLength(const System::UnicodeString Path, const int MaxLength);
static int __fastcall GetExtensionSeparatorPos(const System::UnicodeString FileName);
static bool __fastcall HasPathValidColon(const System::UnicodeString Path);
static bool __fastcall IsCharInOrderedArray(const System::WideChar AChar, const System::DynamicArray<System::WideChar> AnArray);
static bool __fastcall IsPathWildcardChar(const System::WideChar AChar);
static bool __fastcall IsPathSeparator(const System::WideChar AChar);
static bool __fastcall IsFileNameWildcardChar(const System::WideChar AChar);
static int __fastcall GetPosAfterExtendedPrefix(const System::UnicodeString Path)/* overload */;
static int __fastcall GetPosAfterExtendedPrefix(const System::UnicodeString Path, /* out */ TPathPrefixType &Prefix)/* overload */;
static bool __fastcall PrefixExtendsPath(const TPathPrefixType Prefix);
static System::UnicodeString __fastcall DoCombine(const System::UnicodeString Path1, const System::UnicodeString Path2, const bool ValidateParams);
static System::UnicodeString __fastcall DoGetDirectoryName(System::UnicodeString FileName);
static System::UnicodeString __fastcall DoGetFileName(const System::UnicodeString FileName, const bool ValidateParam);
static System::UnicodeString __fastcall DoGetFullPath(const System::UnicodeString Path);
static System::UnicodeString __fastcall DoGetPathRoot(const System::UnicodeString Path);
static bool __fastcall DoIsPathRooted(const System::UnicodeString Path, const bool ValidateParam);
static bool __fastcall DoMatchesPattern(const System::UnicodeString FileName, const System::UnicodeString Pattern);
private:
public:
static bool __fastcall IsValidPathChar(const System::WideChar AChar);
static bool __fastcall IsValidFileNameChar(const System::WideChar AChar);
static bool __fastcall HasValidPathChars(const System::UnicodeString Path, const bool UseWildcards);
static bool __fastcall HasValidFileNameChars(const System::UnicodeString FileName, const bool UseWildcards);
static TPathPrefixType __fastcall GetExtendedPrefix(const System::UnicodeString Path);
static bool __fastcall IsDriveRooted(const System::UnicodeString Path);
static bool __fastcall IsExtendedPrefixed(const System::UnicodeString Path);
static bool __fastcall IsRelativePath(const System::UnicodeString Path);
static bool __fastcall IsUNCPath(const System::UnicodeString Path);
static bool __fastcall IsUNCRooted(const System::UnicodeString Path);
static System::UnicodeString __fastcall GetGUIDFileName(const bool UseSeparator = false);
static bool __fastcall DriveExists(const System::UnicodeString Path);
static bool __fastcall MatchesPattern(const System::UnicodeString FileName, const System::UnicodeString Pattern, const bool CaseSensitive);
static System::UnicodeString __fastcall ChangeExtension(const System::UnicodeString Path, const System::UnicodeString Extension);
static System::UnicodeString __fastcall Combine(const System::UnicodeString Path1, const System::UnicodeString Path2);
static System::UnicodeString __fastcall GetDirectoryName(System::UnicodeString FileName);
static System::UnicodeString __fastcall GetExtension(const System::UnicodeString FileName);
static System::UnicodeString __fastcall GetFileName(const System::UnicodeString FileName);
static System::UnicodeString __fastcall GetFileNameWithoutExtension(const System::UnicodeString FileName);
static System::UnicodeString __fastcall GetFullPath(const System::UnicodeString Path);
static System::DynamicArray<System::WideChar> __fastcall GetInvalidFileNameChars();
static System::DynamicArray<System::WideChar> __fastcall GetInvalidPathChars();
static System::UnicodeString __fastcall GetPathRoot(const System::UnicodeString Path);
static System::UnicodeString __fastcall GetRandomFileName();
static System::UnicodeString __fastcall GetTempFileName();
static System::UnicodeString __fastcall GetTempPath();
static System::UnicodeString __fastcall GetHomePath();
static TFileAttributes __fastcall GetAttributes(const System::UnicodeString Path, bool FollowLink = true);
static void __fastcall SetAttributes(const System::UnicodeString Path, const TFileAttributes Attributes);
static bool __fastcall HasExtension(const System::UnicodeString Path);
static bool __fastcall IsPathRooted(const System::UnicodeString Path);
/* static */ __property System::WideChar ExtensionSeparatorChar = {read=FExtensionSeparatorChar};
/* static */ __property System::WideChar AltDirectorySeparatorChar = {read=FAltDirectorySeparatorChar};
/* static */ __property System::WideChar DirectorySeparatorChar = {read=FDirectorySeparatorChar};
/* static */ __property System::WideChar PathSeparator = {read=FPathSeparator};
/* static */ __property System::WideChar VolumeSeparatorChar = {read=FVolumeSeparatorChar};
private:
};

Properties

Type Visibility Source Unit Parent
struct
class
public
System.IOUtils.pas
System.IOUtils.hpp
System.IOUtils System.IOUtils

Description

Contains a large number of static utility methods used in path manipulations.

TPath is a record containing only static methods used to perform various operations on paths. Do not declare variables of type TPath, since TPath has no instance methods or fields. Operations that can be completed using TPath include:

  • Verifying the correctness of a path or a file name
  • Extracting various parts of a path string
  • Generating temporary and unique paths
Note: Most of the methods exposed by TPath are signature-compatible with the ones exposed by the Path class in the .NET Framework.

See Also

Personal tools
Previous Versions
Translations