IDE: made SwitchPathDelims more generic

git-svn-id: trunk@18132 -
This commit is contained in:
mattias 2009-01-05 11:24:58 +00:00
parent e1ea4a30d9
commit 38abb0125e
2 changed files with 37 additions and 9 deletions

View File

@ -1054,18 +1054,18 @@ end;
procedure TBaseCompilerOptions.LoadTheCompilerOptions(const Path: string);
var
p: String;
PathDelimChanged: boolean;
PathDelimChange: boolean;
FileVersion: Integer;
i: LongInt;
function f(const Filename: string): string;
begin
Result:=SwitchPathDelims(Filename,PathDelimChanged);
Result:=SwitchPathDelims(Filename,PathDelimChange);
end;
function sp(const SearchPath: string): string;
begin
Result:=SwitchPathDelims(SearchPath,PathDelimChanged);
Result:=SwitchPathDelims(SearchPath,PathDelimChange);
Result:=MinimizeSearchPath(Result);
end;
@ -1100,7 +1100,7 @@ var
begin
{ Load the compiler options from the XML file }
p:=Path;
PathDelimChanged:=XMLConfigFile.GetValue(p+'PathDelim/Value', '/')<>PathDelim;
PathDelimChange:=XMLConfigFile.GetValue(p+'PathDelim/Value', '/')<>PathDelim;
FileVersion:=XMLConfigFile.GetValue(p+'Version/Value', 0);
{ Target }
@ -1119,7 +1119,7 @@ begin
{ Conditionals }
TCompOptConditionals(FConditionals).LoadFromXMLConfig(XMLConfigFile,
Path+'Conditionals/',PathDelimChanged);
Path+'Conditionals/',PathDelimChange);
{ Parsing }
p:=Path+'Parsing/';
@ -1234,8 +1234,8 @@ begin
{ Compilation }
CompilerPath := f(XMLConfigFile.GetValue(p+'CompilerPath/Value','$(CompPath)'));
ExecuteBefore.LoadFromXMLConfig(XMLConfigFile,p+'ExecuteBefore/',PathDelimChanged);
ExecuteAfter.LoadFromXMLConfig(XMLConfigFile,p+'ExecuteAfter/',PathDelimChanged);
ExecuteBefore.LoadFromXMLConfig(XMLConfigFile,p+'ExecuteBefore/',PathDelimChange);
ExecuteAfter.LoadFromXMLConfig(XMLConfigFile,p+'ExecuteAfter/',PathDelimChange);
CreateMakefileOnBuild:=XMLConfigFile.GetValue(p+'CreateMakefileOnBuild/Value',false);
end;

View File

@ -78,6 +78,14 @@ function CopyDirectoryWithMethods(const SrcDirectory, DestDirectory: string;
OnCopyFile: TOnCopyFileMethod; OnCopyError: TOnCopyErrorMethod;
Data: TObject): boolean;
type
TPathDelimSwitch = (
pdsNone, // no change
pdsSystem, // switch to current PathDelim
pdsUnix, // switch to slash /
pdsWindows // switch to backslash \
);
// file names
function CompareFilenames(const Filename1, Filename2: string): integer;
function CompareFilenames(const Filename1, Filename2: string;
@ -89,6 +97,7 @@ function FilenameIsPascalSource(const Filename: string): boolean;
function FilenameIsFormText(const Filename: string): boolean;
function CreateRelativePath(const Filename, BaseDirectory: string;
UsePointDirectory: boolean = false): string;
function SwitchPathDelims(const Filename: string; Switch: TPathDelimSwitch): string;
function SwitchPathDelims(const Filename: string; Switch: boolean): string;
function ChompEndNumber(const s: string): string;
@ -808,11 +817,30 @@ begin
Result:=FileProcs.CreateAbsoluteSearchPath(SearchPath,BaseDirectory);
end;
function SwitchPathDelims(const Filename: string; Switch: boolean): string;
function SwitchPathDelims(const Filename: string; Switch: TPathDelimSwitch
): string;
var
i: Integer;
p: Char;
begin
Result:=Filename;
case Switch of
pdsSystem: p:=PathDelim;
pdsUnix: p:='/';
pdsWindows: p:='\';
else exit;
end;
for i:=1 to length(Result) do
if Result[i] in ['/','\'] then
Result[i]:=p;
end;
function SwitchPathDelims(const Filename: string; Switch: boolean): string;
begin
if Switch then
DoDirSeparators(Result);
Result:=SwitchPathDelims(Filename,pdsSystem)
else
Result:=Filename;
end;
function ChompEndNumber(const s: string): string;