| 256 | /************************************************************************/ |
| 257 | |
| 258 | void msDBFClose(DBFHandle psDBF) |
| 259 | { |
| 260 | /* -------------------------------------------------------------------- */ |
| 261 | /* Write out header if not already written. */ |
| 262 | /* -------------------------------------------------------------------- */ |
| 263 | if( psDBF->bNoHeader ) |
| 264 | writeHeader( psDBF ); |
| 265 | |
| 266 | flushRecord( psDBF ); |
| 267 | |
| 268 | /* -------------------------------------------------------------------- */ |
| 269 | /* Update last access date, and number of records if we have */ |
| 270 | /* write access. */ |
| 271 | /* -------------------------------------------------------------------- */ |
| 272 | if( psDBF->bUpdated ) |
| 273 | { |
| 274 | uchar abyFileHeader[32]; |
| 275 | |
| 276 | fseek( psDBF->fp, 0, 0 ); |
| 277 | fread( abyFileHeader, 32, 1, psDBF->fp ); |
| 278 | |
| 279 | abyFileHeader[1] = 95; /* YY */ |
| 280 | abyFileHeader[2] = 7; /* MM */ |
| 281 | abyFileHeader[3] = 26; /* DD */ |
| 282 | |
| 283 | abyFileHeader[4] = psDBF->nRecords % 256; |
| 284 | abyFileHeader[5] = (psDBF->nRecords/256) % 256; |
| 285 | abyFileHeader[6] = (psDBF->nRecords/(256*256)) % 256; |
| 286 | abyFileHeader[7] = (psDBF->nRecords/(256*256*256)) % 256; |
| 287 | |
| 288 | fseek( psDBF->fp, 0, 0 ); |
| 289 | fwrite( abyFileHeader, 32, 1, psDBF->fp ); |
| 290 | } |
| 291 | |
| 292 | /* -------------------------------------------------------------------- */ |
| 293 | /* Close, and free resources. */ |
| 294 | /* -------------------------------------------------------------------- */ |
| 295 | fclose( psDBF->fp ); |
| 296 | |
| 297 | if( psDBF->panFieldOffset != NULL ) |
| 298 | { |
| 299 | free( psDBF->panFieldOffset ); |
| 300 | free( psDBF->panFieldSize ); |
| 301 | free( psDBF->panFieldDecimals ); |
| 302 | free( psDBF->pachFieldType ); |
| 303 | } |
| 304 | |
| 305 | free( psDBF->pszHeader ); |
| 306 | free( psDBF->pszCurrentRecord ); |
| 307 | |
| 308 | if(psDBF->pszStringField) free(psDBF->pszStringField); |
| 309 | |
| 310 | free( psDBF ); |
| 311 | } |
| 312 | |
| 313 | /************************************************************************/ |
| 314 | /* msDBFCreate() */ |
no test coverage detected