MCPcopy Index your code
hub / github.com/MapServer/MapServer / msDBFCreate

Function msDBFCreate

mapxbase.c:318–373  ·  view source on GitHub ↗

/ msDBFCreate() */ / Create a new .dbf file. */ /

Source from the content-addressed store, hash-verified

316/* Create a new .dbf file. */
317/************************************************************************/
318DBFHandle msDBFCreate( const char * pszFilename )
319
320{
321 DBFHandle psDBF;
322 FILE *fp;
323
324 /* -------------------------------------------------------------------- */
325 /* Create the file. */
326 /* -------------------------------------------------------------------- */
327 fp = fopen( pszFilename, "wb" );
328 if( fp == NULL )
329 return( NULL );
330
331 fputc( 0, fp );
332 fclose( fp );
333
334 fp = fopen( pszFilename, "rb+" );
335 if( fp == NULL )
336 return( NULL );
337
338 /* -------------------------------------------------------------------- */
339 /* Create the info structure. */
340 /* -------------------------------------------------------------------- */
341 psDBF = (DBFHandle) malloc(sizeof(DBFInfo));
342 if (psDBF == NULL)
343 {
344 msSetError(MS_MEMERR, "%s: %d: Out of memory allocating %u bytes.\n", "msDBFCreate()",
345 __FILE__, __LINE__, sizeof(DBFInfo));
346 fclose(fp);
347 return NULL;
348 }
349
350 psDBF->fp = fp;
351 psDBF->nRecords = 0;
352 psDBF->nFields = 0;
353 psDBF->nRecordLength = 1;
354 psDBF->nHeaderLength = 33;
355
356 psDBF->panFieldOffset = NULL;
357 psDBF->panFieldSize = NULL;
358 psDBF->panFieldDecimals = NULL;
359 psDBF->pachFieldType = NULL;
360 psDBF->pszHeader = NULL;
361
362 psDBF->nCurrentRecord = -1;
363 psDBF->bCurrentRecordModified = MS_FALSE;
364 psDBF->pszCurrentRecord = NULL;
365
366 psDBF->pszStringField = NULL;
367 psDBF->nStringFieldLen = 0;
368
369 psDBF->bNoHeader = MS_TRUE;
370 psDBF->bUpdated = MS_FALSE;
371
372 return( psDBF );
373}
374
375/************************************************************************/

Callers 3

process_shapefilesFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 1

msSetErrorFunction · 0.85

Tested by

no test coverage detected