9.6 File Access

The following functions return fail if a system error occurred, for example, if name-file does not exist (except for IsExistingFile). In this case the function LastSystemError can be used to get information about the error.

  • IsExistingFile( name-file ) F

    returns true if a file with the filename name-file exists, and false otherwise.

  • IsReadableFile( name-file ) F

    returns true if a file with the filename name-file exists and the GAP process has read permissions for the file, and false if it has no such permissions.

  • IsWriteableFile( name-file ) F

    returns true if a file with the filename name-file exists and the GAP process has write permissions for the file, and false if it has no such permissions.

  • IsExecuteableFile( name-file ) F

    returns true if a file with the filename name-file exists and the GAP process has execute permissions for the file, and false if it has no such permissions. Note that execute permissions do not imply that it is possible to execute the file, e.g., it could only be an executable on a different machine.

  • IsDirectoryPath( name-file ) F

    returns true if the file with the filename name-file exists and is a directory. It returns false if the file exists but is a plain file. Note that this functions does not check if the GAP process actually has write or execute permissions for the directory.

    Examples

    # the file `/bin/date' exists
    gap> IsExistingFile( "/bin/date" );    
    true
    
    # the file `/bin/date.new' does not exist
    gap> IsExistingFile( "/bin/date.new" );
    false
    
    # `/bin/date' is not a directory
    gap> IsExistingFile( "/bin/date/new" );
    fail
    gap> LastSystemError().message;
    "Not a directory"
    
    # the file `/bin/date' is readable
    gap> IsReadableFile( "/bin/date" );
    true
    
    # the file `/bin/date.new' does not exist
    gap> IsReadableFile( "/bin/date.new" );
    fail
    gap> LastSystemError().message;        
    "No such file or directory"
    
    # the file `/bin/date' is not writable
    gap> IsWritableFile( "/bin/date" );
    false
    
    # but executable
    gap> IsExecutableFile( "/bin/date" );
    true
    

    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    February 2000