Table of contents
CSPICE_EXISTS returns a boolean indicating whether the input
file exists (True) or not (False).
Given:
fname the name of the file in question.
help, fname
STRING = Scalar
This may be any unambiguous file name valid on the user's
computer, for example
'/usr/dir1/dir2/DATA.DAT'
'./DATA.DAT'
'c:\usr\dir1\dir2\data.dat'
Environment or shell variables may not be used.
the call:
exists = cspice_exists( fname )
returns:
exists the value True if the file exists, False otherwise.
help, exists
BOOLEAN = Scalar
None.
Any numerical results shown for these examples may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
1) Given two arbitrary files (one of them the actual code example
source file), determine if they exists.
Example code begins here.
PRO exists_ex1
;;
;; Define an array of file names.
;;
fname = [ 'exists_ex1.txt', 'exists_ex1.pro' ]
for i=0, (n_elements(fname) - 1) do begin
if ( cspice_exists( fname[i] ) ) then begin
print, 'The file ', fname[i], ' exists.'
endif else begin
print, 'Cannot find the file ', fname[i]
endelse
endfor
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Cannot find the file exists_ex1.txt
The file exists_ex1.pro exists.
2) Repeat the example using the native IDL code to perform
the same task.
Example code begins here.
PRO exists_ex2
;;
;; Define an array of file names.
;;
fname = [ 'exists_ex2.txt', 'exists_ex2.pro' ]
for i=0, (n_elements(fname) - 1) do begin
if ( findfile( fname[i] ) ) then begin
print, 'The file ', fname[i], ' exists.'
endif else begin
print, 'Cannot find the file ', fname[i]
endelse
endfor
END
When this program was executed on a Mac/Intel/IDL8.x/64-bit
platform, the output was:
Cannot find the file exists_ex2.txt
The file exists_ex2.pro exists.
None.
1) If the filename is blank, the error SPICE(BLANKFILENAME) is
signaled by a routine in the call tree of this routine.
2) If an i/o error occurs while checking the existence of the
indicated file, the error SPICE(INQUIREFAILED) is signaled by
a routine in the call tree of this routine.
3) If the input argument `fname' is undefined, an error is
signaled by the IDL error handling system.
4) If the input argument `fname' is not of the expected type, or
it does not have the expected dimensions and size, an error is
signaled by the Icy interface.
None.
None.
ICY.REQ
None.
J. Diaz del Rio (ODC Space)
E.D. Wright (JPL)
-Icy Version 1.1.0, 25-AUG-2021 (JDR)
Changed the input argument name "name" to "fname" for
consistency with other routines.
Edited the header to comply with NAIF standard. Added complete code
example.
Edited the -I/O section to match standard format.
Added -Parameters, -Exceptions, -Files, -Restrictions,
-Literature_References and -Author_and_Institution sections.
Removed reference to the routine's corresponding CSPICE header from
-Abstract section.
Added arguments' type and size information in the -I/O section.
-Icy Version 1.0.1, 09-DEC-2005 (EDW)
Added -Examples section.
-Icy Version 1.0.0, 16-JUN-2003 (EDW)
does the file exist
|