C+ C NAME: C iCheckDirectory C PURPOSE: C Check whether a directory exists or not C CATEGORY: C Environment C CALLING SEQUENCE: function iCheckDirectory(cDir) C INPUTS: C cDir character*(*) Directory to be checked C OUTPUTS: C I integer 0: directory does not exist, or parse error C 1: directory exists C CALLS: C iSearch, iSetFileSpec, iDir2File, iFile2Dir C INCLUDE: include 'filparts.h' C SIDE EFFECTS: C iFile2Dir is called to convert the input from file format to directory format. C On VMS this converts DEVICE:[DIR]NAME.DIR to DEVICE:[DIR.NAME] C On DOS and Unix it adds the trailing (back)slash. C C If the directory exists it is stored using iSetFileSpec. C The calling procedure can retrieve the fully qualified directory name C (including (back)slash on DOS and Unix) using: C I = iGetFileSpec(0,FIL__DIRECTORY,cDir) C (the include file 'filparts.h' sets the value FIL__DIRECTORY) C DEPENDENCY TREE: C iCheckDirectory C iSetFileSpec C iGetFileSpec C iDir2File C iSearch *system call (on VMS) C *depends on various system calls on DOS: C iOSRenameFile *(system call) C iOSDeleteFile *(system call) C iOSGetDirectory *(system call) C iOSCheckDirectory *(system call) C iOSSpawnCmd *(system call) C ExitCmd *(system call) C PROCEDURE: C iSearch is used to check whether the directory exists. C MODIFICATION HISTORY: C JUL-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu) C Added more documentation C- character cDir*(*) character cFile*(FIL__LENGTH) !------- ! Convert to directory name. This makes the call to iSearch more efficient, ! especially on DOS and Unix and the sign on the 1st arg does not matter anymore. if (iFile2Dir(cDir, cFile) .eq. 0) cFile = cDir !------- ! On the VAX the call iSearch(11,cDir,cFile) only appears to test for ! directory existence on the local machine. When testing a directory on a ! foreign host iSearch will return 0, even when the directory does not exist ! (on the local machine it will return 2 (parse error) for a non-existing ! directory). iCheckDirectory = iSearch(11,cFile,cFile) if (iCheckDirectory .eq. 2) then ! Parse error on local machine iCheckDirectory = 0 else if (iCheckDirectory .ne. 1) then ! DOS will always be 1 !------- ! On the VAX, if iCheckDirectory = 0 the directory might still not exist ! Convert to a file name and test for the existence of the file. I = iGetFileSpec(0,FIL__DIRECTORY,cFile) if (iDir2File(cFile,cFile) .gt. 0) then! Search for dir file on remote machine iCheckDirectory = mod(iSearch(11,cFile,cFile),2) else ! No dir-file for root. iCheckDirectory = 1 ! But does the device exist?????? end if end if end if return end