| iMatix home page | << | < | > | >> |
![]() Version 1.91 |
#include "sflfile.h" Bool file_is_program ( const char *filename)
Returns TRUE if the specified filename is an executable program on the PATH. Under DOS, and Windows, appends ".com", ".exe", and ".bat" to the file, in that order, to build an executable filename, then searches the PATH definition for the executable filename. Under OS/2, appends ".exe", and ".cmd" to the file, in that order, to build an executable filename, then searches the PATH definition for the executable filename. If the filename already has a path specifier, will not use the PATH definition. Under VMS, appends "exe" and "com" to the file, in that order, to build an executable filename. Searches the PATH if necessary.
{ Bool executable = FALSE; /* Return code */ #if (defined (__UNIX__)) char *found_file; ASSERT (filename); found_file = file where ('r', "PATH", filename, ""); if (found_file && (file_mode (found_file) & S_IEXEC)) executable = TRUE; /* Executable file found */ #elif (defined (__VMS__)) char *found_file; ASSERT (filename); found_file = file where ('r', "PATH", filename, ""); if (!found_file) found_file = file where ('r', "PATH", filename, ".exe"); if (!found_file) found_file = file where ('r', "PATH", filename, ".com"); if (found_file && (file_mode (found_file) & S_IEXEC)) executable = TRUE; /* Executable file found */ #elif (defined (MSDOS_FILESYSTEM)) char *path; /* What path do we search? */ ASSERT (filename); /* If the filename already contains a path, don't look at PATH */ if (strchr (filename, '/') || strchr (filename, '\\')) path = NULL; else path = "PATH"; # if (defined (__WINDOWS__)) if (file where ('r', path, filename, ".com") || file where ('r', path, filename, ".exe") || file where ('r', path, filename, ".bat")) executable = TRUE; /* Executable file found */ # else /* OS/2 */ if (file where ('r', path, filename, ".exe") || file where ('r', path, filename, ".cmd")) executable = TRUE; # endif #endif return (executable); }
| << | < | > | >> |
![]() |