You've already forked lazarus-ccr
RxFPC:New function in RxFileUtils - NormalizeFileName. Fix languages
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4815 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -43,6 +43,16 @@ procedure GetFileOwnerData(const SearchDomain, FileName:String;out UserName, Dom
|
||||
function NormalizeDirectoryName(const DirName:string):string;
|
||||
function GetUserName:string;
|
||||
|
||||
function IsValidFileNameChar(const AChar: Char): Boolean;inline;
|
||||
function NormalizeFileName(const FileName:string; AReplaceChar:char = '_'):string; //funtion only for filename - without folder name
|
||||
|
||||
const
|
||||
{$IFDEF WINDOWS}
|
||||
FileNameDisabledChars = [#0 .. #31, '"', '*', '/', ':', '<', '>', '?', '\' , '|'];
|
||||
{$ELSE}
|
||||
FileNameDisabledChars = [#0 .. #31, '/', '~'];
|
||||
{$ENDIF}
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
@ -207,5 +217,20 @@ begin
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
function IsValidFileNameChar(const AChar: Char): Boolean;
|
||||
begin
|
||||
Result:=not (AChar in FileNameDisabledChars);
|
||||
end;
|
||||
|
||||
function NormalizeFileName(const FileName: string; AReplaceChar:char = '_'): string;
|
||||
var
|
||||
i:integer;
|
||||
begin
|
||||
Result:=FileName;
|
||||
for i:=1 to Length(Result) do
|
||||
if not IsValidFileNameChar(Result[i]) then
|
||||
Result[i]:=AReplaceChar;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Reference in New Issue
Block a user