Show: Delphi C++
Display Preferences

System.IOUtils.TDirectory

From XE2 API Documentation
Jump to: navigation, search

Delphi

  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(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; inline; static;

C++

struct DECLSPEC_DRECORD TDirectory{
public:
__interface TFilterPredicate;
typedef System::DelphiInterface<TFilterPredicate> _di_TFilterPredicate;
__interface TFilterPredicate  : public System::IInterface
{
public:
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
{
public:
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(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);
};

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 directory manipulations.

TDirectory is a record containing only static methods used to perform various operations on directories. You should not declare variables of type TDirectory, since TDirectory has no instance methods or fields. Possible operations that can be completed using TDirectory include:

  • Creating, renaming, and deleting directories.
  • Traversing directories (also recursively).
  • Manipulating directory attributes and timestamps.
Note: Most of the methods exposed by TDirectory are signature-compatible with the ones exposed by the Directory class in the .NET Framework.

See Also

Personal tools
Previous Versions
Translations