CHECKFILE Function
Determines if a file can be read from or written to.
Usage
status = CHECKFILE(filename)
Input Parameters
filename—A string containing the name of a file. If a pathname is not included, the function looks in the current directory for the file.
Returned Value
status—A value indicating if the file can be used for the given operation.
1—Indicates the file can be used for the specified operation.
0—Indicates the file cannot be used.
Keywords
FullName—(UNIX Only) A string containing the expanded filename is returned. Constructs such as ~user and $ENV_VAR are expanded.
Is_Dir—Returns a 1 if filename is a directory.
Read—If specified and nonzero, the function verifies that file is readable.
note | Either the Read keyword or the Write keyword must be specified. |
Size—Returns the size of the file in bytes.
Write—If specified and nonzero, the function verifies that file is writable.
Discussion
You must supply either the Read or Write keyword. If neither of these keywords is supplied, the CHECKFILE function returns 0.
Example
status = CHECKFILE(!Data_dir + 'head.img', /Read)
PRINT, status
; PV-WAVE prints: 1
status = CHECKFILE(!Data_dir + 'new_head.img', /Write)
PRINT, status
; PV-WAVE prints: 1
status = CHECKFILE(!Data_dir + 'head_not.img', /Read)
PRINT, status
; PV-WAVE prints: 0
status = CHECKFILE(!Dir, /Read, Is_Dir=isdir)
PRINT, status
; PV-WAVE prints: 1
; Determine if a directory exists.
PRINT, isdir
; PV-WAVE prints: 1
; Check the size of a file.
status = CHECKFILE(!Data_dir + 'head.img', Size=sz)
PRINT, sz
; PV-WAVE prints: 262144
See Also
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.