get_file_type

Definition: integer res = get_file_type(string filename)
Description: Get the type of a file or directory.

filename: the name of the file to query. It must not have wildcards (? and *).

Returns an integer:
  • FILETYPE_UNDEFINED (-1) if file could be multiply defined
  • FILETYPE_NOT_FOUND (0) if filename does not exist
  • FILETYPE_FILE (1) if filename is a file
  • FILETYPE_DIRECTORY (2) if filename is a directory
Comments: Both forwardslash ('/') and backslash ('\\') are handled for all platforms.

A trailing slash is optional on directories, it makes no difference whether one is present or not.

The four return values above are automatically declared in psym.e/syminit().
Example:
if get_file_type("C:/Program Files (x86)/Phix/builtins/vm/papnd.e")!=FILETYPE_FILE then ?9/0 end if
if get_file_type("C:/Program Files (x86)/Phix/builtins/vm")!=FILETYPE_DIRECTORY then ?9/0 end if
if get_file_type("C:\\Program Files (x86)\\Phix\\builtins\\vm\\")!=FILETYPE_DIRECTORY then ?9/0 end if
See Also: dir