diff options
Diffstat (limited to '')
-rw-r--r-- | unicode/src/base/UFilesystem.pas | 168 | ||||
-rw-r--r-- | unicode/src/base/UPath.pas | 42 |
2 files changed, 105 insertions, 105 deletions
diff --git a/unicode/src/base/UFilesystem.pas b/unicode/src/base/UFilesystem.pas index 5f7e8c34..a28b1f39 100644 --- a/unicode/src/base/UFilesystem.pas +++ b/unicode/src/base/UFilesystem.pas @@ -50,9 +50,9 @@ type {$ENDIF} TFileInfo = record - Time: Integer; // timestamp - Size: Int64; // file size (byte) - Attr: Integer; // file attributes + Time: integer; // timestamp + Size: int64; // file size (byte) + Attr: integer; // file attributes Name: IPath; // basename with extension end; @@ -63,7 +63,7 @@ type * SearchRec := Iter.Next(); *} IFileIterator = interface - function HasNext(): Boolean; + function HasNext(): boolean; function Next(): TFileInfo; end; @@ -74,36 +74,36 @@ type IFileSystem = interface function ExpandFileName(const FileName: IPath): IPath; function FileCreate(const FileName: IPath): THandle; - function DirectoryCreate(const Dir: IPath): Boolean; - function FileOpen(const FileName: IPath; Mode: LongWord): THandle; - function FileAge(const FileName: IPath): Integer; overload; - function FileAge(const FileName: IPath; out FileDateTime: TDateTime): Boolean; overload; + function DirectoryCreate(const Dir: IPath): boolean; + function FileOpen(const FileName: IPath; Mode: longword): THandle; + function FileAge(const FileName: IPath): integer; overload; + function FileAge(const FileName: IPath; out FileDateTime: TDateTime): boolean; overload; - function DirectoryExists(const Name: IPath): Boolean; + function DirectoryExists(const Name: IPath): boolean; {** * On Windows: returns true only for files (not directories) * On Apple/Unix: returns true for all kind of files (even directories) * @seealso SysUtils.FileExists() *} - function FileExists(const Name: IPath): Boolean; + function FileExists(const Name: IPath): boolean; function FileGetAttr(const FileName: IPath): Cardinal; - function FileSetAttr(const FileName: IPath; Attr: Integer): Boolean; - function FileIsReadOnly(const FileName: IPath): Boolean; - function FileSetReadOnly(const FileName: IPath; ReadOnly: Boolean): Boolean; - function FileIsAbsolute(const FileName: IPath): Boolean; - function ForceDirectories(const Dir: IPath): Boolean; - function RenameFile(const OldName, NewName: IPath): Boolean; - function DeleteFile(const FileName: IPath): Boolean; - function RemoveDir(const Dir: IPath): Boolean; + function FileSetAttr(const FileName: IPath; Attr: integer): boolean; + function FileIsReadOnly(const FileName: IPath): boolean; + function FileSetReadOnly(const FileName: IPath; ReadOnly: boolean): boolean; + function FileIsAbsolute(const FileName: IPath): boolean; + function ForceDirectories(const Dir: IPath): boolean; + function RenameFile(const OldName, NewName: IPath): boolean; + function DeleteFile(const FileName: IPath): boolean; + function RemoveDir(const Dir: IPath): boolean; {** * Copies file Source to Target. If FailIfExists is true, the file is not * copied if it already exists. * Returns true if the file was successfully copied. *} - function CopyFile(const Source, Target: IPath; FailIfExists: Boolean): Boolean; + function CopyFile(const Source, Target: IPath; FailIfExists: boolean): boolean; function ExtractFileDrive(const FileName: IPath): IPath; function ExtractFilePath(const FileName: IPath): IPath; @@ -125,17 +125,17 @@ type {** * More convenient version of FindFirst/Next/Close with iterator support. *} - function FileFind(const FilePattern: IPath; Attr: Integer): IFileIterator; + function FileFind(const FilePattern: IPath; Attr: integer): IFileIterator; {** * Old style search functions. Use FileFind() instead. *} - function FindFirst(const FilePattern: IPath; Attr: Integer; var F: TSytemSearchRec): Integer; - function FindNext(var F: TSytemSearchRec): Integer; + function FindFirst(const FilePattern: IPath; Attr: integer; var F: TSytemSearchRec): integer; + function FindNext(var F: TSytemSearchRec): integer; procedure FindClose(var F: TSytemSearchRec); function GetCurrentDir: IPath; - function SetCurrentDir(const Dir: IPath): Boolean; + function SetCurrentDir(const Dir: IPath): boolean; {** * Returns true if the filesystem is case-sensitive. @@ -152,22 +152,22 @@ type public function ExpandFileName(const FileName: IPath): IPath; function FileCreate(const FileName: IPath): THandle; - function DirectoryCreate(const Dir: IPath): Boolean; - function FileOpen(const FileName: IPath; Mode: LongWord): THandle; - function FileAge(const FileName: IPath): Integer; overload; - function FileAge(const FileName: IPath; out FileDateTime: TDateTime): Boolean; overload; - function DirectoryExists(const Name: IPath): Boolean; - function FileExists(const Name: IPath): Boolean; + function DirectoryCreate(const Dir: IPath): boolean; + function FileOpen(const FileName: IPath; Mode: longword): THandle; + function FileAge(const FileName: IPath): integer; overload; + function FileAge(const FileName: IPath; out FileDateTime: TDateTime): boolean; overload; + function DirectoryExists(const Name: IPath): boolean; + function FileExists(const Name: IPath): boolean; function FileGetAttr(const FileName: IPath): Cardinal; - function FileSetAttr(const FileName: IPath; Attr: Integer): Boolean; - function FileIsReadOnly(const FileName: IPath): Boolean; - function FileSetReadOnly(const FileName: IPath; ReadOnly: Boolean): Boolean; - function FileIsAbsolute(const FileName: IPath): Boolean; - function ForceDirectories(const Dir: IPath): Boolean; - function RenameFile(const OldName, NewName: IPath): Boolean; - function DeleteFile(const FileName: IPath): Boolean; - function RemoveDir(const Dir: IPath): Boolean; - function CopyFile(const Source, Target: IPath; FailIfExists: Boolean): Boolean; + function FileSetAttr(const FileName: IPath; Attr: integer): boolean; + function FileIsReadOnly(const FileName: IPath): boolean; + function FileSetReadOnly(const FileName: IPath; ReadOnly: boolean): boolean; + function FileIsAbsolute(const FileName: IPath): boolean; + function ForceDirectories(const Dir: IPath): boolean; + function RenameFile(const OldName, NewName: IPath): boolean; + function DeleteFile(const FileName: IPath): boolean; + function RemoveDir(const Dir: IPath): boolean; + function CopyFile(const Source, Target: IPath; FailIfExists: boolean): boolean; function ExtractFileDrive(const FileName: IPath): IPath; function ExtractFilePath(const FileName: IPath): IPath; @@ -180,27 +180,27 @@ type function ExcludeTrailingPathDelimiter(const FileName: IPath): IPath; function FileSearch(const Name: IPath; DirList: array of IPath): IPath; - function FileFind(const FilePattern: IPath; Attr: Integer): IFileIterator; + function FileFind(const FilePattern: IPath; Attr: integer): IFileIterator; - function FindFirst(const FilePattern: IPath; Attr: Integer; var F: TSytemSearchRec): Integer; - function FindNext(var F: TSytemSearchRec): Integer; + function FindFirst(const FilePattern: IPath; Attr: integer; var F: TSytemSearchRec): integer; + function FindNext(var F: TSytemSearchRec): integer; procedure FindClose(var F: TSytemSearchRec); function GetCurrentDir: IPath; - function SetCurrentDir(const Dir: IPath): Boolean; + function SetCurrentDir(const Dir: IPath): boolean; function IsCaseSensitive(): boolean; end; TFileIterator = class(TInterfacedObject, IFileIterator) private - fHasNext: Boolean; + fHasNext: boolean; fSearchRec: TSytemSearchRec; public - constructor Create(const FilePattern: IPath; Attr: Integer); + constructor Create(const FilePattern: IPath; Attr: integer); destructor Destroy(); override; - function HasNext(): Boolean; + function HasNext(): boolean; function Next(): TFileInfo; end; @@ -213,7 +213,7 @@ begin Result := FileSystem_Singleton; end; -function TFileSystemImpl.FileFind(const FilePattern: IPath; Attr: Integer): IFileIterator; +function TFileSystemImpl.FileFind(const FilePattern: IPath; Attr: integer): IFileIterator; begin Result := TFileIterator.Create(FilePattern, Attr); end; @@ -228,7 +228,7 @@ begin {$IFEND} end; -function TFileSystemImpl.FileIsAbsolute(const FileName: IPath): Boolean; +function TFileSystemImpl.FileIsAbsolute(const FileName: IPath): boolean; var NameStr: UTF8String; begin @@ -264,32 +264,32 @@ begin Result := WideFileCreate(FileName.ToWide()); end; -function TFileSystemImpl.DirectoryCreate(const Dir: IPath): Boolean; +function TFileSystemImpl.DirectoryCreate(const Dir: IPath): boolean; begin Result := WideCreateDir(Dir.ToWide()); end; -function TFileSystemImpl.FileOpen(const FileName: IPath; Mode: LongWord): THandle; +function TFileSystemImpl.FileOpen(const FileName: IPath; Mode: longword): THandle; begin Result := WideFileOpen(FileName.ToWide(), Mode); end; -function TFileSystemImpl.FileAge(const FileName: IPath): Integer; +function TFileSystemImpl.FileAge(const FileName: IPath): integer; begin Result := WideFileAge(FileName.ToWide()); end; -function TFileSystemImpl.FileAge(const FileName: IPath; out FileDateTime: TDateTime): Boolean; +function TFileSystemImpl.FileAge(const FileName: IPath; out FileDateTime: TDateTime): boolean; begin Result := WideFileAge(FileName.ToWide(), FileDateTime); end; -function TFileSystemImpl.DirectoryExists(const Name: IPath): Boolean; +function TFileSystemImpl.DirectoryExists(const Name: IPath): boolean; begin Result := WideDirectoryExists(Name.ToWide()); end; -function TFileSystemImpl.FileExists(const Name: IPath): Boolean; +function TFileSystemImpl.FileExists(const Name: IPath): boolean; begin Result := WideFileExists(Name.ToWide()); end; @@ -299,22 +299,22 @@ begin Result := WideFileGetAttr(FileName.ToWide()); end; -function TFileSystemImpl.FileSetAttr(const FileName: IPath; Attr: Integer): Boolean; +function TFileSystemImpl.FileSetAttr(const FileName: IPath; Attr: integer): boolean; begin Result := WideFileSetAttr(FileName.ToWide(), Attr); end; -function TFileSystemImpl.FileIsReadOnly(const FileName: IPath): Boolean; +function TFileSystemImpl.FileIsReadOnly(const FileName: IPath): boolean; begin Result := WideFileIsReadOnly(FileName.ToWide()); end; -function TFileSystemImpl.FileSetReadOnly(const FileName: IPath; ReadOnly: Boolean): Boolean; +function TFileSystemImpl.FileSetReadOnly(const FileName: IPath; ReadOnly: boolean): boolean; begin Result := WideFileSetReadOnly(FileName.ToWide(), ReadOnly); end; -function TFileSystemImpl.ForceDirectories(const Dir: IPath): Boolean; +function TFileSystemImpl.ForceDirectories(const Dir: IPath): boolean; begin Result := WideForceDirectories(Dir.ToWide()); end; @@ -334,22 +334,22 @@ begin Result := Path(WideFileSearch(Name.ToWide(), DirListStr)); end; -function TFileSystemImpl.RenameFile(const OldName, NewName: IPath): Boolean; +function TFileSystemImpl.RenameFile(const OldName, NewName: IPath): boolean; begin Result := WideRenameFile(OldName.ToWide(), NewName.ToWide()); end; -function TFileSystemImpl.DeleteFile(const FileName: IPath): Boolean; +function TFileSystemImpl.DeleteFile(const FileName: IPath): boolean; begin Result := WideDeleteFile(FileName.ToWide()); end; -function TFileSystemImpl.RemoveDir(const Dir: IPath): Boolean; +function TFileSystemImpl.RemoveDir(const Dir: IPath): boolean; begin Result := WideRemoveDir(Dir.ToWide()); end; -function TFileSystemImpl.CopyFile(const Source, Target: IPath; FailIfExists: Boolean): Boolean; +function TFileSystemImpl.CopyFile(const Source, Target: IPath; FailIfExists: boolean): boolean; begin Result := WideCopyFile(Source.ToWide(), Target.ToWide(), FailIfExists); end; @@ -399,12 +399,12 @@ begin Result := Path(WideExcludeTrailingPathDelimiter(FileName.ToWide())); end; -function TFileSystemImpl.FindFirst(const FilePattern: IPath; Attr: Integer; var F: TSytemSearchRec): Integer; +function TFileSystemImpl.FindFirst(const FilePattern: IPath; Attr: integer; var F: TSytemSearchRec): integer; begin Result := WideFindFirst(FilePattern.ToWide(), Attr, F); end; -function TFileSystemImpl.FindNext(var F: TSytemSearchRec): Integer; +function TFileSystemImpl.FindNext(var F: TSytemSearchRec): integer; begin Result := WideFindNext(F); end; @@ -419,7 +419,7 @@ begin Result := Path(WideGetCurrentDir()); end; -function TFileSystemImpl.SetCurrentDir(const Dir: IPath): Boolean; +function TFileSystemImpl.SetCurrentDir(const Dir: IPath): boolean; begin Result := WideSetCurrentDir(Dir.ToWide()); end; @@ -436,24 +436,24 @@ begin Result := SysUtils.FileCreate(FileName.ToNative()); end; -function TFileSystemImpl.DirectoryCreate(const Dir: IPath): Boolean; +function TFileSystemImpl.DirectoryCreate(const Dir: IPath): boolean; begin Result := SysUtils.CreateDir(Dir.ToNative()); end; -function TFileSystemImpl.FileOpen(const FileName: IPath; Mode: LongWord): THandle; +function TFileSystemImpl.FileOpen(const FileName: IPath; Mode: longword): THandle; begin Result := SysUtils.FileOpen(FileName.ToNative(), Mode); end; -function TFileSystemImpl.FileAge(const FileName: IPath): Integer; +function TFileSystemImpl.FileAge(const FileName: IPath): integer; begin Result := SysUtils.FileAge(FileName.ToNative()); end; -function TFileSystemImpl.FileAge(const FileName: IPath; out FileDateTime: TDateTime): Boolean; +function TFileSystemImpl.FileAge(const FileName: IPath; out FileDateTime: TDateTime): boolean; var - FileDate: Integer; + FileDate: integer; begin FileDate := SysUtils.FileAge(FileName.ToNative()); Result := (FileDate <> -1); @@ -461,12 +461,12 @@ begin FileDateTime := FileDateToDateTime(FileDate); end; -function TFileSystemImpl.DirectoryExists(const Name: IPath): Boolean; +function TFileSystemImpl.DirectoryExists(const Name: IPath): boolean; begin Result := SysUtils.DirectoryExists(Name.ToNative()); end; -function TFileSystemImpl.FileExists(const Name: IPath): Boolean; +function TFileSystemImpl.FileExists(const Name: IPath): boolean; begin Result := SysUtils.FileExists(Name.ToNative()); end; @@ -476,22 +476,22 @@ begin Result := SysUtils.FileGetAttr(FileName.ToNative()); end; -function TFileSystemImpl.FileSetAttr(const FileName: IPath; Attr: Integer): Boolean; +function TFileSystemImpl.FileSetAttr(const FileName: IPath; Attr: integer): boolean; begin Result := (SysUtils.FileSetAttr(FileName.ToNative(), Attr) = 0); end; -function TFileSystemImpl.FileIsReadOnly(const FileName: IPath): Boolean; +function TFileSystemImpl.FileIsReadOnly(const FileName: IPath): boolean; begin Result := SysUtils.FileIsReadOnly(FileName.ToNative()); end; -function TFileSystemImpl.FileSetReadOnly(const FileName: IPath; ReadOnly: Boolean): Boolean; +function TFileSystemImpl.FileSetReadOnly(const FileName: IPath; ReadOnly: boolean): boolean; begin Result := (SysUtils.FileSetAttr(FileName.ToNative(), faReadOnly) = 0); end; -function TFileSystemImpl.ForceDirectories(const Dir: IPath): Boolean; +function TFileSystemImpl.ForceDirectories(const Dir: IPath): boolean; begin Result := SysUtils.ForceDirectories(Dir.ToNative()); end; @@ -511,22 +511,22 @@ begin Result := Path(SysUtils.FileSearch(Name.ToNative(), DirListStr)); end; -function TFileSystemImpl.RenameFile(const OldName, NewName: IPath): Boolean; +function TFileSystemImpl.RenameFile(const OldName, NewName: IPath): boolean; begin Result := SysUtils.RenameFile(OldName.ToNative(), NewName.ToNative()); end; -function TFileSystemImpl.DeleteFile(const FileName: IPath): Boolean; +function TFileSystemImpl.DeleteFile(const FileName: IPath): boolean; begin Result := SysUtils.DeleteFile(FileName.ToNative()); end; -function TFileSystemImpl.RemoveDir(const Dir: IPath): Boolean; +function TFileSystemImpl.RemoveDir(const Dir: IPath): boolean; begin Result := SysUtils.RemoveDir(Dir.ToNative()); end; -function TFileSystemImpl.CopyFile(const Source, Target: IPath; FailIfExists: Boolean): Boolean; +function TFileSystemImpl.CopyFile(const Source, Target: IPath; FailIfExists: boolean): boolean; const COPY_BUFFER_SIZE = 4096; // a good tradeoff between speed and memory consumption var @@ -614,12 +614,12 @@ begin Result := Path(SysUtils.ExcludeTrailingPathDelimiter(FileName.ToNative())); end; -function TFileSystemImpl.FindFirst(const FilePattern: IPath; Attr: Integer; var F: TSytemSearchRec): Integer; +function TFileSystemImpl.FindFirst(const FilePattern: IPath; Attr: integer; var F: TSytemSearchRec): integer; begin Result := SysUtils.FindFirst(FilePattern.ToNative(), Attr, F); end; -function TFileSystemImpl.FindNext(var F: TSytemSearchRec): Integer; +function TFileSystemImpl.FindNext(var F: TSytemSearchRec): integer; begin Result := SysUtils.FindNext(F); end; @@ -634,7 +634,7 @@ begin Result := Path(SysUtils.GetCurrentDir()); end; -function TFileSystemImpl.SetCurrentDir(const Dir: IPath): Boolean; +function TFileSystemImpl.SetCurrentDir(const Dir: IPath): boolean; begin Result := SysUtils.SetCurrentDir(Dir.ToNative()); end; @@ -644,7 +644,7 @@ end; { TFileIterator } -constructor TFileIterator.Create(const FilePattern: IPath; Attr: Integer); +constructor TFileIterator.Create(const FilePattern: IPath; Attr: integer); begin inherited Create(); fHasNext := (FileSystem.FindFirst(FilePattern, Attr, fSearchRec) = 0); @@ -656,7 +656,7 @@ begin inherited; end; -function TFileIterator.HasNext(): Boolean; +function TFileIterator.HasNext(): boolean; begin Result := fHasNext; end; diff --git a/unicode/src/base/UPath.pas b/unicode/src/base/UPath.pas index c74d1a16..eeec5b74 100644 --- a/unicode/src/base/UPath.pas +++ b/unicode/src/base/UPath.pas @@ -65,7 +65,7 @@ type {** * @seealso TFileStream.Create for valid Mode parameters *} - constructor Create(const FileName: IPath; Mode: Word); + constructor Create(const FileName: IPath; Mode: word); end; {** @@ -79,7 +79,7 @@ type function ReadLine(var Success: boolean): RawByteString; overload; virtual; abstract; public - constructor Create(Filename: IPath; Mode: Word); + constructor Create(Filename: IPath; Mode: word); function ReadString(): RawByteString; virtual; abstract; function ReadLine(var Line: UTF8String): boolean; overload; @@ -99,20 +99,20 @@ type private fStream: TMemoryStream; protected - function GetSize: Int64; override; + function GetSize: int64; override; {** * Copies fStream.Memory from StartPos to EndPos-1 to the result string; *} function CopyMemString(StartPos: int64; EndPos: int64): RawByteString; public - constructor Create(Filename: IPath; Mode: Word); + constructor Create(Filename: IPath; Mode: word); destructor Destroy(); override; - function Read(var Buffer; Count: Longint): Longint; override; - function Write(const Buffer; Count: Longint): Longint; override; - function Seek(Offset: Longint; Origin: Word): Longint; override; - function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override; + function Read(var Buffer; Count: longint): longint; override; + function Write(const Buffer; Count: longint): longint; override; + function Seek(Offset: longint; Origin: word): longint; override; + function Seek(const Offset: int64; Origin: TSeekOrigin): int64; override; function ReadLine(var Success: boolean): RawByteString; override; function ReadString(): RawByteString; override; @@ -200,7 +200,7 @@ type * Note: File must be closed with FileClose(Handle) after usage * @seealso SysUtils.FileOpen() *} - function Open(Mode: LongWord): THandle; + function Open(Mode: longword): THandle; {** @seealso SysUtils.ExtractFileDrive() *} function GetDrive(): IPath; @@ -383,7 +383,7 @@ type function ToWide(UseNativeDelim: boolean): WideString; function ToNative(): RawByteString; - function Open(Mode: LongWord): THandle; + function Open(Mode: longword): THandle; function GetDrive(): IPath; function GetPath(): IPath; @@ -460,7 +460,7 @@ procedure TPathImpl.AssertRefCount; begin {$IFDEF FPC} if (FRefCount <= 0) then - raise Exception.Create('RefCount error: ' + inttostr(FRefCount)); + raise Exception.Create('RefCount error: ' + IntToStr(FRefCount)); {$ENDIF} end; @@ -873,7 +873,7 @@ begin Result := FileSystem.DirectoryCreate(Self); end; -function TPathImpl.Open(Mode: LongWord): THandle; +function TPathImpl.Open(Mode: longword): THandle; begin Result := FileSystem.FileOpen(Self, Mode); end; @@ -978,7 +978,7 @@ end; { TBinaryFileStream } -constructor TBinaryFileStream.Create(const FileName: IPath; Mode: Word); +constructor TBinaryFileStream.Create(const FileName: IPath; Mode: word); begin {$IFDEF MSWINDOWS} inherited Create(FileName.ToWide(), Mode); @@ -989,7 +989,7 @@ end; { TTextStream } -constructor TTextFileStream.Create(Filename: IPath; Mode: Word); +constructor TTextFileStream.Create(Filename: IPath; Mode: word); begin inherited Create(); fMode := Mode; @@ -1020,7 +1020,7 @@ end; { TMemTextStream } -constructor TMemTextFileStream.Create(Filename: IPath; Mode: Word); +constructor TMemTextFileStream.Create(Filename: IPath; Mode: word); var FileStream: TBinaryFileStream; begin @@ -1070,27 +1070,27 @@ begin inherited; end; -function TMemTextFileStream.GetSize: Int64; +function TMemTextFileStream.GetSize: int64; begin Result := fStream.Size; end; -function TMemTextFileStream.Read(var Buffer; Count: Longint): Longint; +function TMemTextFileStream.Read(var Buffer; Count: longint): longint; begin Result := fStream.Read(Buffer, Count); end; -function TMemTextFileStream.Write(const Buffer; Count: Longint): Longint; +function TMemTextFileStream.Write(const Buffer; Count: longint): longint; begin Result := fStream.Write(Buffer, Count); end; -function TMemTextFileStream.Seek(Offset: Longint; Origin: Word): Longint; +function TMemTextFileStream.Seek(Offset: longint; Origin: word): longint; begin Result := fStream.Seek(Offset, Origin); end; -function TMemTextFileStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; +function TMemTextFileStream.Seek(const Offset: int64; Origin: TSeekOrigin): int64; begin Result := fStream.Seek(Offset, Origin); end; @@ -1119,7 +1119,7 @@ end; function TMemTextFileStream.ReadString(): RawByteString; var TextPtr: PAnsiChar; - CurPos, StartPos, FileSize: Int64; + CurPos, StartPos, FileSize: int64; begin TextPtr := PAnsiChar(fStream.Memory); CurPos := Position; |