Changeset 21081 for trunk/psLib
- Timestamp:
- Jan 2, 2009, 3:05:47 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/fits/psFits.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/fits/psFits.c
r19035 r21081 7 7 * @author Robert DeSonia, MHPCC 8 8 * 9 * @version $Revision: 1.8 1$ $Name: not supported by cvs2svn $10 * @date $Date: 200 8-08-12 22:54:53$9 * @version $Revision: 1.82 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2009-01-03 01:05:47 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 20 20 #include <string.h> 21 21 #include <errno.h> 22 #include <libgen.h> 22 23 23 24 #include "psFits.h" … … 123 124 } 124 125 126 # define FITS_OPEN_RETRIES 5 127 # define FITS_OPEN_RETRY_WAIT 200000 128 125 129 psFits* psFitsOpen(const char* name, const char* mode) 126 130 { … … 129 133 int status = 0; 130 134 fitsfile *fptr = NULL; /* Pointer to the FITS file */ 135 136 // check that the directory exists : for NFS-mounted file systems, the directory may 137 // take some time to appear 138 139 int dirstat = 0; 140 char *tmpname = psStringCopy (name); 141 char *tmpdir = dirname (tmpname); 142 char *dir = psStringCopy (tmpdir); 143 useconds_t waittime = FITS_OPEN_RETRY_WAIT; 144 145 for (int i = 0; (i < FITS_OPEN_RETRIES) && ((dirstat = access (dir, F_OK)) != 0); i++) { 146 // if the error is not ENOENT, then the error is more serious than NFS-mount delays 147 if (errno != ENOENT) { 148 int thisErrno = errno; 149 char errorBuf[64], *errorMsg; 150 # if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE) 151 errorMsg = strerror_r (thisErrno, errorBuf, 64); 152 # else 153 strerror_r (thisErrno, errorBuf, 64); 154 errorMsg = errorBuf; 155 # endif 156 psError (PS_ERR_IO, true, "Directory (%s) for requested file is not accessible: %s", dir, errorMsg); 157 158 psFree (dir); 159 psFree (tmpname); 160 return NULL; 161 } 162 163 usleep (waittime); 164 waittime *= 2; 165 } 166 if (dirstat != 0) { 167 psError (PS_ERR_IO, true, "Directory (%s) for requested file is not accessible, timed out", dir); 168 psFree (dir); 169 psFree (tmpname); 170 return NULL; 171 } 172 psFree (dir); 173 psFree (tmpname); 131 174 132 175 /* check the mode to determine how to open/create file */ … … 154 197 155 198 if (newFile) { 156 /* Check if an existing file is in the way before creating file */199 /* Check if an existing file is in the way before creating file */ 157 200 if (access(name, F_OK) == 0) { 158 201 // file exists, delete old one first
Note:
See TracChangeset
for help on using the changeset viewer.
