System.IOUtils.TDirectory

提供: Appmethod Libraries
移動先: 案内検索

Object Pascal

  TDirectory = record
  public
    type
      TFilterPredicate = reference to function(const Path: string;
          const SearchRec: TSearchRec): Boolean;
  private
    type
      TDirectoryWalkProc = reference to function (const Path: string;
          const FileInfo: TSearchRec): Boolean;
    class procedure InternalCheckDirPathParam(const Path: string;
        const ExistsCheck: Boolean); static;
    class procedure CheckCreateDirectoryParameters(const Path: string); inline; static;
    class procedure CheckCopyParameters(SourceDirName, DestDirName: string); static;
    class procedure CheckDeleteParameters(const Path: string;
        const Recursive: Boolean); static;
    class procedure CheckGetAttributesParameters(const Path: string); inline; static;
    class procedure CheckGetDirectoriesParameters(const Path: string;
        const SearchPattern: string); static;
    class procedure CheckGetDirectoryRootParameters(const Path: string); inline; static;
    class procedure CheckGetFilesParameters(Path: string;
        const SearchPattern: string); static;
    class procedure CheckGetFileSystemEntriesParameters(Path: string;
        const SearchPattern: string); static;
    class procedure CheckGetCreationTimeParameters(const Path: string); inline; static;
    class procedure CheckGetCreationTimeUtcParameters(const Path: string); inline; static;
    class procedure CheckGetLastAccessTimeParameters(const Path: string); inline; static;
    class procedure CheckGetLastAccessTimeUtcParameters(const Path: string); inline; static;
    class procedure CheckGetLastWriteTimeParameters(const Path: string); inline; static;
    class procedure CheckGetLastWriteTimeUtcParameters(const Path: string); inline; static;
    class procedure CheckGetParentParameters(const Path: string); inline; static;
    class procedure CheckMoveParameters(SourceDirName, DestDirName: string); static;
    class procedure CheckSetAttributesParameters(const Path: string); inline; static;
    class procedure CheckSetCurrentDirectoryParameters(const Path: string); inline; static;
    class procedure CheckSetCreationTimeParameters(const Path: string); static;
    class procedure CheckSetCreationTimeUtcParameters(const Path: string); static;
    class procedure CheckSetLastAccessTimeParameters(const Path: string); static;
    class procedure CheckSetLastAccessTimeUtcParameters(const Path: string); static;
    class procedure CheckSetLastWriteTimeParameters(const Path: string); static;
    class procedure CheckSetLastWriteTimeUtcParameters(const Path: string); static;
    class procedure GetDateTimeInfo(const Path: string; out CreationTime,
        LastAccessTime, LastWriteTime: TDateTime;
        const UseLocalTimeZone: Boolean); static;
    class procedure SetDateTimeInfo(const Path: string; const CreationTime,
        LastAccessTime, LastWriteTime: PDateTime;
        const UseLocalTimeZone: Boolean); static;
{$IFDEF MSWINDOWS}
    class function ConvertDateTimeToFileTime(const DateTime: TDateTime;
        const UseLocalTimeZone: Boolean): TFileTime; static;
{$ENDIF}
{$IFDEF POSIX}
    class function ConvertDateTimeToFileTime(const DateTime: TDateTime;
        const UseLocalTimeZone: Boolean): time_t; static;
{$ENDIF}
    class function DoGetCreationTime(const Path: string): TDateTime; inline; static;
    class function DoGetCreationTimeUtc(const Path: string): TDateTime; inline; static;
    class function DoGetLastAccessTime(const Path: string): TDateTime; inline; static;
    class function DoGetLastAccessTimeUtc(const Path: string): TDateTime; inline; static;
    class function DoGetLastWriteTime(const Path: string): TDateTime; inline; static;
    class function DoGetLastWriteTimeUtc(const Path: string): TDateTime; inline; static;
    class procedure DoSetCreationTime(const Path: string;
        const CreationTime: TDateTime); inline; static;
    class procedure DoSetCreationTimeUtc(const Path: string;
        const CreationTime: TDateTime); inline; static;
    class procedure DoSetLastAccessTime(const Path: string;
        const LastAccessTime: TDateTime); inline; static;
    class procedure DoSetLastAccessTimeUtc(const Path: string;
        const LastAccessTime: TDateTime); inline; static;
    class procedure DoSetLastWriteTime(const Path: string;
        const LastWriteTime: TDateTime); inline; static;
    class procedure DoSetLastWriteTimeUtc(const Path: string;
        const LastWriteTime: TDateTime); inline; static;
    class function DoGetFiles(const Path, SearchPattern: string;
        const SearchOption: TSearchOption;
        const Predicate: TFilterPredicate): TStringDynArray; static;
    class function DoGetDirectories(const Path, SearchPattern: string;
        const SearchOption: TSearchOption;
        const Predicate: TFilterPredicate): TStringDynArray; static;
    class function DoGetFileSystemEntries(const Path, SearchPattern: string;
        const SearchOption: TSearchOption;
        const Predicate: TFilterPredicate): TStringDynArray; overload; static;
    class procedure WalkThroughDirectory(const Path, Pattern: string;
        const PreCallback, PostCallback: TDirectoryWalkProc;
        const Recursive: Boolean); static;
  public
    class procedure Copy(const SourceDirName, DestDirName: string); static;
    class procedure CreateDirectory(const Path: string); static;
    class procedure Delete(const Path: string); overload; inline; static;
    class procedure Delete(const Path: string; const Recursive: Boolean);
        overload; static;
    class function Exists(const Path: string; FollowLink: Boolean = True): Boolean; inline; static;
    class function GetAttributes(const Path: string; FollowLink: Boolean = True): TFileAttributes; inline; static;
    class function GetCurrentDirectory: string; {$IFDEF MSWINDOWS} inline; {$ENDIF} static;
    class procedure SetCurrentDirectory(const Path: string); static;
    class function GetLogicalDrives: TStringDynArray; static;
    class function GetCreationTime(const Path: string): TDateTime; static;
    class function GetCreationTimeUtc(const Path: string): TDateTime; static;
    class function GetLastAccessTime(const Path: string): TDateTime; static;
    class function GetLastAccessTimeUtc(const Path: string): TDateTime; static;
    class function GetLastWriteTime(const Path: string): TDateTime; static;
    class function GetLastWriteTimeUtc(const Path: string): TDateTime; static;
    class procedure SetAttributes(const Path: string;
        const Attributes: TFileAttributes); inline; static;
    class procedure SetCreationTime(const Path: string;
        const CreationTime: TDateTime); static;
    class procedure SetCreationTimeUtc(const Path: string;
        const CreationTime: TDateTime); static;
    class procedure SetLastAccessTime(const Path: string;
        const LastAccessTime: TDateTime); static;
    class procedure SetLastAccessTimeUtc(const Path: string;
        const LastAccessTime: TDateTime); static;
    class procedure SetLastWriteTime(const Path: string;
        const LastWriteTime: TDateTime); static;
    class procedure SetLastWriteTimeUtc(const Path: string;
        const LastWriteTime: TDateTime); static;
    class function GetParent(const Path: string): string; static;
    class function GetDirectories(const Path: string): TStringDynArray;
        overload; inline; static;
    class function GetDirectories(const Path: string;
        const Predicate: TFilterPredicate): TStringDynArray;
        overload; inline; static;
    class function GetDirectories(const Path,
        SearchPattern: string): TStringDynArray; overload; inline; static;
    class function GetDirectories(const Path, SearchPattern: string;
        const Predicate: TFilterPredicate): TStringDynArray;
        overload; inline; static;
    class function GetDirectories(const Path, SearchPattern: string;
        const SearchOption: TSearchOption): TStringDynArray; overload; static;
    class function GetDirectories(const Path, SearchPattern: string;
        const SearchOption: TSearchOption;
        const Predicate: TFilterPredicate): TStringDynArray; overload; static;
    class function GetDirectories(const Path: string;
        const SearchOption: TSearchOption;
        const Predicate: TFilterPredicate): TStringDynArray; overload; static;
    class function GetDirectoryRoot(const Path: string): string; static;
    class function GetFiles(const Path: string): TStringDynArray;
        overload; inline; static;
    class function GetFiles(const Path: string;
        const Predicate: TFilterPredicate): TStringDynArray;
        overload; inline; static;
    class function GetFiles(const Path, SearchPattern: string): TStringDynArray;
        overload; inline; static;
    class function GetFiles(const Path, SearchPattern: string;
        const Predicate: TFilterPredicate): TStringDynArray;
        overload; inline; static;
    class function GetFiles(const Path, SearchPattern: string;
        const SearchOption: TSearchOption): TStringDynArray; overload; static;
    class function GetFiles(const Path, SearchPattern: string;
        const SearchOption: TSearchOption;
        const Predicate: TFilterPredicate): TStringDynArray; overload; static;
    class function GetFiles(const Path: string;
        const SearchOption: TSearchOption;
        const Predicate: TFilterPredicate): TStringDynArray; overload; static;
    class function GetFileSystemEntries(const Path: string): TStringDynArray;
        overload; inline; static;
    class function GetFileSystemEntries(const Path: string;
        const Predicate: TFilterPredicate): TStringDynArray;
        overload; inline; static;
    class function GetFileSystemEntries(const Path,
        SearchPattern: string): TStringDynArray; overload; static;
    class function GetFileSystemEntries(const Path, SearchPattern: string;
        const Predicate: TFilterPredicate): TStringDynArray; overload; static;
    class function GetFileSystemEntries(const Path: string;
        const SearchOption: TSearchOption;
        const Predicate: TFilterPredicate): TStringDynArray; overload; static;
    class function IsEmpty(const Path: string): Boolean; static;
    class function IsRelativePath(const Path: string): Boolean; inline; static;
    class procedure Move(const SourceDirName, DestDirName: string); static;
  end;

