PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ DBFFlushRecord()

static int DBFFlushRecord ( DBFHandle  psDBF)
static

Definition at line 195 of file dbfopen.c.

197{
198 SAOffset nRecordOffset;
199
200 if( psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1 )
201 {
203
204 nRecordOffset =
206 + psDBF->nHeaderLength;
207
208/* -------------------------------------------------------------------- */
209/* Guard FSeek with check for whether we're already at position; */
210/* no-op FSeeks defeat network filesystems' write buffering. */
211/* -------------------------------------------------------------------- */
212 if ( psDBF->bRequireNextWriteSeek ||
213 psDBF->sHooks.FTell( psDBF->fp ) != nRecordOffset ) {
214 if ( psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ) != 0 ) {
215 char szMessage[128];
216 snprintf( szMessage, sizeof(szMessage),
217 "Failure seeking to position before writing DBF record %d.",
218 psDBF->nCurrentRecord );
219 psDBF->sHooks.Error( szMessage );
220 return FALSE;
221 }
222 }
223
224 if ( psDBF->sHooks.FWrite( psDBF->pszCurrentRecord,
225 psDBF->nRecordLength,
226 1, psDBF->fp ) != 1 )
227 {
228 char szMessage[128];
229 snprintf( szMessage, sizeof(szMessage), "Failure writing DBF record %d.",
230 psDBF->nCurrentRecord );
231 psDBF->sHooks.Error( szMessage );
232 return FALSE;
233 }
234
235/* -------------------------------------------------------------------- */
236/* If next op is also a write, allow possible skipping of FSeek. */
237/* -------------------------------------------------------------------- */
239
240 if( psDBF->nCurrentRecord == psDBF->nRecords - 1 )
241 {
242 if( psDBF->bWriteEndOfFileChar )
243 {
244 char ch = END_OF_FILE_CHARACTER;
245 psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp );
246 }
247 }
248 }
249
250 return TRUE;
251}
#define STATIC_CAST(type, x)
Definition dbfopen.c:96
#define TRUE
Definition dbfopen.c:73
#define FALSE
Definition dbfopen.c:72
#define END_OF_FILE_CHARACTER
Definition dbfopen.c:82
unsigned long SAOffset
Definition shapefil.h:286
int bWriteEndOfFileChar
Definition shapefil.h:631
int nRecordLength
Definition shapefil.h:596
int nHeaderLength
Definition shapefil.h:597
char * pszCurrentRecord
Definition shapefil.h:610
int bCurrentRecordModified
Definition shapefil.h:609
SAFile fp
Definition shapefil.h:592
int bRequireNextWriteSeek
Definition shapefil.h:633
SAHooks sHooks
Definition shapefil.h:590
int nRecords
Definition shapefil.h:594
int nCurrentRecord
Definition shapefil.h:608
void(* Error)(const char *message)
Definition shapefil.h:299
SAOffset(* FTell)(SAFile file)
Definition shapefil.h:294
SAOffset(* FWrite)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
Definition shapefil.h:292
SAOffset(* FSeek)(SAFile file, SAOffset offset, int whence)
Definition shapefil.h:293

References DBFInfo::bCurrentRecordModified, DBFInfo::bRequireNextWriteSeek, DBFInfo::bWriteEndOfFileChar, END_OF_FILE_CHARACTER, SAHooks::Error, FALSE, DBFInfo::fp, SAHooks::FSeek, SAHooks::FTell, SAHooks::FWrite, DBFInfo::nCurrentRecord, DBFInfo::nHeaderLength, DBFInfo::nRecordLength, DBFInfo::nRecords, DBFInfo::pszCurrentRecord, DBFInfo::sHooks, STATIC_CAST, and TRUE.

Referenced by DBFAddNativeFieldType(), DBFAlterFieldDefn(), DBFClose(), DBFLoadRecord(), DBFReorderFields(), DBFUpdateHeader(), DBFWriteAttribute(), DBFWriteAttributeDirectly(), and DBFWriteTuple().

Here is the caller graph for this function: