mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-19 09:09:32 +02:00
LazUtils: added GetUnixPhysicalFilename
git-svn-id: trunk@44578 -
This commit is contained in:
parent
877c4d50b9
commit
3595a693a9
@ -106,6 +106,10 @@ function GetFileDescription(const AFilename: string): string;
|
||||
function ReadAllLinks(const Filename: string;
|
||||
ExceptionOnError: boolean): string; // if a link is broken returns ''
|
||||
function TryReadAllLinks(const Filename: string): string; // if a link is broken returns Filename
|
||||
{$IFDEF Unix}
|
||||
function GetUnixPhysicalFilename(const Filename: string;
|
||||
ExceptionOnError: boolean): string; // if a link is broken returns ''
|
||||
{$ENDIF}
|
||||
|
||||
function GetAppConfigDirUTF8(Global: Boolean; Create: boolean = false): string;
|
||||
function GetAppConfigFileUTF8(Global: Boolean; SubDir: boolean = false;
|
||||
|
@ -5,22 +5,23 @@ begin
|
||||
Result:=FilenameIsUnixAbsolute(TheFilename);
|
||||
end;
|
||||
|
||||
function FileOpenUTF8(Const FileName : string; Mode : Integer) : THandle;
|
||||
function FileOpenUTF8(const FileName: string; Mode: Integer): THandle;
|
||||
begin
|
||||
Result := SysUtils.FileOpen(UTF8ToSys(FileName), Mode);
|
||||
end;
|
||||
|
||||
function FileCreateUTF8(Const FileName : string) : THandle;
|
||||
function FileCreateUTF8(const FileName: string): THandle;
|
||||
begin
|
||||
Result := SysUtils.FileCreate(UTF8ToSys(FileName));
|
||||
end;
|
||||
|
||||
function FileCreateUTF8(Const FileName : string; Rights: Cardinal) : THandle;
|
||||
function FileCreateUTF8(const FileName: string; Rights: Cardinal): THandle;
|
||||
begin
|
||||
Result := SysUtils.FileCreate(UTF8ToSys(FileName), Rights);
|
||||
end;
|
||||
|
||||
Function FileCreateUtf8(Const FileName : String; ShareMode : Integer; Rights : Cardinal) : THandle;
|
||||
function FileCreateUtf8(const FileName: String; ShareMode: Integer;
|
||||
Rights: Cardinal): THandle;
|
||||
begin
|
||||
Result := SysUtils.FileCreate(UTF8ToSys(FileName), ShareMode, Rights);
|
||||
end;
|
||||
@ -46,7 +47,7 @@ begin
|
||||
Result:=SysUtils.DirectoryExists(UTF8ToSys(Directory));
|
||||
end;
|
||||
|
||||
function FileAgeUTF8(const FileName: String): Longint;
|
||||
function FileAgeUTF8(const FileName: string): Longint;
|
||||
begin
|
||||
Result:=SysUtils.FileAge(UTF8ToSys(Filename));
|
||||
end;
|
||||
@ -121,6 +122,36 @@ begin
|
||||
Result:='';
|
||||
end;
|
||||
|
||||
function GetUnixPhysicalFilename(const Filename: string;
|
||||
ExceptionOnError: boolean): string;
|
||||
var
|
||||
OldPath: String;
|
||||
NewPath: String;
|
||||
p: PChar;
|
||||
begin
|
||||
Result:=Filename;
|
||||
p:=PChar(Result);
|
||||
repeat
|
||||
while p^='/' do
|
||||
inc(p);
|
||||
if p^=#0 then exit;
|
||||
if p^<>'/' then
|
||||
begin
|
||||
repeat
|
||||
inc(p);
|
||||
until p^ in [#0,'/'];
|
||||
OldPath:=LeftStr(Result,p-PChar(Result));
|
||||
NewPath:=ReadAllLinks(OldPath,ExceptionOnError);
|
||||
if NewPath='' then exit('');
|
||||
if OldPath<>NewPath then
|
||||
begin
|
||||
Result:=NewPath+copy(Result,length(OldPath)+1,length(Result));
|
||||
p:=PChar(Result)+length(NewPath);
|
||||
end;
|
||||
end;
|
||||
until false;
|
||||
end;
|
||||
|
||||
function CreateDirUTF8(const NewDir: String): Boolean;
|
||||
begin
|
||||
Result:=SysUtils.CreateDir(UTF8ToSys(NewDir));
|
||||
@ -165,7 +196,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
function ExpandFileNameUtf8(const FileName: string; {const} BaseDir: String = ''): String;
|
||||
function ExpandFileNameUTF8(const FileName: string; BaseDir: string): string;
|
||||
var
|
||||
IsAbs: Boolean;
|
||||
CurDir, HomeDir, Fn: String;
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<fpdoc-descriptions>
|
||||
<package name="lazutils">
|
||||
|
||||
@ -1092,7 +1092,14 @@ if ReadBackslash=true then \" is replaced to " and not treated as quote.
|
||||
#0 is always end.
|
||||
</descr>
|
||||
</element>
|
||||
</module> <!-- LazFileUtils -->
|
||||
<element name="ReadAllLinks"><short>Resolves a symlink to the real file. It does not resolve symlinks in parent directories.</short><descr>If a symlink can not be resolved the function returns the empty string if ExceptionOnError is false. If ExceptionOnError is true it raises an EFOpenError with a message, containing more details.
|
||||
On Windows it simply returns Filename.</descr>
|
||||
</element><element name="GetUnixPhysicalFilename"><short>Resolves all symlinks in Filename, including all directories.</short><descr>If a symlink can not be resolved the function returns the empty string if ExceptionOnError is false. If ExceptionOnError is true it raises an EFOpenError with a message, containing more details.
|
||||
</descr>
|
||||
</element><element name="TryReadAllLinks"><short>Resolves a symlink to the real file. It does not resolve symlinks in parent directories.</short><descr>If a symlink can not be resolved it returns Filename.
|
||||
It uses ReadAllLinks.</descr>
|
||||
</element>
|
||||
</module> <!-- LazFileUtils -->
|
||||
|
||||
</package>
|
||||
</fpdoc-descriptions>
|
||||
|
Loading…
Reference in New Issue
Block a user