mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 20:39:14 +02:00
LazUtils: Move ExtractFileNameWithoutExt to LazFileUtils. Rhymes with ExtractFileNameOnly.
git-svn-id: trunk@59169 -
This commit is contained in:
parent
03042bfb7d
commit
571647e302
@ -95,24 +95,6 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ExtractFileNameWithoutExt(const AFilename: string): string;
|
|
||||||
var
|
|
||||||
p: Integer;
|
|
||||||
begin
|
|
||||||
Result:=AFilename;
|
|
||||||
p:=length(Result);
|
|
||||||
while (p>0) do begin
|
|
||||||
case Result[p] of
|
|
||||||
PathDelim: exit;
|
|
||||||
{$ifdef windows}
|
|
||||||
'/': if ('/' in AllowDirectorySeparators) then exit;
|
|
||||||
{$endif}
|
|
||||||
'.': exit(copy(Result,1, p-1));
|
|
||||||
end;
|
|
||||||
dec(p);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function DeleteDirectory(const DirectoryName: string; OnlyChildren: boolean): boolean;
|
function DeleteDirectory(const DirectoryName: string; OnlyChildren: boolean): boolean;
|
||||||
const
|
const
|
||||||
//Don't follow symlinks on *nix, just delete them
|
//Don't follow symlinks on *nix, just delete them
|
||||||
|
@ -61,7 +61,6 @@ function ProgramDirectoryWithBundle: string;
|
|||||||
|
|
||||||
function ExpandUNCFileNameUTF8(const FileName: string): string;
|
function ExpandUNCFileNameUTF8(const FileName: string): string;
|
||||||
function FileSize(const Filename: string): int64; overload; inline;
|
function FileSize(const Filename: string): int64; overload; inline;
|
||||||
function ExtractFileNameWithoutExt(const AFilename: string): string;
|
|
||||||
function FilenameIsPascalUnit(const Filename: string): boolean;
|
function FilenameIsPascalUnit(const Filename: string): boolean;
|
||||||
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
|
function CreateAbsoluteSearchPath(const SearchPath, BaseDirectory: string): string;
|
||||||
function CreateAbsolutePath(const Filename, BaseDirectory: string): string;
|
function CreateAbsolutePath(const Filename, BaseDirectory: string): string;
|
||||||
|
@ -247,7 +247,7 @@ end;
|
|||||||
}
|
}
|
||||||
|
|
||||||
function TryCreateRelativePath(const Dest, Source: String; UsePointDirectory: boolean;
|
function TryCreateRelativePath(const Dest, Source: String; UsePointDirectory: boolean;
|
||||||
AlwaysRequireSharedBaseFolder: Boolean; out RelPath: String): Boolean;
|
AlwaysRequireSharedBaseFolder: Boolean; out RelPath: String): Boolean;
|
||||||
Const
|
Const
|
||||||
MaxDirs = 129;
|
MaxDirs = 129;
|
||||||
Type
|
Type
|
||||||
@ -416,7 +416,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function CreateRelativePath(const Filename, BaseDirectory: string;
|
function CreateRelativePath(const Filename, BaseDirectory: string;
|
||||||
UsePointDirectory: boolean; AlwaysRequireSharedBaseFolder: Boolean): string;
|
UsePointDirectory: boolean; AlwaysRequireSharedBaseFolder: Boolean): string;
|
||||||
var
|
var
|
||||||
RelPath: String;
|
RelPath: String;
|
||||||
begin
|
begin
|
||||||
|
@ -29,9 +29,7 @@ uses
|
|||||||
function CompareFilenames(const Filename1, Filename2: string): integer; overload;
|
function CompareFilenames(const Filename1, Filename2: string): integer; overload;
|
||||||
function CompareFilenamesIgnoreCase(const Filename1, Filename2: string): integer;
|
function CompareFilenamesIgnoreCase(const Filename1, Filename2: string): integer;
|
||||||
function CompareFileExt(const Filename, Ext: string;
|
function CompareFileExt(const Filename, Ext: string;
|
||||||
CaseSensitive: boolean): integer; overload;
|
CaseSensitive: boolean = False): integer;
|
||||||
function CompareFileExt(const Filename, Ext: string): integer; overload;
|
|
||||||
|
|
||||||
function CompareFilenameStarts(const Filename1, Filename2: string): integer;
|
function CompareFilenameStarts(const Filename1, Filename2: string): integer;
|
||||||
function CompareFilenames(Filename1: PChar; Len1: integer;
|
function CompareFilenames(Filename1: PChar; Len1: integer;
|
||||||
Filename2: PChar; Len2: integer): integer; overload;
|
Filename2: PChar; Len2: integer): integer; overload;
|
||||||
@ -42,6 +40,7 @@ function CompareFilenamesP(Filename1, Filename2: PChar;
|
|||||||
function DirPathExists(DirectoryName: string): boolean;
|
function DirPathExists(DirectoryName: string): boolean;
|
||||||
function DirectoryIsWritable(const DirectoryName: string): boolean;
|
function DirectoryIsWritable(const DirectoryName: string): boolean;
|
||||||
function ExtractFileNameOnly(const AFilename: string): string;
|
function ExtractFileNameOnly(const AFilename: string): string;
|
||||||
|
function ExtractFileNameWithoutExt(const AFilename: string): string;
|
||||||
function FilenameIsAbsolute(const TheFilename: string):boolean;
|
function FilenameIsAbsolute(const TheFilename: string):boolean;
|
||||||
function FilenameIsWinAbsolute(const TheFilename: string):boolean;
|
function FilenameIsWinAbsolute(const TheFilename: string):boolean;
|
||||||
function FilenameIsUnixAbsolute(const TheFilename: string):boolean;
|
function FilenameIsUnixAbsolute(const TheFilename: string):boolean;
|
||||||
@ -64,9 +63,9 @@ function CleanAndExpandDirectory(const Filename: string): string; // empty strin
|
|||||||
function TrimAndExpandFilename(const Filename: string; const BaseDir: string = ''): string; // empty string returns empty string
|
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 TrimAndExpandDirectory(const Filename: string; const BaseDir: string = ''): string; // empty string returns empty string
|
||||||
function TryCreateRelativePath(const Dest, Source: String; UsePointDirectory: boolean;
|
function TryCreateRelativePath(const Dest, Source: String; UsePointDirectory: boolean;
|
||||||
AlwaysRequireSharedBaseFolder: Boolean; out RelPath: String): Boolean;
|
AlwaysRequireSharedBaseFolder: Boolean; out RelPath: String): Boolean;
|
||||||
function CreateRelativePath(const Filename, BaseDirectory: string;
|
function CreateRelativePath(const Filename, BaseDirectory: string;
|
||||||
UsePointDirectory: boolean = false; AlwaysRequireSharedBaseFolder: Boolean = True): string;
|
UsePointDirectory: boolean = false; AlwaysRequireSharedBaseFolder: Boolean = True): string;
|
||||||
function FileIsInPath(const Filename, Path: string): boolean;
|
function FileIsInPath(const Filename, Path: string): boolean;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -294,11 +293,6 @@ begin
|
|||||||
if Result > 0 then Result := 1;
|
if Result > 0 then Result := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function CompareFileExt(const Filename, Ext: string): integer;
|
|
||||||
begin
|
|
||||||
Result := CompareFileExt(Filename, Ext, False);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function ExtractFileNameOnly(const AFilename: string): string;
|
function ExtractFileNameOnly(const AFilename: string): string;
|
||||||
var
|
var
|
||||||
StartPos: Integer;
|
StartPos: Integer;
|
||||||
@ -317,6 +311,24 @@ begin
|
|||||||
Result:=copy(AFilename,StartPos,ExtPos-StartPos);
|
Result:=copy(AFilename,StartPos,ExtPos-StartPos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function ExtractFileNameWithoutExt(const AFilename: string): string;
|
||||||
|
var
|
||||||
|
p: Integer;
|
||||||
|
begin
|
||||||
|
Result:=AFilename;
|
||||||
|
p:=length(Result);
|
||||||
|
while (p>0) do begin
|
||||||
|
case Result[p] of
|
||||||
|
PathDelim: exit;
|
||||||
|
{$ifdef windows}
|
||||||
|
'/': if ('/' in AllowDirectorySeparators) then exit;
|
||||||
|
{$endif}
|
||||||
|
'.': exit(copy(Result,1, p-1));
|
||||||
|
end;
|
||||||
|
dec(p);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{$IFDEF darwin}
|
{$IFDEF darwin}
|
||||||
function GetDarwinSystemFilename(Filename: string): string;
|
function GetDarwinSystemFilename(Filename: string): string;
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user