@@ -356,8 +356,8 @@ private function _saveRecords() {
356
356
if (file_exists ($ dbf_name )) {
357
357
unlink ($ dbf_name );
358
358
}
359
- if (!( $ this ->DBFFile = @ dbase_create ( $ dbf_name , $ this ->DBFHeader ))) {
360
- $ this ->setError ( sprintf ( ' It wasn \' t possible to create the DBase file "%s" ' , $ dbf_name ));
359
+ $ this ->DBFFile = $ this ->_createDBFFile ();
360
+ if ( $ this ->DBFFile === false ) {
361
361
return false ;
362
362
}
363
363
@@ -417,6 +417,23 @@ private function _closeSHXFile() {
417
417
}
418
418
}
419
419
420
+ /**
421
+ * Creates DBF file
422
+ *
423
+ * @return int|false
424
+ */
425
+ private function _createDBFFile ()
426
+ {
427
+ $ dbf_name = $ this ->_getFilename ('.dbf ' );
428
+ $ result = @dbase_create ($ dbf_name , $ this ->DBFHeader );
429
+ if ($ result === false ) {
430
+ $ this ->setError (sprintf ('It wasn \'t possible to create the DBase file "%s" ' , $ dbf_name ));
431
+ return false ;
432
+ }
433
+ return $ result ;
434
+
435
+ }
436
+
420
437
/**
421
438
* Loads DBF file if supported
422
439
*
@@ -429,8 +446,7 @@ private function _openDBFFile($toWrite = false) {
429
446
$ dbf_name = $ this ->_getFilename ('.dbf ' );
430
447
$ checkFunction = $ toWrite ? 'is_writable ' : 'is_readable ' ;
431
448
if (($ toWrite ) && (!file_exists ($ dbf_name ))) {
432
- if (!@dbase_create ($ dbf_name , $ this ->DBFHeader )) {
433
- $ this ->setError (sprintf ('It wasn \'t possible to create the DBase file "%s" ' , $ dbf_name ));
449
+ if ($ this ->_createDBFFile () === false ) {
434
450
return false ;
435
451
}
436
452
}
0 commit comments