[Lazarus] How to determine the file extension to use
waldo kitty
wkitty42 at windstream.net
Fri Oct 23 20:53:33 CEST 2009
Graeme Geldenhuys wrote:
> 2009/10/23 Vincent Snijders <vsnijders at vodafonevast.nl>:
>> http://lazarus-ccr.sourceforge.net/docs/lcl/fileutil/getexeext.html
>
>
> Looking at the implementation of GetExeExt(), I'm not sure how
> "complete" this is. Especially if applied to other platforms. For
> example, OS/2 also uses ".exe" extension. Also, doesn't Mac OS X use
> something like .dm? extension. So I guess this function needs a bit
> more work before it is FPC ready. :-)
i had to laugh... big belly laugh...
> --------------------------
> function GetExeExt: string;
> begin
> {$IFDEF WINDOWS}
> Result:='.exe';
> {$ELSE}
> Result:='';
> {$ENDIF}
> end;
> --------------------------
doesn't the above do the "IFDEF" thing that you said you didn't want to do? ;) :lol:
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?
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) ;)
More information about the Lazarus
mailing list