[Lazarus] How to determine the file extension to use

Vincent Snijders vsnijders at vodafonevast.nl
Fri Oct 23 20:59:44 CEST 2009


waldo kitty schreef:
> 
> doesn't the above do the "IFDEF" thing that you said you didn't want to 
> do? ;) :lol:
> 

That is correct, let the library do the IFDEF, so you don't have to do it.

> one must also remember that .exe is not the only executable extension on 
> windows, OS/2 and DOS platforms... there is also .com... i must also 
> ask, are not shell scripts "executable" or are we looking solely at 
> binary executables?

That depends on the purpose. FPC cannot create .com files, so for 
example the file name of a fpc executable is 
ExtractFileNameWithoutExt('projectfilename.lpi')+GetExeExt;

> 
> seems to me that a more generic GetFileExt type function would be 
> better... one that might also check the linux file permissions to 
> determine if the file is executable or not... i have numerous *nix 
> executable files with and without extensions on them... checking the 
> perms is the only way to know if they can will start straight up or if 
> they must be given a kickstart (ie: sh foo.sh or php foo.php or even 
> perl foo.pl) ;)

And that is why there is 
http://lazarus-ccr.sourceforge.net/docs/lcl/fileutil/fileisexecutable.html

Vincent




More information about the Lazarus mailing list