mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 11:19:26 +02:00
LazUtils: Move more functions from FileUtils to LazFileUtilities, deprecate the old ones.
git-svn-id: trunk@59177 -
This commit is contained in:
parent
33374c2b95
commit
75d1f28106
@ -154,59 +154,6 @@ begin
|
||||
Result:=ExtractFilePath(LeftStr(Result,Length(Result)-Length(BundlePostFix)));
|
||||
end;
|
||||
|
||||
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
|
||||
var
|
||||
PathLen: Integer;
|
||||
EndPos: Integer;
|
||||
StartPos: Integer;
|
||||
CurDir: String;
|
||||
NewCurDir: String;
|
||||
DiffLen: Integer;
|
||||
BaseDir: String;
|
||||
begin
|
||||
Result:=SearchPath;
|
||||
if (SearchPath='') or (BaseDirectory='') then exit;
|
||||
BaseDir:=AppendPathDelim(BaseDirectory);
|
||||
|
||||
PathLen:=length(Result);
|
||||
EndPos:=1;
|
||||
while EndPos<=PathLen do begin
|
||||
StartPos:=EndPos;
|
||||
while (Result[StartPos]=';') do begin
|
||||
inc(StartPos);
|
||||
if StartPos>PathLen then exit;
|
||||
end;
|
||||
EndPos:=StartPos;
|
||||
while (EndPos<=PathLen) and (Result[EndPos]<>';') do inc(EndPos);
|
||||
CurDir:=copy(Result,StartPos,EndPos-StartPos);
|
||||
if not FilenameIsAbsolute(CurDir) then begin
|
||||
NewCurDir:=BaseDir+CurDir;
|
||||
if NewCurDir<>CurDir then begin
|
||||
DiffLen:=length(NewCurDir)-length(CurDir);
|
||||
Result:=copy(Result,1,StartPos-1)+NewCurDir
|
||||
+copy(Result,EndPos,PathLen-EndPos+1);
|
||||
inc(EndPos,DiffLen);
|
||||
inc(PathLen,DiffLen);
|
||||
end;
|
||||
end;
|
||||
StartPos:=EndPos;
|
||||
end;
|
||||
end;
|
||||
|
||||
function CreateAbsolutePath(const Filename, BaseDirectory: string): string;
|
||||
begin
|
||||
if (Filename='') or FilenameIsAbsolute(Filename) then
|
||||
Result:=Filename
|
||||
{$IFDEF Windows}
|
||||
else if (Filename[1]='\') then
|
||||
// only use drive of BaseDirectory
|
||||
Result:=ExtractFileDrive(BaseDirectory)+Filename
|
||||
{$ENDIF}
|
||||
else
|
||||
Result:=AppendPathDelim(BaseDirectory)+Filename;
|
||||
Result:=TrimFilename(Result);
|
||||
end;
|
||||
|
||||
function FileIsInPath(const Filename, Path: string): boolean;
|
||||
var
|
||||
ExpFile: String;
|
||||
@ -238,6 +185,21 @@ begin
|
||||
and (CompareFilenames(ExpDir,LeftStr(ExpFile,p))=0);
|
||||
end;
|
||||
|
||||
function ExtractFileNameWithoutExt(const AFilename: string): string;
|
||||
begin
|
||||
Result:=LazFileUtils.ExtractFileNameWithoutExt(AFilename);
|
||||
end;
|
||||
|
||||
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
|
||||
begin
|
||||
Result:=LazFileUtils.CreateAbsoluteSearchPath(SearchPath, BaseDirectory);
|
||||
end;
|
||||
|
||||
function CreateAbsolutePath(const Filename, BaseDirectory: string): string;
|
||||
begin
|
||||
Result:=LazFileUtils.CreateAbsolutePath(Filename, BaseDirectory);
|
||||
end;
|
||||
|
||||
function CopyFile(const SrcFilename, DestFilename: String;
|
||||
Flags: TCopyFileFlags=[cffOverwriteFile]; ExceptionOnError: Boolean=False): Boolean;
|
||||
var
|
||||
|
@ -62,11 +62,13 @@ function ProgramDirectoryWithBundle: string;
|
||||
function ExpandUNCFileNameUTF8(const FileName: string): string;
|
||||
function FileSize(const Filename: string): int64; overload; inline;
|
||||
function FilenameIsPascalUnit(const Filename: string): boolean;
|
||||
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
|
||||
function CreateAbsolutePath(const Filename, BaseDirectory: string): string;
|
||||
function FileIsInPath(const Filename, Path: string): boolean;
|
||||
function FileIsInDirectory(const Filename, Directory: string): boolean;
|
||||
|
||||
function ExtractFileNameWithoutExt(const AFilename: string): string; deprecated 'Use the function from unit LazFileUtils';
|
||||
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string; deprecated 'Use the function from unit LazFileUtils';
|
||||
function CreateAbsolutePath(const Filename, BaseDirectory: string): string; deprecated 'Use the function from unit LazFileUtils';
|
||||
|
||||
function GetAllFilesMask: string; inline;
|
||||
function GetExeExt: string; inline;
|
||||
function ReadFileToString(const Filename: string): string;
|
||||
|
@ -213,6 +213,20 @@ begin
|
||||
Result:=(TheFilename<>'') and (TheFilename[1]='/');
|
||||
end;
|
||||
|
||||
function CreateAbsolutePath(const Filename, BaseDirectory: string): string;
|
||||
begin
|
||||
if (Filename='') or FilenameIsAbsolute(Filename) then
|
||||
Result:=Filename
|
||||
{$IFDEF Windows}
|
||||
else if (Filename[1]='\') then
|
||||
// only use drive of BaseDirectory
|
||||
Result:=ExtractFileDrive(BaseDirectory)+Filename
|
||||
{$ENDIF}
|
||||
else
|
||||
Result:=AppendPathDelim(BaseDirectory)+Filename;
|
||||
Result:=TrimFilename(Result);
|
||||
end;
|
||||
|
||||
|
||||
{
|
||||
Returns True if it is possible to create a relative path from Source to Dest
|
||||
@ -245,7 +259,6 @@ end;
|
||||
- Dest = /foo Source = /bar AlwaysRequireSharedBaseFolder = True Result = False
|
||||
- Dest = /foo Source = /bar AlwaysRequireSharedBaseFolder = False Result = True RelPath = ../foo
|
||||
}
|
||||
|
||||
function TryCreateRelativePath(const Dest, Source: String; UsePointDirectory: boolean;
|
||||
AlwaysRequireSharedBaseFolder: Boolean; out RelPath: String): Boolean;
|
||||
Const
|
||||
|
@ -62,6 +62,7 @@ function CleanAndExpandFilename(const Filename: string): string; // empty string
|
||||
function CleanAndExpandDirectory(const Filename: string): string; // empty string returns current directory
|
||||
function TrimAndExpandFilename(const Filename: string; const BaseDir: string = ''): string; // empty string returns empty string
|
||||
function TrimAndExpandDirectory(const Filename: string; const BaseDir: string = ''): string; // empty string returns empty string
|
||||
function CreateAbsolutePath(const Filename, BaseDirectory: string): string;
|
||||
function TryCreateRelativePath(const Dest, Source: String; UsePointDirectory: boolean;
|
||||
AlwaysRequireSharedBaseFolder: Boolean; out RelPath: String): Boolean;
|
||||
function CreateRelativePath(const Filename, BaseDirectory: string;
|
||||
|
Loading…
Reference in New Issue
Block a user