C++

struct DECLSPEC_DRECORD TDirectory
{
public:
    __interface TFilterPredicate;
    typedef System::DelphiInterface<TFilterPredicate> _di_TFilterPredicate;
    __interface TFilterPredicate  : public System::IInterface
    {
        virtual bool __fastcall Invoke(const System::UnicodeString Path, const System::Sysutils::TSearchRec &SearchRec) = 0 ;
    };
private:
    __interface TDirectoryWalkProc;
    typedef System::DelphiInterface<TDirectoryWalkProc> _di_TDirectoryWalkProc;
    __interface TDirectoryWalkProc  : public System::IInterface
    {
        virtual bool __fastcall Invoke(const System::UnicodeString Path, const System::Sysutils::TSearchRec &FileInfo) = 0 ;
    };
private:
    static void __fastcall InternalCheckDirPathParam(const System::UnicodeString Path, const bool ExistsCheck);
    static void __fastcall CheckCreateDirectoryParameters(const System::UnicodeString Path);
    static void __fastcall CheckCopyParameters(System::UnicodeString SourceDirName, System::UnicodeString DestDirName);
    static void __fastcall CheckDeleteParameters(const System::UnicodeString Path, const bool Recursive);
    static void __fastcall CheckGetAttributesParameters(const System::UnicodeString Path);
    static void __fastcall CheckGetDirectoriesParameters(const System::UnicodeString Path, const System::UnicodeString SearchPattern);
    static void __fastcall CheckGetDirectoryRootParameters(const System::UnicodeString Path);
    static void __fastcall CheckGetFilesParameters(System::UnicodeString Path, const System::UnicodeString SearchPattern);
    static void __fastcall CheckGetFileSystemEntriesParameters(System::UnicodeString Path, const System::UnicodeString SearchPattern);
    static void __fastcall CheckGetCreationTimeParameters(const System::UnicodeString Path);
    static void __fastcall CheckGetCreationTimeUtcParameters(const System::UnicodeString Path);
    static void __fastcall CheckGetLastAccessTimeParameters(const System::UnicodeString Path);
    static void __fastcall CheckGetLastAccessTimeUtcParameters(const System::UnicodeString Path);
    static void __fastcall CheckGetLastWriteTimeParameters(const System::UnicodeString Path);
    static void __fastcall CheckGetLastWriteTimeUtcParameters(const System::UnicodeString Path);
    static void __fastcall CheckGetParentParameters(const System::UnicodeString Path);
    static void __fastcall CheckMoveParameters(System::UnicodeString SourceDirName, System::UnicodeString DestDirName);
    static void __fastcall CheckSetAttributesParameters(const System::UnicodeString Path);
    static void __fastcall CheckSetCurrentDirectoryParameters(const System::UnicodeString Path);
    static void __fastcall CheckSetCreationTimeParameters(const System::UnicodeString Path);
    static void __fastcall CheckSetCreationTimeUtcParameters(const System::UnicodeString Path);
    static void __fastcall CheckSetLastAccessTimeParameters(const System::UnicodeString Path);
    static void __fastcall CheckSetLastAccessTimeUtcParameters(const System::UnicodeString Path);
    static void __fastcall CheckSetLastWriteTimeParameters(const System::UnicodeString Path);
    static void __fastcall CheckSetLastWriteTimeUtcParameters(const System::UnicodeString Path);
    static void __fastcall GetDateTimeInfo(const System::UnicodeString Path, /* out */ System::TDateTime &CreationTime, /* out */ System::TDateTime &LastAccessTime, /* out */ System::TDateTime &LastWriteTime, const bool UseLocalTimeZone);
    static void __fastcall SetDateTimeInfo(const System::UnicodeString Path, const System::PDateTime CreationTime, const System::PDateTime LastAccessTime, const System::PDateTime LastWriteTime, const bool UseLocalTimeZone);
    static _FILETIME __fastcall ConvertDateTimeToFileTime(const System::TDateTime DateTime, const bool UseLocalTimeZone);
    static System::TDateTime __fastcall DoGetCreationTime(const System::UnicodeString Path);
    static System::TDateTime __fastcall DoGetCreationTimeUtc(const System::UnicodeString Path);
    static System::TDateTime __fastcall DoGetLastAccessTime(const System::UnicodeString Path);
    static System::TDateTime __fastcall DoGetLastAccessTimeUtc(const System::UnicodeString Path);
    static System::TDateTime __fastcall DoGetLastWriteTime(const System::UnicodeString Path);
    static System::TDateTime __fastcall DoGetLastWriteTimeUtc(const System::UnicodeString Path);
    static void __fastcall DoSetCreationTime(const System::UnicodeString Path, const System::TDateTime CreationTime);
    static void __fastcall DoSetCreationTimeUtc(const System::UnicodeString Path, const System::TDateTime CreationTime);
    static void __fastcall DoSetLastAccessTime(const System::UnicodeString Path, const System::TDateTime LastAccessTime);
    static void __fastcall DoSetLastAccessTimeUtc(const System::UnicodeString Path, const System::TDateTime LastAccessTime);
    static void __fastcall DoSetLastWriteTime(const System::UnicodeString Path, const System::TDateTime LastWriteTime);
    static void __fastcall DoSetLastWriteTimeUtc(const System::UnicodeString Path, const System::TDateTime LastWriteTime);
    static System::TStringDynArray __fastcall DoGetFiles(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const TSearchOption SearchOption, const _di_TFilterPredicate Predicate);
    static System::TStringDynArray __fastcall DoGetDirectories(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const TSearchOption SearchOption, const _di_TFilterPredicate Predicate);
    static System::TStringDynArray __fastcall DoGetFileSystemEntries(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const TSearchOption SearchOption, const _di_TFilterPredicate Predicate)/* overload */;
    static void __fastcall WalkThroughDirectory(const System::UnicodeString Path, const System::UnicodeString Pattern, const _di_TDirectoryWalkProc PreCallback, const _di_TDirectoryWalkProc PostCallback, const bool Recursive);
public:
    static void __fastcall Copy(const System::UnicodeString SourceDirName, const System::UnicodeString DestDirName);
    static void __fastcall CreateDirectory(const System::UnicodeString Path);
    static void __fastcall Delete(const System::UnicodeString Path)/* overload */;
    static void __fastcall Delete(const System::UnicodeString Path, const bool Recursive)/* overload */;
    static bool __fastcall Exists(const System::UnicodeString Path, bool FollowLink = true);
    static TFileAttributes __fastcall GetAttributes(const System::UnicodeString Path, bool FollowLink = true);
    static System::UnicodeString __fastcall GetCurrentDirectory();
    static void __fastcall SetCurrentDirectory(const System::UnicodeString Path);
    static System::TStringDynArray __fastcall GetLogicalDrives();
    static System::TDateTime __fastcall GetCreationTime(const System::UnicodeString Path);
    static System::TDateTime __fastcall GetCreationTimeUtc(const System::UnicodeString Path);
    static System::TDateTime __fastcall GetLastAccessTime(const System::UnicodeString Path);
    static System::TDateTime __fastcall GetLastAccessTimeUtc(const System::UnicodeString Path);
    static System::TDateTime __fastcall GetLastWriteTime(const System::UnicodeString Path);
    static System::TDateTime __fastcall GetLastWriteTimeUtc(const System::UnicodeString Path);
    static void __fastcall SetAttributes(const System::UnicodeString Path, const TFileAttributes Attributes);
    static void __fastcall SetCreationTime(const System::UnicodeString Path, const System::TDateTime CreationTime);
    static void __fastcall SetCreationTimeUtc(const System::UnicodeString Path, const System::TDateTime CreationTime);
    static void __fastcall SetLastAccessTime(const System::UnicodeString Path, const System::TDateTime LastAccessTime);
    static void __fastcall SetLastAccessTimeUtc(const System::UnicodeString Path, const System::TDateTime LastAccessTime);
    static void __fastcall SetLastWriteTime(const System::UnicodeString Path, const System::TDateTime LastWriteTime);
    static void __fastcall SetLastWriteTimeUtc(const System::UnicodeString Path, const System::TDateTime LastWriteTime);
    static System::UnicodeString __fastcall GetParent(const System::UnicodeString Path);
    static System::TStringDynArray __fastcall GetDirectories(const System::UnicodeString Path)/* overload */;
    static System::TStringDynArray __fastcall GetDirectories(const System::UnicodeString Path, const _di_TFilterPredicate Predicate)/* overload */;
    static System::TStringDynArray __fastcall GetDirectories(const System::UnicodeString Path, const System::UnicodeString SearchPattern)/* overload */;
    static System::TStringDynArray __fastcall GetDirectories(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const _di_TFilterPredicate Predicate)/* overload */;
    static System::TStringDynArray __fastcall GetDirectories(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const TSearchOption SearchOption)/* overload */;
    static System::TStringDynArray __fastcall GetDirectories(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const TSearchOption SearchOption, const _di_TFilterPredicate Predicate)/* overload */;
    static System::TStringDynArray __fastcall GetDirectories(const System::UnicodeString Path, const TSearchOption SearchOption, const _di_TFilterPredicate Predicate)/* overload */;
    static System::UnicodeString __fastcall GetDirectoryRoot(const System::UnicodeString Path);
    static System::TStringDynArray __fastcall GetFiles(const System::UnicodeString Path)/* overload */;
    static System::TStringDynArray __fastcall GetFiles(const System::UnicodeString Path, const _di_TFilterPredicate Predicate)/* overload */;
    static System::TStringDynArray __fastcall GetFiles(const System::UnicodeString Path, const System::UnicodeString SearchPattern)/* overload */;
    static System::TStringDynArray __fastcall GetFiles(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const _di_TFilterPredicate Predicate)/* overload */;
    static System::TStringDynArray __fastcall GetFiles(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const TSearchOption SearchOption)/* overload */;
    static System::TStringDynArray __fastcall GetFiles(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const TSearchOption SearchOption, const _di_TFilterPredicate Predicate)/* overload */;
    static System::TStringDynArray __fastcall GetFiles(const System::UnicodeString Path, const TSearchOption SearchOption, const _di_TFilterPredicate Predicate)/* overload */;
    static System::TStringDynArray __fastcall GetFileSystemEntries(const System::UnicodeString Path)/* overload */;
    static System::TStringDynArray __fastcall GetFileSystemEntries(const System::UnicodeString Path, const _di_TFilterPredicate Predicate)/* overload */;
    static System::TStringDynArray __fastcall GetFileSystemEntries(const System::UnicodeString Path, const System::UnicodeString SearchPattern)/* overload */;
    static System::TStringDynArray __fastcall GetFileSystemEntries(const System::UnicodeString Path, const System::UnicodeString SearchPattern, const _di_TFilterPredicate Predicate)/* overload */;
    static System::TStringDynArray __fastcall GetFileSystemEntries(const System::UnicodeString Path, const TSearchOption SearchOption, const _di_TFilterPredicate Predicate)/* overload */;
    static bool __fastcall IsEmpty(const System::UnicodeString Path);
    static bool __fastcall IsRelativePath(const System::UnicodeString Path);
    static void __fastcall Move(const System::UnicodeString SourceDirName, const System::UnicodeString DestDirName);
};

プロパティ

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


説明

ディレクトリ操作で使われるたくさんの静的ユーティリティ メソッドを含んでいます。

TDirectory は、ディレクトリに対するさまざまな操作を実行するために使われる静的メソッドのみを含むレコードです。 TDirectory はインスタンス メソッドやフィールドを持たないため、TDirectory 型の変数を宣言してはいけません。 TDirectory を使用して実行できる操作には、以下のものがあります。

  • ディレクトリの作成、名前変更、および削除。
  • ディレクトリの走査(再帰的な走査も含む)。
  • ディレクトリの属性およびタイムスタンプの操作。

メモ: TDirectory が公開しているメソッドのほとんどは、.NET FrameworkDirectory クラスが公開しているメソッドとシグネチャの互換性があります。

関連項目