mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-20 19:19:31 +01:00
FileUtil: inline FileSize to LazFileUtils.FileSizeUtf8.
git-svn-id: trunk@41295 -
This commit is contained in:
parent
3b1ac2f83d
commit
ef3320295a
@ -69,6 +69,11 @@ begin
|
|||||||
Result := LazFileUtils.FileSetDateUTF8(FileName, Age);
|
Result := LazFileUtils.FileSetDateUTF8(FileName, Age);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function FileSize(const Filename: string): int64;
|
||||||
|
begin
|
||||||
|
Result := LazFileUtils.FileSizeUtf8(FileName);
|
||||||
|
end;
|
||||||
|
|
||||||
{$IFDEF darwin}
|
{$IFDEF darwin}
|
||||||
function GetDarwinSystemFilename(Filename: string): string;
|
function GetDarwinSystemFilename(Filename: string): string;
|
||||||
var
|
var
|
||||||
|
|||||||
@ -58,7 +58,7 @@ function FileIsText(const AFilename: string; out FileReadable: boolean): boolean
|
|||||||
function FileIsExecutable(const AFilename: string): boolean;
|
function FileIsExecutable(const AFilename: string): boolean;
|
||||||
function FileIsSymlink(const AFilename: string): boolean;
|
function FileIsSymlink(const AFilename: string): boolean;
|
||||||
function FileIsHardLink(const AFilename: string): boolean;
|
function FileIsHardLink(const AFilename: string): boolean;
|
||||||
function FileSize(const Filename: string): int64; overload;
|
function FileSize(const Filename: string): int64; overload; inline;
|
||||||
function GetFileDescription(const AFilename: string): string;
|
function GetFileDescription(const AFilename: string): string;
|
||||||
function ReadAllLinks(const Filename: string;
|
function ReadAllLinks(const Filename: string;
|
||||||
ExceptionOnError: boolean): string; // if a link is broken returns ''
|
ExceptionOnError: boolean): string; // if a link is broken returns ''
|
||||||
|
|||||||
@ -123,20 +123,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
FileSize
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
function FileSize(const Filename: string): int64;
|
|
||||||
var
|
|
||||||
st: baseunix.stat;
|
|
||||||
begin
|
|
||||||
if not fpstat(pointer(Filename),st{%H-})>=0 then
|
|
||||||
exit(-1);
|
|
||||||
Result:=st.st_size;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
GetFileDescription
|
GetFileDescription
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
|
|||||||
@ -197,50 +197,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
|
||||||
FileSize
|
|
||||||
------------------------------------------------------------------------------}
|
|
||||||
{$ifndef WinCE}
|
|
||||||
function FileSizeAnsi(const Filename: string): int64;
|
|
||||||
var
|
|
||||||
FindData: TWIN32FindDataA;
|
|
||||||
FindHandle: THandle;
|
|
||||||
Str: AnsiString;
|
|
||||||
begin
|
|
||||||
// Fix for the bug 14360:
|
|
||||||
// Don't assign the widestring to TSearchRec.name because it is of type
|
|
||||||
// string, which will generate a conversion to the system encoding
|
|
||||||
Str := Utf8ToAnsi(Filename);
|
|
||||||
FindHandle:=Windows.FindFirstFileA(PAnsiChar(Str), FindData);
|
|
||||||
if FindHandle=Windows.Invalid_Handle_value then
|
|
||||||
begin
|
|
||||||
Result:=-1;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
Result:=(int64(FindData.nFileSizeHigh) shl 32)+FindData.nFileSizeLow;
|
|
||||||
Windows.FindClose(FindHandle);
|
|
||||||
end;
|
|
||||||
{$endif}
|
|
||||||
|
|
||||||
function FileSizeWide(const Filename: string): int64;
|
|
||||||
var
|
|
||||||
FindData: TWIN32FindDataW;
|
|
||||||
FindHandle: THandle;
|
|
||||||
Str: WideString;
|
|
||||||
begin
|
|
||||||
// Fix for the bug 14360:
|
|
||||||
// Don't assign the widestring to TSearchRec.name because it is of type
|
|
||||||
// string, which will generate a conversion to the system encoding
|
|
||||||
Str := UTF8Decode(Filename);
|
|
||||||
FindHandle:=Windows.FindFirstFileW(PWideChar(Str), FindData);
|
|
||||||
if FindHandle=Windows.Invalid_Handle_value then
|
|
||||||
begin
|
|
||||||
Result:=-1;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
Result:=(int64(FindData.nFileSizeHigh) shl 32)+FindData.nFileSizeLow;
|
|
||||||
Windows.FindClose(FindHandle);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
@ -490,7 +446,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
FileSize_ : function (const Filename: string): int64 = @FileSizeWide;
|
|
||||||
FindFirst_ : function (const Path: string; Attr: Longint;
|
FindFirst_ : function (const Path: string; Attr: Longint;
|
||||||
out Rslt: TSearchRec): Longint = @FindFirstWide;
|
out Rslt: TSearchRec): Longint = @FindFirstWide;
|
||||||
FindNext_ : function (var Rslt: TSearchRec): Longint = @FindNextWide;
|
FindNext_ : function (var Rslt: TSearchRec): Longint = @FindNextWide;
|
||||||
@ -505,11 +460,6 @@ var
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
function FileSize(const Filename: string): int64;
|
|
||||||
begin
|
|
||||||
Result:=FileSize_(FileName);
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
function FindFirstUTF8(const Path: string; Attr: Longint; out Rslt: TSearchRec): Longint;
|
function FindFirstUTF8(const Path: string; Attr: Longint; out Rslt: TSearchRec): Longint;
|
||||||
begin
|
begin
|
||||||
@ -591,7 +541,6 @@ begin
|
|||||||
{$ifndef WinCE}
|
{$ifndef WinCE}
|
||||||
if Win32MajorVersion <= 4 then
|
if Win32MajorVersion <= 4 then
|
||||||
begin
|
begin
|
||||||
FileSize_:=@FileSizeAnsi;
|
|
||||||
DeleteFile_:=@DeleteFileAnsi;
|
DeleteFile_:=@DeleteFileAnsi;
|
||||||
RenameFile_:=@RenameFileAnsi;
|
RenameFile_:=@RenameFileAnsi;
|
||||||
SetCurrentDir_:=@SetCurrentDirAnsi;
|
SetCurrentDir_:=@SetCurrentDirAnsi;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user