UTF-8: added ExpandFilenameUTF8

git-svn-id: trunk@16272 -
This commit is contained in:
mattias 2008-08-27 11:25:01 +00:00
parent f65592b46f
commit 9032caa4fd
49 changed files with 813 additions and 766 deletions

1
.gitattributes vendored
View File

@ -3776,6 +3776,7 @@ tools/apiwizz/apiwizard.pp svneol=native#text/pascal
tools/apiwizz/apiwizz.lpi svneol=native#text/plain
tools/apiwizz/apiwizz.pp svneol=native#text/pascal
tools/check_ide_libs.sh -text svneol=native#application/x-sh
tools/compile_all.sh svneol=native#text/plain
tools/convert_po_file_to_utf-8.sh svneol=native#text/plain
tools/copy_po_files_to_lazarus_sources.sh -text svneol=native#application/x-sh
tools/delete_non_svn_files.pl svneol=native#text/plain

View File

@ -910,9 +910,9 @@ begin
Options.InitWithEnvironmentVariables;
// apply defaults
if Options.FPCSrcDir='' then
Options.FPCSrcDir:=ExpandFileName('~/freepascal/fpc');
Options.FPCSrcDir:=ExpandFileNameUTF8('~/freepascal/fpc');
if Options.LazarusSrcDir='' then
Options.LazarusSrcDir:=ExpandFileName('~/pascal/lazarus');
Options.LazarusSrcDir:=ExpandFileNameUTF8('~/pascal/lazarus');
DebugLn(['TCodeToolManager.SimpleInit PP=',Options.FPCPath,' FPCDIR=',Options.FPCSrcDir,' LAZARUSDIR=',Options.LazarusSrcDir]);
// init the codetools
if not Options.UnitLinkListValid then

View File

@ -138,7 +138,7 @@ procedure TCodeToolsOptions.SetFPCPath(const AValue: string);
var
NewValue: String;
begin
NewValue:=ExpandFileName(AValue);
NewValue:=ExpandFileNameUTF8(AValue);
if FFPCPath=NewValue then exit;
FFPCPath:=NewValue;
FUnitLinkListValid:=false;
@ -149,7 +149,7 @@ procedure TCodeToolsOptions.SetFPCSrcDir(const AValue: string);
var
NewValue: String;
begin
NewValue:=ExpandFileName(AValue);
NewValue:=ExpandFileNameUTF8(AValue);
if FFPCSrcDir=NewValue then exit;
FFPCSrcDir:=NewValue;
FUnitLinkListValid:=false;
@ -168,7 +168,7 @@ procedure TCodeToolsOptions.SetLazarusSrcDir(const AValue: string);
var
NewValue: String;
begin
NewValue:=ExpandFileName(AValue);
NewValue:=ExpandFileNameUTF8(AValue);
if FLazarusSrcDir=NewValue then exit;
FLazarusSrcDir:=NewValue;
Modified:=true;

View File

@ -2935,7 +2935,7 @@ var
Inc(CurPos, 17);
NewPath:=copy(Line,CurPos,len);
if not FilenameIsAbsolute(NewPath) then
NewPath:=ExpandFileName(NewPath);
NewPath:=ExpandFileNameUTF8(NewPath);
{$IFDEF VerboseFPCSrcScan}
DebugLn('Using unit path: "',NewPath,'"');
{$ENDIF}

View File

@ -51,8 +51,8 @@ begin
// setup your paths
Options.FPCPath:='/usr/bin/ppc386';
Options.FPCSrcDir:=ExpandFileName('~/freepascal/fpc');
Options.LazarusSrcDir:=ExpandFileName('~/pascal/lazarus');
Options.FPCSrcDir:=ExpandFileNameUTF8('~/freepascal/fpc');
Options.LazarusSrcDir:=ExpandFileNameUTF8('~/pascal/lazarus');
// optional: ProjectDir and TestPascalFile exists only to easily test some
// things.
@ -68,7 +68,7 @@ begin
Options.SaveToFile(ConfigFilename);
// load the example unit
Filename:=ExpandFileName('scanexamples/brokenfilenames.pas');
Filename:=ExpandFileNameUTF8('scanexamples/brokenfilenames.pas');
Code:=CodeToolBoss.LoadFile(Filename,false,false);
if Code=nil then
raise Exception.Create('unable to read '+Filename);

View File

@ -37,7 +37,7 @@ var
CurClassName: String;
Node: TCodeTreeNode;
begin
ExpandedFilename:=ExpandFileName('scanexamples/simpleunit1.pas');
ExpandedFilename:=ExpandFileNameUTF8('scanexamples/simpleunit1.pas');
CodeBuf:=CodeToolBoss.LoadFile(ExpandedFilename,true,false);
if CodeBuf=nil then
raise Exception.Create('failed loading '+ExpandedFilename);

View File

@ -37,7 +37,7 @@ var
NewX, NewY, NewTopLine: integer;
RevertableJump: boolean;
begin
ExpandedFilename:=ExpandFileName('scanexamples/tgeneric2.pas');
ExpandedFilename:=ExpandFileNameUTF8('scanexamples/tgeneric2.pas');
CodeBuf:=CodeToolBoss.LoadFile(ExpandedFilename,true,false);
if CodeBuf=nil then
raise Exception.Create('failed loading '+ExpandedFilename);

View File

