mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-30 11:29:14 +02:00
IDE: fixed wrong CleanAndExpandFile/Dir use
git-svn-id: trunk@28940 -
This commit is contained in:
parent
dc5709cc8a
commit
d5c9ca6f4f
@ -1070,7 +1070,8 @@ begin
|
||||
Abort:=false;
|
||||
try
|
||||
FileCount:=0;
|
||||
Directory:=CleanAndExpandDirectory(Directory);
|
||||
Directory:=TrimAndExpandDirectory(Directory);
|
||||
if Directory='' then exit;
|
||||
Search('',0);
|
||||
finally
|
||||
if not Abort then
|
||||
@ -1541,7 +1542,8 @@ begin
|
||||
FileCount:=0;
|
||||
Abort:=false;
|
||||
for i:=SearchPaths.Count-1 downto 0 do begin
|
||||
Directory:=CleanAndExpandDirectory(SearchPaths[i]);
|
||||
Directory:=TrimAndExpandDirectory(SearchPaths[i]);
|
||||
if (Directory='') then continue;
|
||||
if FindFirstUTF8(Directory+FileMask,faAnyFile,FileInfo)=0 then begin
|
||||
repeat
|
||||
inc(FileCount);
|
||||
@ -8572,7 +8574,7 @@ procedure TFPCUnitSetCache.SetCompilerFilename(const AValue: string);
|
||||
var
|
||||
NewFilename: String;
|
||||
begin
|
||||
NewFilename:=CleanAndExpandFilename(AValue);
|
||||
NewFilename:=TrimAndExpandFilename(AValue);
|
||||
if FCompilerFilename=NewFilename then exit;
|
||||
FCompilerFilename:=NewFilename;
|
||||
ClearConfigCache;
|
||||
@ -8589,7 +8591,7 @@ procedure TFPCUnitSetCache.SetFPCSourceDirectory(const AValue: string);
|
||||
var
|
||||
NewValue: String;
|
||||
begin
|
||||
NewValue:=CleanAndExpandDirectory(AValue);
|
||||
NewValue:=TrimAndExpandDirectory(AValue);
|
||||
if FFPCSourceDirectory=NewValue then exit;
|
||||
FFPCSourceDirectory:=NewValue;
|
||||
ClearSourceCache;
|
||||
|
@ -90,8 +90,10 @@ function FileIsText(const AFilename: string; out FileReadable: boolean): boolean
|
||||
function FilenameIsTrimmed(const TheFilename: string): boolean;
|
||||
function FilenameIsTrimmed(StartPos: PChar; NameLen: integer): boolean;
|
||||
function TrimFilename(const AFilename: string): string;
|
||||
function CleanAndExpandFilename(const Filename: string): string;
|
||||
function CleanAndExpandDirectory(const Filename: string): string;
|
||||
function CleanAndExpandFilename(const Filename: string): string; // empty string returns current directory
|
||||
function CleanAndExpandDirectory(const Filename: string): string; // empty string returns current directory
|
||||
function TrimAndExpandFilename(const Filename: string): string; // empty string returns empty string
|
||||
function TrimAndExpandDirectory(const Filename: string): string; // empty string returns empty string
|
||||
function CreateRelativePath(const Filename, BaseDirectory: string;
|
||||
UsePointDirectory: boolean = false): string;
|
||||
function FileIsInPath(const Filename, Path: string): boolean;
|
||||
@ -1376,6 +1378,20 @@ begin
|
||||
Result:=AppendPathDelim(CleanAndExpandFilename(Filename));
|
||||
end;
|
||||
|
||||
function TrimAndExpandFilename(const Filename: string): string;
|
||||
begin
|
||||
Result:=ChompPathDelim(TrimFilename(Filename));
|
||||
if Result='' then exit;
|
||||
Result:=TrimFilename(ExpandFileNameUTF8(Result));
|
||||
end;
|
||||
|
||||
function TrimAndExpandDirectory(const Filename: string): string;
|
||||
begin
|
||||
Result:=TrimFilename(Filename);
|
||||
if Result='' then exit;
|
||||
Result:=TrimFilename(AppendPathDelim(ExpandFileNameUTF8(Result)));
|
||||
end;
|
||||
|
||||
function CreateRelativePath(const Filename, BaseDirectory: string;
|
||||
UsePointDirectory: boolean): string;
|
||||
var
|
||||
|
@ -630,7 +630,7 @@ begin
|
||||
|
||||
p:=1;
|
||||
while p<=length(FPCCfgUnitPath) do begin
|
||||
Directory:=CleanAndExpandDirectory(GetNextDirectoryInSearchPath(FPCCfgUnitPath,p));
|
||||
Directory:=TrimAndExpandDirectory(GetNextDirectoryInSearchPath(FPCCfgUnitPath,p));
|
||||
if Directory<>'' then begin
|
||||
if FindFirstUTF8(Directory+GetAllFilesMask,faAnyFile,FileInfo)=0
|
||||
then begin
|
||||
@ -846,7 +846,7 @@ begin
|
||||
while p<=length(FPCCfgUnitPath) do begin
|
||||
Directory:=TrimFilename(GetNextDirectoryInSearchPath(FPCCfgUnitPath,p));
|
||||
if (Directory<>'') then begin
|
||||
Directory:=CleanAndExpandDirectory(GetNextDirectoryInSearchPath(FPCCfgUnitPath,p));
|
||||
Directory:=TrimAndExpandDirectory(GetNextDirectoryInSearchPath(FPCCfgUnitPath,p));
|
||||
if (Directory<>'') and (FilenameIsAbsolute(Directory))
|
||||
and (WarnedDirectories.IndexOf(Directory)<0) then begin
|
||||
//DebugLn(['TCheckCompilerOptsDlg.CheckFPCUnitPathsContainSources Directory="',Directory,'"']);
|
||||
|
@ -2783,7 +2783,8 @@ function TCodeBrowserView.ExportTreeAsText(Filename: String): TModalResult;
|
||||
var
|
||||
List: TStrings;
|
||||
begin
|
||||
Filename:=CleanAndExpandFilename(Filename);
|
||||
Filename:=TrimAndExpandFilename(Filename);
|
||||
if Filename='' then exit(mrCancel);
|
||||
Result:=CheckCreatingFile(Filename,true,true,true);
|
||||
if Result<>mrOk then exit;
|
||||
List:=TStringList.Create;
|
||||
|
@ -24,7 +24,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LCLIntf, Controls, StdCtrls, Forms, Buttons,
|
||||
ExtCtrls, FileUtil, LazarusIDEStrConsts, Dialogs, SynEditTypes, MacroIntf,
|
||||
ExtCtrls, FileProcs, LazarusIDEStrConsts, Dialogs, SynEditTypes, MacroIntf,
|
||||
IDEDialogs, IDEWindowIntf, InputHistory, IDEContextHelpEdit, ButtonPanel,
|
||||
SrcEditorIntf, EditorOptions, SearchFrm, Project, SynEdit, SearchResultView;
|
||||
|
||||
@ -415,8 +415,7 @@ function TLazFindInFilesDialog.GetResolvedDirectory: string;
|
||||
begin
|
||||
Result:=DirectoryComboBox.Text;
|
||||
IDEMacros.SubstituteMacros(Result);
|
||||
if Result<>'' then
|
||||
Result:=CleanAndExpandDirectory(Result);
|
||||
Result:=TrimAndExpandDirectory(Result);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -1126,7 +1126,7 @@ begin
|
||||
// check if visible
|
||||
if not IsVisible then exit;
|
||||
|
||||
NewSrcFilename:=CleanAndExpandFilename(SrcFilename);
|
||||
NewSrcFilename:=TrimAndExpandFilename(SrcFilename);
|
||||
if (NewSrcFilename=SourceFilename) and (CompareCaret(Caret,CaretXY)=0)
|
||||
and (fChain<>nil) and fChain.IsValid
|
||||
and (not LazarusIDE.NeedSaveSourceEditorChangesToCodeCache(nil)) then
|
||||
|
@ -35,7 +35,7 @@ interface
|
||||
uses
|
||||
// FCL+LCL
|
||||
Classes, SysUtils, AVL_Tree, LCLProc, LCLIntf, LCLType, Forms, Controls, Buttons,
|
||||
StdCtrls, Dialogs, ExtCtrls, FileUtil, Graphics,
|
||||
StdCtrls, Dialogs, ExtCtrls, FileProcs, Graphics,
|
||||
// CodeTools
|
||||
BasicCodeTools, CodeToolManager, CodeAtom, CodeCache, CustomCodeTool, CodeTree,
|
||||
PascalParserTool, FindDeclarationTool,
|
||||
@ -854,7 +854,7 @@ procedure TIDEHelpManager.UpdateFPCDocsHTMLDirectory;
|
||||
var
|
||||
NewDir: String;
|
||||
begin
|
||||
NewDir:=CleanAndExpandDirectory(Directory);
|
||||
NewDir:=TrimAndExpandDirectory(Directory);
|
||||
if not IsFPCDocsHTMDirectory(NewDir) then exit(false);
|
||||
HelpOpts.FPCDocsHTMLDirectory:=NewDir;
|
||||
DebugLn(['TryDirectory Changing FPCDocsHTMLDirectory to "',HelpOpts.FPCDocsHTMLDirectory,'"']);
|
||||
|
@ -2336,8 +2336,8 @@ var
|
||||
|
||||
begin
|
||||
Result:=true;
|
||||
SrcDir:=AppendPathDelim(CleanAndExpandDirectory(SrcDirectory));
|
||||
DestDir:=AppendPathDelim(CleanAndExpandDirectory(DestDirectory));
|
||||
SrcDir:=AppendPathDelim(TrimAndExpandDirectory(SrcDirectory));
|
||||
DestDir:=AppendPathDelim(TrimAndExpandDirectory(DestDirectory));
|
||||
if CompareFilenames(SrcDir,DestDir)=0 then exit;
|
||||
|
||||
if (not DirPathExists(SrcDir))
|
||||
|
13
ide/main.pp
13
ide/main.pp
@ -5044,8 +5044,8 @@ begin
|
||||
AnUnitInfo:=Project1.UnitInfoWithFilename(AFilename);
|
||||
if AnUnitInfo = nil then
|
||||
begin
|
||||
AFilename:=CleanAndExpandFilename(UnitFilename);
|
||||
if not FileExistsInIDE(AFilename,[]) then begin
|
||||
AFilename:=TrimAndExpandFilename(UnitFilename);
|
||||
if (AFilename='') or (not FileExistsInIDE(AFilename,[])) then begin
|
||||
DebugLn(['TMainIDE.DoOpenComponent file not found ',AFilename]);
|
||||
exit(mrCancel);
|
||||
end;
|
||||
@ -12546,8 +12546,8 @@ begin
|
||||
Result:=mrCancel;
|
||||
|
||||
// do not delete project files
|
||||
DestDir:=TrimFilename(AppendPathDelim(DestDirectory));
|
||||
SrcDir:=TrimFilename(AppendPathDelim(SrcDirectory));
|
||||
DestDir:=TrimAndExpandDirectory(DestDirectory);
|
||||
SrcDir:=TrimAndExpandDirectory(SrcDirectory);
|
||||
if (DestDir='') then begin
|
||||
MessageDlg('Invalid publishing Directory',
|
||||
'Destination directory for publishing is empty.',mtError,
|
||||
@ -12556,8 +12556,7 @@ begin
|
||||
exit;
|
||||
end;
|
||||
//DebugLn('TMainIDE.DoPublishModule A SrcDir="',SrcDir,'" DestDir="',DestDir,'"');
|
||||
if CompareFilenames(CleanAndExpandDirectory(SrcDir),
|
||||
CleanAndExpandDirectory(DestDir))=0
|
||||
if CompareFilenames(SrcDir,DestDir)=0
|
||||
then begin
|
||||
MessageDlg(lisInvalidPublishingDirectory,
|
||||
Format(lisSourceDirectoryAndDestinationDirectoryAreTheSameMa, ['"',
|
||||
@ -14339,7 +14338,7 @@ var
|
||||
CodeBuffer: TCodeBuffer;
|
||||
begin
|
||||
Result:=mrCancel;
|
||||
CodeBuffer:=CodeToolBoss.LoadFile(CleanAndExpandFilename(Filename),true,false);
|
||||
CodeBuffer:=CodeToolBoss.LoadFile(TrimAndExpandFilename(Filename),true,false);
|
||||
if CodeBuffer=nil then exit;
|
||||
Result:=DoJumpToCodePos(nil,nil,CodeBuffer,NewX,NewY,NewTopLine,AddJumpPoint, True, MarkLine);
|
||||
end;
|
||||
|
@ -1395,7 +1395,6 @@ begin
|
||||
Result:=FullDir+ShortIncFilename;
|
||||
if FileExistsUTF8(Result) then begin
|
||||
// file found in search dir
|
||||
Result:=CleanAndExpandFilename(Result);
|
||||
exit;
|
||||
end;
|
||||
AlreadySearchedPaths:=MergeSearchPaths(AlreadySearchedPaths,FullDir);
|
||||
|
@ -799,7 +799,8 @@ var
|
||||
CodeBuf: TCodeBuffer;
|
||||
TargetCodeBuffer: TCodeBuffer;
|
||||
begin
|
||||
TheFilename:=CleanAndExpandFilename(AFilename);
|
||||
TheFilename:=TrimAndExpandFilename(AFilename);
|
||||
if TheFilename='' then exit(false);
|
||||
CodeBuf:=CodeToolBoss.FindFile(TheFilename);
|
||||
if CodeBuf=nil then begin
|
||||
// it is not in cache
|
||||
|
@ -27,7 +27,7 @@ interface
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, Forms, Controls, Graphics, Dialogs,
|
||||
StdCtrls, ExtCtrls, ButtonPanel,
|
||||
SynRegExpr, FileUtil,
|
||||
SynRegExpr, FileProcs,
|
||||
// IDE
|
||||
IDEWindowIntf, InputHistory, IDEProcs,
|
||||
LazarusIDEStrConsts, PackageDefs;
|
||||
@ -206,13 +206,13 @@ function TAddDirToPkgDialog.GatherFiles(Directory: string;
|
||||
CurFilename: String;
|
||||
begin
|
||||
Result:=false;
|
||||
CurDir:=CleanAndExpandDirectory(CurDir);
|
||||
CurDir:=TrimAndExpandDirectory(CurDir);
|
||||
if not DirPathExists(CurDir) then begin
|
||||
MessageDlg(lisEnvOptDlgDirectoryNotFound,
|
||||
Format(lisTheDirectoryWasNotFound, [CurDir]), mtError, [mbCancel], 0);
|
||||
exit;
|
||||
end;
|
||||
if FindFirstUTF8(CurDir+GetAllFilesMask,faAnyFile,FileInfo)=0 then begin
|
||||
if FindFirstUTF8(CurDir+FileMask,faAnyFile,FileInfo)=0 then begin
|
||||
repeat
|
||||
// check if special file
|
||||
if (FileInfo.Name='.') or (FileInfo.Name='..') or (FileInfo.Name='') then
|
||||
|
Loading…
Reference in New Issue
Block a user