Lazarus gives a wrong note: Lazarus source directory not set, even if it is set…
Show quoted text 42 lines
At first I thought replacing FileExists with DirectoryExists would make things work.
To test things a bit further a made a testprogram: program direxists;
{$mode objfpc}{$H+}
uses
Classes, SysUtils;
var
path: string;
begin
path := ExtractFileDir(ParamStr(0));
writeln(format('FPC version: %s',[{$I %FPCVERSION}]));
writeln(format('DirectoryExists(''%s''): ',[path]),
DirectoryExists(path));
writeln(format('FileExists(''%s''): ',[path]),
FileExists(path));
path := path + DirectorySeparator;
writeln(format('DirectoryExists(''%s''): ',[path]),
DirectoryExists(path));
writeln(format('FileExists(''%s''): ',[path]),
FileExists(path));
end.On linux the output for fpc 1.0.11 and fpc 1.9.1 is the same, it doesn't matter if the name has a directory seperator appended: DirectoryExists('/home/vsds/lazarus/projects/bugs/fileexists'): TRUE FileExists('/home/vsds/lazarus/projects/bugs/fileexists'): TRUE DirectoryExists('/home/vsds/lazarus/projects/bugs/fileexists/'): TRUE FileExists('/home/vsds/lazarus/projects/bugs/fileexists/'): TRUE
On win32 the output depends on the fpc version:
FPC version: 1.0.11
DirectoryExists('V:\LAZARUS\PROJECTS\BUGS\FILEEXISTS'): TRUE FileExists('V:\LAZARUS\PROJECTS\BUGS\FILEEXISTS'): TRUE DirectoryExists('V:\LAZARUS\PROJECTS\BUGS\FILEEXISTS\'): TRUE FileExists('V:\LAZARUS\PROJECTS\BUGS\FILEEXISTS\'): FALSE
FPC version: 1.9.1
DirectoryExists('V:\LAZARUS\PROJECTS\BUGS\FILEEXISTS'): TRUE FileExists('V:\LAZARUS\PROJECTS\BUGS\FILEEXISTS'): TRUE DirectoryExists('V:\LAZARUS\PROJECTS\BUGS\FILEEXISTS\'): FALSE FileExists('V:\LAZARUS\PROJECTS\BUGS\FILEEXISTS\'): FALSE
Since I first tested with fpc 1.0.11, I thought replacing FileExists with DirectoryExists would solve the incomptible behaviour between linux and win32. But with fpc 1.9.1 that doesn't help.
There are two incompatibilities here:
1. FileExists doesn't behave the same on win32 and linux. (Is this a bug?)
2. DirectoryExists doesn't behave the same on win32 for fpc 1.0.11 and fpc 1.9. (Is this a bug?)
So unless these incompatibilties are fixed (by the fpc team), we should call DirectoryExists without appended directory seperator.
I see two ways to proceed then:
1. Making calls like
DirectoryExists(ChompPathDelim(EnvironmentOptions.LazarusDirectory))
2. In for example TEnvironmentOptions instead of
FLazarusDirectory:=AppendPathDelim(TrimFilename(AValue));do
FLazarusDirectory:=ChompPathDelim(TrimFilename(AValue));What do you prefer?
Regards,
Vincent.