@ -37,7 +37,7 @@ var
begin
// create a template for the current directory
// all child nodes of this templates are only valid for this directory.
Directory:=ExpandFileName(GetCurrentDirUTF8);
Directory:=ExpandFileNameUTF8(GetCurrentDirUTF8);
DirectoryTemplate:=TDefineTemplate.Create('Current working directory',
'Example template for current working directory','',Directory,da_Directory);

View File

@ -314,6 +314,7 @@ function SysToUTF8(const s: string): string;// as AnsiToUTF8 but more independen
function FileExistsUTF8(const Filename: string): boolean;
function FileAgeUTF8(const FileName: string): Longint;
function DirectoryExistsUTF8(const Directory: string): Boolean;
function ExpandFileNameUTF8(const FileName: string): string;
function FindFirstUTF8(const Path: string; Attr: Longint; out Rslt: TSearchRec): Longint;
function FindNextUTF8(var Rslt: TSearchRec): Longint;
procedure FindCloseUTF8(var F: TSearchrec);
@ -398,9 +399,17 @@ begin
FNeedRTLAnsiValid:=true;
end;
function IsASCII(const s: string): boolean; inline;
var
i: Integer;
begin
for i:=1 to length(s) do if ord(s[i])>127 then exit(false);
Result:=true;
end;
function UTF8ToSys(const s: string): string;
begin
if NeedRTLAnsi then
if NeedRTLAnsi and (not IsASCII(s)) then
Result:=UTF8ToAnsi(s)
else
Result:=s;
@ -408,7 +417,7 @@ end;
function SysToUTF8(const s: string): string;
begin
if NeedRTLAnsi then
if NeedRTLAnsi and (not IsASCII(s)) then
Result:=AnsiToUTF8(s)
else
Result:=s;
@ -429,6 +438,11 @@ begin
Result:=SysUtils.DirectoryExists(UTF8ToSys(Directory));
end;
function ExpandFileNameUTF8(const FileName: string): string;
begin
Result:=SysToUTF8(SysUtils.ExpandFileName(UTF8ToSys(Filename)));
end;
function FindFirstUTF8(const Path: string; Attr: Longint; out Rslt: TSearchRec
): Longint;
begin
@ -573,7 +587,7 @@ var
CurPath: String;
CurName: String;
begin
Result:=ExpandFilename(Path);
Result:=ExpandFileNameUTF8(Path);
CurPath:=AppendPathDelim(ExtractFilePath(Result));
CurName:=Prefix+ExtractFileNameOnly(Result);
i:=1;
@ -1086,7 +1100,7 @@ end;
------------------------------------------------------------------------------}
function CleanAndExpandFilename(const Filename: string): string;
begin
Result:=ExpandFilename(TrimFileName(Filename));
Result:=ExpandFileNameUTF8(TrimFileName(Filename));
end;
{------------------------------------------------------------------------------
@ -1365,7 +1379,7 @@ var
p, StartPos, l: integer;
CurPath, Base: string;
begin
Base:=ExpandFilename(AppendPathDelim(BasePath));
Base:=ExpandFileNameUTF8(AppendPathDelim(BasePath));
// search in current directory
Result:=SearchPascalUnitInDir(AnUnitName,Base,SearchCase);
if Result<>'' then exit;
@ -1379,7 +1393,7 @@ begin
if CurPath<>'' then begin
if not FilenameIsAbsolute(CurPath) then
CurPath:=Base+CurPath;
CurPath:=ExpandFilename(AppendPathDelim(CurPath));
CurPath:=ExpandFileNameUTF8(AppendPathDelim(CurPath));
Result:=SearchPascalUnitInDir(AnUnitName,CurPath,SearchCase);
if Result<>'' then exit;
end;
@ -1455,7 +1469,7 @@ var
p, StartPos, l: integer;
CurPath, Base: string;
begin
Base:=ExpandFilename(AppendPathDelim(BasePath));
Base:=ExpandFileNameUTF8(AppendPathDelim(BasePath));
// search in current directory
if not FilenameIsAbsolute(Base) then
Base:='';
@ -1473,7 +1487,7 @@ begin
if CurPath<>'' then begin
if not FilenameIsAbsolute(CurPath) then
CurPath:=Base+CurPath;
CurPath:=ExpandFilename(AppendPathDelim(CurPath));
CurPath:=ExpandFileNameUTF8(AppendPathDelim(CurPath));
if FilenameIsAbsolute(CurPath) then begin
Result:=SearchPascalFileInDir(ShortFilename,CurPath,SearchCase);
if Result<>'' then exit;
@ -1751,7 +1765,7 @@ begin
if FilenameIsAbsolute(Filename) then begin
if SearchCase=ctsfcDefault then begin
if FileExistsCached(Filename) then begin
Result:=ExpandFilename(Filename);
Result:=ExpandFileNameUTF8(Filename);
end else begin
Result:='';
end;
@ -1760,7 +1774,7 @@ begin
ExtractFilePath(BasePath),'',';',SearchCase);
exit;
end;
Base:=ExpandFilename(AppendPathDelim(BasePath));
Base:=ExpandFileNameUTF8(AppendPathDelim(BasePath));
// search in current directory
Result:=SearchFileInDir(Filename,Base,SearchCase);
if Result<>'' then exit;
@ -1774,7 +1788,7 @@ begin
if CurPath<>'' then begin
if not FilenameIsAbsolute(CurPath) then
CurPath:=Base+CurPath;
CurPath:=ExpandFilename(AppendPathDelim(CurPath));
CurPath:=ExpandFileNameUTF8(AppendPathDelim(CurPath));
Result:=SearchFileInDir(Filename,CurPath,SearchCase);
if Result<>'' then exit;
end;

