IDE: changed CreateCompilerTestPascalFilename as suggested by Mattias

* return '', if no file could be created
* use same implementation on all platforms

git-svn-id: trunk@15790 -
This commit is contained in:
vincents 2008-07-15 22:16:14 +00:00
parent 5b3c40da89
commit 92b6e4d35d
3 changed files with 28 additions and 39 deletions

View File

@ -99,33 +99,6 @@ begin
SecondaryConfigPath:=ExpandFileName(NewValue);
end;
{---------------------------------------------------------------------------
function CreateCompilerTestPascalFilename: string;
---------------------------------------------------------------------------}
function CreateCompilerTestPascalFilename: string;
function CreateFile(const Filename: string): boolean;
var
fs: TFileStream;
begin
if FileExists(Filename) then exit(true);
Result:=false;
try
fs:=TFileStream.Create(Filename,fmCreate);
fs.Free;
Result:=true;
except
end;
end;
begin
Result:=AppendPathDelim(GetPrimaryConfigPath)+'compilertest.pas';
if CreateFile(Result) then exit;
Result:=AppendPathDelim(GetTempDir)+'compilertest1.pas';
if CreateFile(Result) then exit;
writeln('unable to create temporay file ',Result);
end;
{---------------------------------------------------------------------------
function FindDefaultCompilerPath: string;
---------------------------------------------------------------------------}

View File

@ -107,18 +107,6 @@ begin
[]);
end;
function CreateCompilerTestPascalFilename: string;
var
fs: TFileStream;
begin
Result := AppendPathDelim(GetPrimaryConfigPath) + 'compilertest.pas';
if not FileExists(Result) then
begin
fs := TFileStream.Create(Result, fmCreate);
fs.Free;
end;
end;
function GetDefaultCompiledUnitExt(FPCVersion, FPCRelease: integer): string;
begin
if (FPCVersion=1) and (FPCRelease=0) then

View File

@ -130,6 +130,34 @@ implementation
{$I lazconf.inc}
{---------------------------------------------------------------------------
function CreateCompilerTestPascalFilename: string;
---------------------------------------------------------------------------}
function CreateCompilerTestPascalFilename: string;
function CreateFile(const Filename: string): boolean;
var
fs: TFileStream;
begin
if FileExists(Filename) then exit(true);
Result:=false;
try
fs:=TFileStream.Create(Filename,fmCreate);
fs.Free;
Result:=true;
except
end;
end;
begin
Result:=AppendPathDelim(GetPrimaryConfigPath)+'compilertest.pas';
if CreateFile(Result) then exit;
Result:=AppendPathDelim(GetTempDir)+'compilertest.pas';
if CreateFile(Result) then exit;
Debugln('unable to create temporay file ',Result);
Result:='';
end;
function FindDefaultExecutablePath(const Executable: string): string;
begin
if FilenameIsAbsolute(Executable) then