Changeset 13594
- Timestamp:
- 01/25/08 08:53:00 (5 months ago)
- Files:
-
- trunk/gdal/port/cpl_vsil_unix_stdio_64.cpp (modified) (8 diffs)
- trunk/gdal/port/cpl_vsisimple.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gdal/port/cpl_vsil_unix_stdio_64.cpp
r13549 r13594 27 27 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 28 28 * DEALINGS IN THE SOFTWARE. 29 **************************************************************************** 30 * 31 * NB: Note that in wrappers we are always saving the error state (errno 32 * variable) to avoid side effects during debug prints or other possible 33 * standard function calls (error states will be overwritten after such 34 * a call). 35 * 29 36 ****************************************************************************/ 30 37 … … 140 147 141 148 { 149 int nResult = VSI_FSEEK64( fp, nOffset, nWhence ); 150 int nError = errno; 151 142 152 #ifdef VSI_DEBUG 143 144 int nResult = VSI_FSEEK64( fp, nOffset, nWhence );145 153 146 154 if( nWhence == SEEK_SET ) … … 165 173 } 166 174 175 #endif 176 177 errno = nError; 167 178 return nResult; 168 169 #else170 171 return( VSI_FSEEK64( fp, nOffset, nWhence ) );172 173 #endif174 179 } 175 180 … … 181 186 182 187 { 183 vsi_l_offset nOffset = VSI_FTELL64( fp ); 188 vsi_l_offset nOffset = VSI_FTELL64( fp ); 189 int nError = errno; 184 190 185 191 VSIDebug2( "VSIUnixStdioHandle::Tell(%p) = %ld", fp, (long)nOffset ); 186 192 193 errno = nError; 187 194 return nOffset; 188 195 } … … 208 215 { 209 216 size_t nResult = fread( pBuffer, nSize, nCount, fp ); 210 211 // Here we saving the error state to avoid side effects during debug212 // prints (file stream and error states will be cleared after print call).213 // We want debug line to come before the possible error lines.214 217 int nError = errno; 215 int nFpError = ferror(fp);216 218 217 219 VSIDebug4( "VSIUnixStdioHandle::Read(%p,%ld,%ld) = %ld", 218 220 fp, (long)nSize, (long)nCount, (long)nResult ); 219 221 220 if ( !nResult && nFpError ) 221 { 222 #ifdef notdef 223 CPLError( CE_Failure, CPLE_FileIO, 224 "Failed to read %ld blocks of %ld byte(s).\n%s", 225 (long)nCount, (long)nSize, VSIStrerror(nError) ); 226 #endif 227 } 228 222 errno = nError; 229 223 return nResult; 230 224 } … … 238 232 239 233 { 240 size_t nResult = fwrite( pBuffer, nSize, nCount, fp ); 234 size_t nResult = fwrite( pBuffer, nSize, nCount, fp ); 235 int nError = errno; 241 236 242 237 VSIDebug4( "VSIUnixStdioHandle::Write(%p,%ld,%ld) = %ld", 243 238 fp, (long)nSize, (long)nCount, (long)nResult ); 244 239 240 errno = nError; 245 241 return nResult; 246 242 } … … 276 272 VSIDebug3( "VSIUnixStdioFilesystemHandler::Open(\"%s\",\"%s\") = %p", 277 273 pszFilename, pszAccess, fp ); 278 274 279 275 if( fp == NULL ) 280 276 { 281 #ifdef notdef 282 CPLError( CE_Failure, CPLE_FileIO, 283 "Failed to open \"%s\" file.\n%s", 284 pszFilename, VSIStrerror(nError) ); 285 #endif 277 errno = nError; 286 278 return NULL; 287 279 } … … 291 283 poHandle->fp = fp; 292 284 285 errno = nError; 293 286 return poHandle; 294 287 } trunk/gdal/port/cpl_vsisimple.cpp
r13549 r13594 26 26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 27 * DEALINGS IN THE SOFTWARE. 28 **************************************************************************** 29 * 30 * NB: Note that in wrappers we are always saving the error state (errno 31 * variable) to avoid side effects during debug prints or other possible 32 * standard function calls (error states will be overwritten after such 33 * a call). 34 * 28 35 ****************************************************************************/ 29 36 … … 71 78 VSIDebug3( "VSIFOpen(%s,%s) = %p", pszFilename, pszAccess, fp ); 72 79 73 if( fp == NULL ) 74 { 75 #ifdef notdef 76 CPLError( CE_Failure, CPLE_FileIO, 77 "Failed to open \"%s\" file.\n%s", 78 pszFilename, VSIStrerror(nError) ); 79 #endif 80 return NULL; 81 } 82 80 errno = nError; 83 81 return( fp ); 84 82 } … … 103 101 104 102 { 103 int nResult = fseek( fp, nOffset, nWhence ); 104 int nError = errno; 105 105 106 #ifdef VSI_DEBUG 106 107 if( nWhence == SEEK_SET ) 107 108 { 108 VSIDebug 2( "VSIFSeek(%p,%d,SEEK_SET)", fp, nOffset );109 VSIDebug3( "VSIFSeek(%p,%d,SEEK_SET) = %d", fp, nOffset, nResult ); 109 110 } 110 111 else if( nWhence == SEEK_END ) 111 112 { 112 VSIDebug 2( "VSIFSeek(%p,%d,SEEK_END)", fp, nOffset );113 VSIDebug3( "VSIFSeek(%p,%d,SEEK_END) = %d", fp, nOffset, nResult ); 113 114 } 114 115 else if( nWhence == SEEK_CUR ) 115 116 { 116 VSIDebug 2( "VSIFSeek(%p,%d,SEEK_CUR)", fp, nOffset );117 VSIDebug3( "VSIFSeek(%p,%d,SEEK_CUR) = %d", fp, nOffset, nResult ); 117 118 } 118 119 else 119 120 { 120 VSIDebug3( "VSIFSeek(%p,%d,%d-Unknown)", fp, nOffset, nWhence ); 121 VSIDebug4( "VSIFSeek(%p,%d,%d-Unknown) = %d", 122 fp, nOffset, nWhence, nResult ); 121 123 } 122 124 #endif 123 125 124 return( fseek( fp, nOffset, nWhence ) ); 126 errno = nError; 127 return nResult; 125 128 } 126 129 … … 132 135 133 136 { 134 VSIDebug2( "VSIFTell(%p) = %ld", fp, ftell(fp) ); 135 136 return( ftell( fp ) ); 137 long nOffset = ftell(fp); 138 int nError = errno; 139 140 VSIDebug2( "VSIFTell(%p) = %ld", fp, nOffset ); 141 142 errno = nError; 143 return nOffset; 137 144 } 138 145 … … 157 164 size_t nResult = fread( pBuffer, nSize, nCount, fp ); 158 165 int nError = errno; 159 int nFpError = ferror(fp);160 166 161 167 VSIDebug4( "VSIFRead(%p,%ld,%ld) = %ld", 162 168 fp, (long)nSize, (long)nCount, (long)nResult ); 163 169 164 if ( !nResult && nFpError ) 165 { 166 #ifdef notdef 167 CPLError( CE_Failure, CPLE_FileIO, 168 "Failed to read %ld blocks of %ld byte(s).\n%s", 169 (long)nCount, (long)nSize, VSIStrerror(nError) ); 170 #endif 171 } 172 170 errno = nError; 173 171 return nResult; 174 172 } … … 181 179 182 180 { 183 size_t nResult = fwrite( pBuffer, nSize, nCount, fp ); 181 size_t nResult = fwrite( pBuffer, nSize, nCount, fp ); 182 int nError = errno; 184 183 185 184 VSIDebug4( "VSIFWrite(%p,%ld,%ld) = %ld", 186 185 fp, (long)nSize, (long)nCount, (long)nResult ); 187 186 187 errno = nError; 188 188 return nResult; 189 189 } … … 242 242 { 243 243 va_list args; 244 int nReturn , nError;244 int nReturn; 245 245 246 246 va_start( args, pszFormat ); 247 247 nReturn = vfprintf( fp, pszFormat, args ); 248 nError = errno;249 248 va_end( args ); 250 251 if ( nReturn < 0 )252 {253 CPLError( CE_Failure, CPLE_FileIO,254 "VSIFPrintf() failed.\n%s", VSIStrerror(nError) );255 }256 249 257 250 return( nReturn );