File diff suppressed because it is too large Load Diff

View File

@ -2516,7 +2516,7 @@ var
begin
Path:=ExtractFilePath(AFilename);
if (Path<>'') and (not FilenameIsAbsolute(Path)) then
Path:=ExpandFilename(Path);
Path:=ExpandFileNameUTF8(Path);
FileNameOnly:=ExtractFilename(AFilename);
Result:=nil;
Result:=FOnLoadSource(Self,TrimFilename(Path+FileNameOnly),true);

View File

@ -1268,7 +1268,7 @@ var
NewFilename: String;
begin
Result:=mrCancel;
NewFilename:=ExpandFileName(TrimFilename(Filename));
NewFilename:=ExpandFileNameUTF8(TrimFilename(Filename));
if not FileExistsUTF8(NewFilename) then begin
if ofOnlyIfExists in Flags then begin
MessageDlg('File not found',

View File

@ -10,19 +10,19 @@ msgstr ""
"MIME-Version: 1.0\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
#: h2passtrconsts:h2pcheaderfileconverter
#: h2passtrconsts.h2pcheaderfileconverter
msgid "C header file converter"
msgstr "C antraštės failo konverteris"
#: h2passtrconsts:h2pcreateunitsfromcheaderfiles
#: h2passtrconsts.h2pcreateunitsfromcheaderfiles
msgid "Create units from C header files"
msgstr "Kurti modulius pagal C antraštės failus"
#: h2passtrconsts:h2ph2pas
#: h2passtrconsts.h2ph2pas
msgid "H2Pas"
msgstr "H2Pas"
#: h2passtrconsts:h2ph2pastool
#: h2passtrconsts.h2ph2pastool
msgid "H2PasTool"
msgstr "H2PasTool"

View File

@ -184,14 +184,14 @@ begin
TFMTAP := LongTimeFormat; //nl_langinfo(T_FMT_AMPM)
//KDE config
if DirectoryExistsUTF8(ExpandFileName('~/.kde/share/config')) then
if DirectoryExistsUTF8(ExpandFileNameUTF8('~/.kde/share/config')) then
begin
Lg:=Copy(GetEnvironmentVariableUTF8('LANG'),1,2); //Langue
LstKde:=TStringList.Create;
try
ReadKdeFileConfig(Format('/usr/share/locale/l10n/%s/entry.desktop',[Lg]),'[KCM Locale]',LstKde);
ReadKdeFileConfig(ExpandFileName('~/.kde/share/config/kdeglobals'),'[Locale]',LstKde);
ReadKdeFileConfig(ExpandFileNameUTF8('~/.kde/share/config/kdeglobals'),'[Locale]',LstKde);
St:=ReadKdeConfig('DecimalSymbol',DecimalSeparator);
DecimalSeparator:=St[1];

View File

@ -221,7 +221,7 @@ var PrinterName : string;
begin
Result:=-1;
if not CUPSLibInstalled then Exit;
aFileName:=ExpandFileName(aFileName);
aFileName:=ExpandFileNameUTF8(aFileName);
if (Printers.Count>0) then
begin

View File

@ -229,7 +229,7 @@ begin
editFieldName.Enabled:=False;
comboFieldType.Enabled:=False;
end;
lblFilePath.Caption:='File Path: '+ExpandFileName(DataSet.FileName);
lblFilePath.Caption:='File Path: '+ExpandFileNameUTF8(DataSet.FileName);
label3.caption:='Table Name: '+ DataSet.TableName;
end;

View File

@ -10,7 +10,7 @@ msgstr ""
"X-Generator: KBabel 1.11.4\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
#: registerdbf:dbfsalldbasefiles
#: registerdbf.dbfsalldbasefiles
msgid "DBase Files"
msgstr "DBase failai"

View File

@ -256,7 +256,7 @@ begin
end;
end
else begin
FN := ExpandFileName(FN);
FN := ExpandFileNameUTF8(FN);
CurrFile := ExtractFileName (FN);
Path := ExtractFilePath (FN);
PathChanged := True;

View File

@ -266,7 +266,7 @@ begin
end;
end
else begin
FN := ExpandFileName(FN);
FN := ExpandFileNameUTF8(FN);
CurrFile := ExtractFileName (FN);
Path := ExtractFilePath (FN);
PathChanged := True;

View File

@ -143,7 +143,7 @@ implementation
function expandLocalHtmlFileName (URL : string) : string;
begin
if pos ('FILE://', ansiuppercase(URL)) = 0 then
result := 'file://'+DOSToNetPath(ExpandFileName(URL))
result := 'file://'+DOSToNetPath(ExpandFileNameUTF8(URL))
else
result := URL;
end;

View File

@ -546,7 +546,7 @@ begin
begin
S:=L[i];
If (LBDescrFiles.Items.IndexOf(S)=-1) and
(LBDescrFiles.Items.IndexOf(ExpandFileName(S))=-1) then
(LBDescrFiles.Items.IndexOf(ExpandFileNameUTF8(S))=-1) then
LBDescrFiles.Items.Add(S);
end;
Finally

View File

@ -480,7 +480,7 @@ Var
Index : Integer;
begin
FN:=ExpandFileName(FN);
FN:=ExpandFileNameUTF8(FN);
With FRecent do
begin
Index:=IndexOf(FN);

View File

@ -80,7 +80,7 @@ function origpath:string;
var tmp:string;
begin
tmp:=StrPas(argv[0]);
tmp:=ExpandFileName(tmp);
tmp:=ExpandFileNameUTF8(tmp);
tmp:=ExtractFileDir(tmp);
tmp:=IncludeTrailingPathDelimiter(tmp);
result:=tmp;

View File

@ -423,9 +423,9 @@ begin
begin
S:=ParamStrUTF8(I);
If DirectoryExistsUTF8(S) then
AddDir(ExpandFileName(S),FRecursive)
AddDir(ExpandFileNameUTF8(S),FRecursive)
else if FileExistsUTF8(S) then
AddFile(ExpandFileName(S),LBFiles.Items.Count=0);
AddFile(ExpandFileNameUTF8(S),LBFiles.Items.Count=0);
end;
end;
end;

View File

@ -574,9 +574,9 @@ procedure InitGL;
begin
if not LoadglTexImage2DFromBitmapFile(Filename,Image) then begin
MessageDlg('File not found',
'Image file not found: '+ExpandFilename(Filename),
'Image file not found: '+ExpandFileNameUTF8(Filename),
mtError,[mbOk],0);
raise Exception.Create('Image file not found: '+ExpandFilename(Filename));
raise Exception.Create('Image file not found: '+ExpandFileNameUTF8(Filename));
end;
end;

View File

@ -133,7 +133,7 @@ begin
Bmp:=TBitMap.Create;
try
Bmp.LoadFromFile(ExpandFileName('../../images/LazarusForm.bmp'));
Bmp.LoadFromFile(ExpandFileNameUTF8('../../images/LazarusForm.bmp'));
DRaw(10,450,BMP);
finally
Bmp.Free;
@ -141,7 +141,7 @@ begin
xpm:=TPixMap.Create;
try
xpm.LoadFromFile(ExpandFileName('../../images/lazarus.xpm'));
xpm.LoadFromFile(ExpandFileNameUTF8('../../images/lazarus.xpm'));
StretchDraw(Rect(10,500,110,600),xpm);
finally
xpm.Free;
@ -187,14 +187,14 @@ var
FName: string;
begin
if Sender=nil then ;
if FileExistsUTF8(ExpandFileName('./test1.ps')) then
if FileExistsUTF8(ExpandFileNameUTF8('./test1.ps')) then
begin
{$IFDEF MSWINDOWS}
FName := '"C:\Program Files\Ghostgum\gsview\gsview32" ' + ExpandFileName('./test1.ps');
FName := '"C:\Program Files\Ghostgum\gsview\gsview32" ' + ExpandFileNameUTF8('./test1.ps');
ShellExecute(Handle, 'open', PChar(FName), nil, nil, SW_SHOWNORMAL)
{$ENDIF}
{$IFDEF UNIX}
Shell(format('kghostview %s',[ExpandFileName('./test1.ps')]));
Shell(format('kghostview %s',[ExpandFileNameUTF8('./test1.ps')]));
{$ENDIF}
end;
end;

View File

@ -520,7 +520,7 @@ var
if NewPath<>'' then begin
if not FilenameIsAbsolute(NewPath) then begin
AddWarning(Format(lisCCORelUnitPathFoundInCfg,[NewPath]));
NewPath:=ExpandFileName(NewPath);
NewPath:=ExpandFileNameUTF8(NewPath);
end;
NewPath:=AppendPathDelim(TrimFilename(NewPath));
if (CompareFilenames(NewPath,Options.BaseDirectory)<>0)

View File

@ -91,7 +91,7 @@ begin
else
begin
// Do not add file to the parameter list
if not (Copy(Param,1,1) = '-') and (FileExistsUTF8(ExpandFileName(Param))) then
if not (Copy(Param,1,1) = '-') and (FileExistsUTF8(ExpandFileNameUTF8(Param))) then
begin
DebugLn('%s is a file', [Param]);
continue;

View File

@ -89,8 +89,8 @@ end;
---------------------------------------------------------------------------}
procedure SetPrimaryConfigPath(const NewValue: String);
begin
debugln('SetPrimaryConfigPath NewValue="',NewValue,'" -> "',ExpandFileName(NewValue),'"');
PrimaryConfigPath:=ExpandFileName(NewValue);
debugln('SetPrimaryConfigPath NewValue="',NewValue,'" -> "',ExpandFileNameUTF8(NewValue),'"');
PrimaryConfigPath:=ExpandFileNameUTF8(NewValue);
end;
{---------------------------------------------------------------------------
@ -98,8 +98,8 @@ end;
---------------------------------------------------------------------------}
procedure SetSecondaryConfigPath(const NewValue: String);
begin
debugln('SetSecondaryConfigPath NewValue="',NewValue,'" -> "',ExpandFileName(NewValue),'"');
SecondaryConfigPath:=ExpandFileName(NewValue);
debugln('SetSecondaryConfigPath NewValue="',NewValue,'" -> "',ExpandFileNameUTF8(NewValue),'"');
SecondaryConfigPath:=ExpandFileNameUTF8(NewValue);
end;
{---------------------------------------------------------------------------
@ -183,7 +183,7 @@ end;
---------------------------------------------------------------------------}
procedure InternalInit;
begin
PrimaryConfigPath:=ExpandFileName('~/.lazarus');
PrimaryConfigPath:=ExpandFileNameUTF8('~/.lazarus');
SecondaryConfigPath:='/etc/lazarus';
end;

