System.IOUtils.TPath

提供: RAD Studio API Documentation
移動先: 案内検索

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 procedure InternalCheckPathParam(const Path: string; const ExistsCheck: Boolean); static;
    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;
{$IFDEF MACOS}
    class function InternalGetMACOSPath(const SearchedPath: NSSearchPathDirectory; const SearchMask: NSSearchPathDomainMask): string; static;
{$ENDIF MACOS}
  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 GetDocumentsPath: string; static;
    class function GetSharedDocumentsPath: string; static;
    class function GetLibraryPath: string; static;
    class function GetCachePath: string; static;
    class function GetPublicPath: string; static;
    class function GetPicturesPath: string; static;
    class function GetSharedPicturesPath: string; static;
    class function GetCameraPath: string; static;
    class function GetSharedCameraPath: string; static;
    class function GetMusicPath: string; static;
    class function GetSharedMusicPath: string; static;
    class function GetMoviesPath: string; static;
    class function GetSharedMoviesPath: string; static;
    class function GetAlarmsPath: string; static;
    class function GetSharedAlarmsPath: string; static;
    class function GetDownloadsPath: string; static;
    class function GetSharedDownloadsPath: string; static;
    class function GetRingtonesPath: string; static;
    class function GetSharedRingtonesPath: 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;
#ifndef _WIN64
    static System::DynamicArray<System::WideChar> FInvalidPathChars;
    static System::DynamicArray<System::WideChar> FInvalidFileNameChars;
    static System::DynamicArray<System::WideChar> FPathWildcardChars;
    static System::DynamicArray<System::WideChar> FFileNameWildCardChars;
#else /* _WIN64 */
    static System::TArray__1<System::WideChar> FInvalidPathChars;
    static System::TArray__1<System::WideChar> FInvalidFileNameChars;
    static System::TArray__1<System::WideChar> FPathWildcardChars;
    static System::TArray__1<System::WideChar> FFileNameWildCardChars;
#endif /* _WIN64 */
    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 void __fastcall InternalCheckPathParam(const System::UnicodeString Path, const bool ExistsCheck);
#ifndef _WIN64
    static bool __fastcall IsCharInOrderedArray(const System::WideChar AChar, const System::DynamicArray<System::WideChar> AnArray);
#else /* _WIN64 */
    static bool __fastcall IsCharInOrderedArray(const System::WideChar AChar, const System::TArray__1<System::WideChar> AnArray);
#endif /* _WIN64 */
    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);
#ifndef _WIN64
    static System::DynamicArray<System::WideChar> __fastcall GetInvalidFileNameChars();
    static System::DynamicArray<System::WideChar> __fastcall GetInvalidPathChars();
#else /* _WIN64 */
    static System::TArray__1<System::WideChar> __fastcall GetInvalidFileNameChars();
    static System::TArray__1<System::WideChar> __fastcall GetInvalidPathChars();
#endif /* _WIN64 */
    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 System::UnicodeString __fastcall GetDocumentsPath();
    static System::UnicodeString __fastcall GetSharedDocumentsPath();
    static System::UnicodeString __fastcall GetLibraryPath();
    static System::UnicodeString __fastcall GetCachePath();
    static System::UnicodeString __fastcall GetPublicPath();
    static System::UnicodeString __fastcall GetPicturesPath();
    static System::UnicodeString __fastcall GetSharedPicturesPath();
    static System::UnicodeString __fastcall GetCameraPath();
    static System::UnicodeString __fastcall GetSharedCameraPath();
    static System::UnicodeString __fastcall GetMusicPath();
    static System::UnicodeString __fastcall GetSharedMusicPath();
    static System::UnicodeString __fastcall GetMoviesPath();
    static System::UnicodeString __fastcall GetSharedMoviesPath();
    static System::UnicodeString __fastcall GetAlarmsPath();
    static System::UnicodeString __fastcall GetSharedAlarmsPath();
    static System::UnicodeString __fastcall GetDownloadsPath();
    static System::UnicodeString __fastcall GetSharedDownloadsPath();
    static System::UnicodeString __fastcall GetRingtonesPath();
    static System::UnicodeString __fastcall GetSharedRingtonesPath();
    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:
};

プロパティ

種類 可視性 ソース ユニット
record
struct
public
System.IOUtils.pas
System.IOUtils.hpp
System.IOUtils System.IOUtils

説明

パス操作で使用される多数の静的ユーティリティ メソッドが含まれています。

TPath は、パスに対するさまざまな操作の実行に使用される静的メソッドのみ含まれているレコードです。TPath にはインスタンス メソッドやインスタンス フィールドがないため、TPath 型の変数を宣言しないでください。TPath を使って実行できる操作は以下のとおりです。

  • パスまたはファイル名が正しいかどうかの確認
  • パス文字列のさまざまな部分の抽出
  • 一時的かつ一意なパスの生成

メモ:  TPath で公開されているメソッドの大半は、.NET FrameworkPath クラスで公開されているメソッドとシグニチャの互換性があります。

関連項目