View File

@ -276,7 +276,7 @@ begin
and (Filename<>'') then begin
if FTransferMacros<>nil then
Macros.SubstituteStr(Filename);
Filename:=ExpandFileName(Filename);
Filename:=ExpandFileNameUTF8(Filename);
if (not (iftDirectory in CurFileFlags)) and DirPathExistsCached(Filename)
then
exit;

View File

@ -140,7 +140,7 @@ begin
// if no lazarus executable exists in that directory, try the same directory
// as the startlazarus executable
if not FileExistsUTF8(Result) then
Result := AppendPathDelim(ExtractFilePath(ExpandFileName(ParamStrUTF8(0)))) +
Result := AppendPathDelim(ExtractFilePath(ExpandFileNameUTF8(ParamStrUTF8(0)))) +
FileName + GetExeExt;
end;
@ -244,7 +244,7 @@ var
begin
WaitForLazarus;
try
DefaultDir:=ExtractFilePath(ExpandFileName(ParamStrUTF8(0)));
DefaultDir:=ExtractFilePath(ExpandFileNameUTF8(ParamStrUTF8(0)));
if DirectoryExistsUTF8(DefaultDir) then
DefaultDir:=ReadAllLinks(DefaultDir,true);
except

View File

@ -2381,7 +2381,7 @@ procedure TMainIDE.mnuOpenRecentClicked(Sender: TObject);
var
AFilename: string;
begin
AFileName:=ExpandFilename((Sender as TIDEMenuItem).Caption);
AFileName:=ExpandFileNameUTF8((Sender as TIDEMenuItem).Caption);
if DoOpenEditorFile(AFilename,-1,[ofAddToRecent])=mrOk then begin
UpdateEnvironment;
end else begin
@ -3245,7 +3245,7 @@ Begin
OpenDialog.Title:=lisChooseProgramSourcePpPasLpr;
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist,ofFileMustExist];
if OpenDialog.Execute then begin
AFilename:=ExpandFilename(OpenDialog.Filename);
AFilename:=ExpandFileNameUTF8(OpenDialog.Filename);
if not FilenameIsPascalSource(AFilename) then begin
MessageDlg(lisPkgMangInvalidFileExtension,
lisProgramSourceMustHaveAPascalExtensionLikePasPpOrLp,
@ -3273,7 +3273,7 @@ var
begin
if (Sender is TIDEMenuItem)
and (TIDEMenuItem(Sender).Section=itmProjectRecentOpen) then begin
AFileName:=ExpandFilename(TIDEMenuItem(Sender).Caption);
AFileName:=ExpandFileNameUTF8(TIDEMenuItem(Sender).Caption);
if DoOpenProjectFile(AFilename,[ofAddToRecent])=mrOk then begin
AddRecentProjectFileToEnvironment(AFilename);
end else begin
@ -3292,7 +3292,7 @@ begin
OpenDialog.Filter := lisLazarusProjectInfoFile+' (*.lpi)|*.lpi|'
+lisAllFiles+'|'+GetAllFilesMask;
if OpenDialog.Execute then begin
AFilename:=ExpandFilename(OpenDialog.Filename);
AFilename:=ExpandFileNameUTF8(OpenDialog.Filename);
DoOpenProjectFile(AFilename,[ofAddToRecent]);
end;
InputHistories.StoreFileDialogSettings(OpenDialog);
@ -4466,7 +4466,7 @@ begin
Result:=mrCancel;
exit;
end;
NewFilename:=ExpandFilename(SaveDialog.Filename);
NewFilename:=ExpandFileNameUTF8(SaveDialog.Filename);
finally
InputHistories.StoreFileDialogSettings(SaveDialog);
SaveDialog.Free;
@ -6595,9 +6595,9 @@ begin
Result:=mrCancel;
exit;
end;
NewFilename:=ExpandFilename(SaveDialog.Filename);
NewFilename:=ExpandFileNameUTF8(SaveDialog.Filename);
if not FilenameIsAbsolute(NewFilename) then
RaiseException('TMainIDE.DoShowSaveProjectAsDialog: buggy ExpandFileName');
RaiseException('TMainIDE.DoShowSaveProjectAsDialog: buggy ExpandFileNameUTF8');
NewProgramName:=ExtractFileNameOnly(NewFilename);
// check programname
@ -7387,7 +7387,7 @@ begin
// replace macros
if ofConvertMacros in Flags then begin
if not GlobalMacroList.SubstituteStr(AFilename) then exit;
AFilename:=ExpandFilename(AFilename);
AFilename:=ExpandFileNameUTF8(AFilename);
end;
// revert: use source editor filename
@ -8027,14 +8027,14 @@ var ActiveSrcEdit: TSourceEditor;
if ExtractFileExt(TempFile)='' then begin
for PasExt:=Low(TPascalExtType) to High(TPascalExtType) do begin
Ext:=PascalExtension[PasExt];
FinalFile:=ExpandFileName(CurPath+TempFile+Ext);
FinalFile:=ExpandFileNameUTF8(CurPath+TempFile+Ext);
if FileExistsUTF8(FinalFile) then begin
FName:=FinalFile;
exit;
end;
end;
end else begin
FinalFile:=ExpandFileName(CurPath+TempFile);
FinalFile:=ExpandFileNameUTF8(CurPath+TempFile);
if FileExistsUTF8(FinalFile) then begin
FName:=FinalFile;
exit;
@ -8491,10 +8491,10 @@ begin
Result:=mrCancel;
if ExtractFileNameOnly(AFileName)='' then exit;
//debugln('TMainIDE.DoOpenProjectFile A1 "'+AFileName+'"');
AFilename:=ExpandFileName(TrimFilename(AFilename));
AFilename:=ExpandFileNameUTF8(TrimFilename(AFilename));
//debugln('TMainIDE.DoOpenProjectFile A2 "'+AFileName+'"');
if not FilenameIsAbsolute(AFilename) then
RaiseException('TMainIDE.DoOpenProjectFile: buggy ExpandFileName');
RaiseException('TMainIDE.DoOpenProjectFile: buggy ExpandFileNameUTF8');
Ext:=lowercase(ExtractFileExt(AFilename));
// check if file exists
@ -8764,7 +8764,7 @@ begin
// switch codetools to new project directory
CodeToolBoss.GlobalValues.Variables[ExternalMacroStart+'ProjPath']:=
ExpandFilename(ExtractFilePath(ProgramBuf.Filename));
ExpandFileNameUTF8(ExtractFilePath(ProgramBuf.Filename));
// create a new project
Project1:=CreateProjectObject(NewProjectDesc,ProjectDescriptorProgram);
@ -10108,7 +10108,7 @@ begin
+ '|' + dlgAllFiles + '|'+GetAllFilesMask;
if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin
For I := 0 to OpenDialog.Files.Count-1 do begin
AFilename:=ExpandFilename(OpenDialog.Files.Strings[i]);
AFilename:=ExpandFileNameUTF8(OpenDialog.Files.Strings[i]);
if ConvertDFMFileToLFMFile(AFilename)=mrAbort then begin
Result:=mrAbort;
break;
@ -13456,7 +13456,7 @@ begin
// user cancels
exit;
end;
Filename:=ExpandFilename(SaveDialog.Filename);
Filename:=ExpandFileNameUTF8(SaveDialog.Filename);
finally
InputHistories.StoreFileDialogSettings(SaveDialog);
SaveDialog.Free;

View File

@ -1374,7 +1374,7 @@ begin
if fSource<>nil then
Result:=fSource.IsVirtual
else
Result:=(fFileName<>ExpandFileName(fFileName));
Result:=(fFileName<>ExpandFileNameUTF8(fFileName));
end;
function TUnitInfo.GetDirectory: string;

View File

@ -37,8 +37,8 @@ unit PublishProjectDlg;
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, LResources, Buttons, StdCtrls,
Dialogs,
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, LResources, Buttons,
StdCtrls, Dialogs,
IDEWindowIntf,
ProjectDefs, PackageDefs, PublishModule, IDEOptionDefs, InputHistory,
LazarusIDEStrConsts, ExtCtrls;
@ -137,7 +137,7 @@ begin
InputHistories.ApplyFileDialogSettings(SelectDirDialog);
SelectDirDialog.Title:=lisChooseDirectory;
if SelectDirDialog.Execute then begin
NewDir:=ExpandFilename(SelectDirDialog.Filename);
NewDir:=ExpandFileNameUTF8(SelectDirDialog.Filename);
SeTComboBox(DestDirComboBox,NewDir,20);
end;
SelectDirDialog.Free;

View File

@ -244,7 +244,7 @@ begin
OpenDialog.Title:=lisOpenFile;
OpenDialog.Options:=OpenDialog.Options+[ofFileMustExist];
if OpenDialog.Execute then begin
RootFilename:=ExpandFilename(OpenDialog.Filename);
RootFilename:=ExpandFileNameUTF8(OpenDialog.Filename);
end;
InputHistories.StoreFileDialogSettings(OpenDialog);
finally
@ -403,7 +403,7 @@ begin
end;
FCommitUnitHistoryListSelectionNeeded:=false;
if UnitHistoryList.Items.IndexOf(UnitHistoryList.Text)<0 then exit;
RootFilename:=ExpandFilename(UnitHistoryList.Text);
RootFilename:=ExpandFileNameUTF8(UnitHistoryList.Text);
end;
procedure TUnitDependenciesView.KeyUp(var Key: Word; Shift: TShiftState);

View File

@ -180,6 +180,8 @@ function SysToUTF8(const s: string): string;// as AnsiToUTF8 but more independen
function FileExistsUTF8(const Filename: string): boolean;
function FileAgeUTF8(const FileName: string): Longint;
function DirectoryExistsUTF8(const Directory: string): Boolean;
function ExpandFileNameUTF8(const FileName: string): string;
function ExpandUNCFileNameUTF8(const FileName: string): string;
function FindFirstUTF8(const Path: string; Attr: Longint; out Rslt: TSearchRec): Longint;
function FindNextUTF8(var Rslt: TSearchRec): Longint;
procedure FindCloseUTF8(var F: TSearchrec);

View File

@ -140,11 +140,11 @@ procedure TOpenDialog.DereferenceLinks;
var i: integer;
begin
if Filename<>'' then
Filename:=ExpandFilename(Filename);
Filename:=ExpandFileNameUTF8(Filename);
if Files<>nil then begin
for i:=0 to Files.Count-1 do begin
if Files[i]<>'' then
Files[i]:=ExpandFilename(Files[i]);
Files[i]:=ExpandFileNameUTF8(Files[i]);
end;
end;
end;

View File

@ -66,9 +66,17 @@ begin
FNeedRTLAnsiValid:=true;
end;
function IsASCII(const s: string): boolean; inline;
var
i: Integer;
begin
for i:=1 to length(s) do if ord(s[i])>127 then exit(false);
Result:=true;
end;
function UTF8ToSys(const s: string): string;
begin
if NeedRTLAnsi then
if NeedRTLAnsi and (not IsASCII(s)) then
Result:=UTF8ToAnsi(s)
else
Result:=s;
@ -76,7 +84,7 @@ end;
function SysToUTF8(const s: string): string;
begin
if NeedRTLAnsi then
if NeedRTLAnsi and (not IsASCII(s)) then
Result:=AnsiToUTF8(s)
else
Result:=s;
@ -97,6 +105,16 @@ begin
Result:=SysUtils.DirectoryExists(UTF8ToSys(Directory));
end;
function ExpandFileNameUTF8(const FileName: string): string;
begin
Result:=SysToUTF8(SysUtils.ExpandFileName(UTF8ToSys(Filename)));
end;
function ExpandUNCFileNameUTF8(const FileName: string): string;
begin
Result:=SysToUTF8(SysUtils.ExpandUNCFileName(UTF8ToSys(Filename)));
end;
function FindFirstUTF8(const Path: string; Attr: Longint; out Rslt: TSearchRec
): Longint;
begin
@ -883,7 +901,7 @@ begin
raise EFOpenError.Create(AText);
end else begin
if not FilenameIsAbsolute(LinkFilename) then
Result:=ExpandFilename(ExtractFilePath(Result)+LinkFilename)
Result:=ExpandFileNameUTF8(ExtractFilePath(Result)+LinkFilename)
else
Result:=LinkFilename;
end;
@ -1044,7 +1062,7 @@ begin
// resolve links
Result:=ReadAllLinks(Result,false);
// extract file path and expand to full name
Result:=ExpandFilename(ExtractFilePath(Result));
Result:=ExpandFileNameUTF8(ExtractFilePath(Result));
end;
function DirectoryIsWritable(const DirectoryName: string): boolean;
@ -1071,7 +1089,7 @@ end;
------------------------------------------------------------------------------}
function CleanAndExpandFilename(const Filename: string): string;
begin
Result:=ExpandFilename(TrimFileName(Filename));
Result:=ExpandFileNameUTF8(TrimFileName(Filename));
end;
{------------------------------------------------------------------------------
@ -1288,7 +1306,7 @@ var
i: Integer;
CurPath: String;
begin
CurPath:=AppendPathDelim(ExpandFilename(Directory))+Prefix;
CurPath:=AppendPathDelim(ExpandFileNameUTF8(Directory))+Prefix;
i:=1;
repeat
Result:=CurPath+IntToStr(i)+'.tmp';

View File

@ -600,7 +600,7 @@ var
I:=Length(pName);
while I > 0 do
begin
AFiles.Add(ExpandFileName(StrPas(pName)));
AFiles.Add(ExpandFileNameUTF8(StrPas(pName)));
Inc(pName,Succ(I));
I:=Length(pName);
end;
@ -669,7 +669,7 @@ var
for I:= Start to Length(SelectedStr) do
if SelectedStr[I] = ' ' then
begin
AFiles.Add(ExpandFileName(FolderName+Copy(SelectedStr,Start,I - Start)));
AFiles.Add(ExpandFileNameUTF8(FolderName+Copy(SelectedStr,Start,I - Start)));
Start:=Succ(I);
end;
end;

View File

@ -1291,7 +1291,7 @@ var
Result := GetEnvironmentVariableUTF8(EnvVarName);
end;
if (length(result)>0) then
Result := ExpandFileName(Result);
Result := ExpandFileNameUTF8(Result);
end;
begin

View File

@ -908,7 +908,7 @@ begin
Lst.AddStrings(fHeader);
Lst.AddStrings(fDocument);
Lst.SaveTofile(UTF8ToSys(ExpandFileName(aFileName)));
Lst.SaveTofile(UTF8ToSys(ExpandFileNameUTF8(aFileName)));
finally
Lst.Free;
end;
@ -1304,7 +1304,7 @@ begin
FHeader[I] := '%%' + Format('Pages: %d', [PageNumber]);
if Trim(fFileName)<>'' then
SaveToFile(ExpandFileName(fFileName));
SaveToFile(ExpandFileNameUTF8(fFileName));
end;
procedure TPostScriptPrinterCanvas.NewPage;

View File

@ -1000,7 +1000,7 @@ procedure TPkgManager.MainIDEitmOpenRecentPackageClicked(Sender: TObject);
var
AFilename: string;
begin
AFileName:=ExpandFilename((Sender as TIDEMenuItem).Caption);
AFileName:=ExpandFileNameUTF8((Sender as TIDEMenuItem).Caption);
if DoOpenPackageFile(AFilename,[pofAddToRecent])=mrOk then begin
UpdateEnvironment;
end else begin

View File

@ -74,7 +74,7 @@ var
begin
AssertTrue('Project file '+ FProjectFile + ' does not exist',
FileExistsUTF8(FProjectFile));
LazarusDir := ExpandFileName(ExtractFilePath(ParamStrUTF8(0)) + '../');
LazarusDir := ExpandFileNameUTF8(ExtractFilePath(ParamStrUTF8(0)) + '../');
LazBuildPath := LazarusDir + 'lazbuild' + GetExeExt;
AssertTrue(LazBuildPath + ' does not exist', FileExistsUTF8(LazBuildPath));
LazBuild := TProcess.Create(nil);

View File

@ -66,7 +66,7 @@ var
procedure InitDirectories;
begin
LazarusDir := ExpandFileName(ExtractFilePath(ParamStrUTF8(0)) + '../');
LazarusDir := ExpandFileNameUTF8(ExtractFilePath(ParamStrUTF8(0)) + '../');
ComponentsDir := SetDirSeparators(LazarusDir + 'components/');
ExamplesDir := LazarusDir + 'examples' + PathDelim;
CTExamplesDir := SetDirSeparators(ComponentsDir + 'codetools/examples/');

View File

@ -31,8 +31,8 @@ unit APIWizard;
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls,
Buttons, ExtCtrls;
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ExtCtrls;
type
TApiWizForm = class(TForm)

12
tools/compile_all.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
LazBuild=$1
if [ ! -x "$LazBuild" ]; then
echo Usage: $0 ./lazbuild
exit -1
fi
set -x
find . -name '*.lpk' -exec $LazBuild {} \+
#end.

View File

@ -35,7 +35,7 @@ program LazRes;
{$mode objfpc}{$H+}
uses Classes, SysUtils, LResources;
uses Classes, SysUtils, FileUtil, LResources;
function StreamIsFormInTextFormat(Stream: TMemoryStream): boolean;
const
@ -101,7 +101,7 @@ begin
begin
S := ParamStrUTF8(2);
Delete(S, 1, 1);
S := ExpandFileName(S);
S := ExpandFileNameUTF8(S);
if not FileExistsUTF8(S) then
begin
writeln('ERROR: file list not found: ', S);
@ -112,7 +112,7 @@ begin
else for a:=2 to ParamCount do FileList.Add(ParamStrUTF8(a));
ResourceFilename := ParamStrUTF8(1);
FullResourceFilename := ExpandFileName(ResourceFilename);
FullResourceFilename := ExpandFileNameUTF8(ResourceFilename);
// check that all resources exists and are not the destination file
for a:=0 to FileList.Count-1 do begin
S := FileList[a];
@ -121,7 +121,7 @@ begin
writeln('ERROR: file not found: ', S);
exit;
end;
if ExpandFileName(S) = FullResourceFilename
if ExpandFileNameUTF8(S) = FullResourceFilename
then begin
writeln('ERROR: resourcefilename = file', a);
exit;

View File

@ -271,7 +271,7 @@ begin
Verbose := False;
ConstName := 'RevisionStr';
SourceDirectory:=ChompPathDelim(ExtractFilePath(ParamStrUTF8(0)));
RevisionIncFileName := ExpandFileName('revision.inc');
RevisionIncFileName := ExpandFileNameUTF8('revision.inc');
//find switchless parameters
index := 1;
@ -281,7 +281,7 @@ begin
begin
case index of
1: SourceDirectory:=ChompPathDelim(ParamStrUTF8(i));
2: RevisionIncFileName := ExpandFileName(ParamStrUTF8(i));
2: RevisionIncFileName := ExpandFileNameUTF8(ParamStrUTF8(i));
end;
Inc(index);
end;
@ -316,7 +316,7 @@ begin
exit;
end;
RevisionIncDirName:=ExtractFilePath(ExpandFileName(RevisionIncFileName));
RevisionIncDirName:=ExtractFilePath(ExpandFileNameUTF8(RevisionIncFileName));
if (not UseStdOut) and (not DirectoryExistsUTF8(RevisionIncDirName)) then begin
writeln('Error: Target Directory "', RevisionIncDirName, '" doesn''t exist.');
exit;

View File

@ -313,7 +313,7 @@ begin
Name:=ExtractFilename(Filename);
Ext:=ExtractFileExt(Filename);
NameOnly:=LeftStr(Name,length(Name)-length(Ext));
if SysUtils.FindFirstUTF8(Path+GetAllFilesMask,faAnyFile,FileInfo)=0 then begin
if FindFirstUTF8(Path+GetAllFilesMask,faAnyFile,FileInfo)=0 then begin
repeat
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='')
or (CompareFilenames(FileInfo.Name,Name)=0) then continue;
@ -323,9 +323,9 @@ begin
then
continue;
Result.Add(Path+FileInfo.Name);
until SysUtils.FindNextUTF8(FileInfo)<>0;
until FindNextUTF8(FileInfo)<>0;
end;
SysUtils.FindCloseUTF8(FileInfo);
FindCloseUTF8(FileInfo);
end;
procedure MergePoTrees(SrcTree, DestTree: TAVLTree);