648 char *pszFullname, *pszBasename;
656 pszBasename = (
char *)
malloc(strlen(pszFilename) + 5);
657 strcpy(pszBasename, pszFilename);
658 for (i = strlen(pszBasename) - 1;
659 i > 0 && pszBasename[i] !=
'.' && pszBasename[i] !=
'/' && pszBasename[i] !=
'\\';
663 if (pszBasename[i] ==
'.')
664 pszBasename[i] =
'\0';
666 pszFullname = (
char *)
malloc(strlen(pszBasename) + 5);
667 sprintf(pszFullname,
"%s.dbf", pszBasename);
672 fp = psHooks->
FOpen(pszFullname,
"wb");
680 psHooks->
FWrite(&chZero, 1, 1, fp);
683 fp = psHooks->
FOpen(pszFullname,
"rb+");
691 sprintf(pszFullname,
"%s.cpg", pszBasename);
692 if (pszCodePage != NULL)
694 if (strncmp(pszCodePage,
"LDID/", 5) == 0)
696 ldid = atoi(pszCodePage + 5);
703 psHooks->
FWrite((
char *)pszCodePage, strlen(pszCodePage), 1, fpCPG);
707 if (pszCodePage == NULL || ldid >= 0)
709 psHooks->
Remove(pszFullname);
718 psDBF = (DBFHandle)calloc(1,
sizeof(DBFInfo));
720 memcpy(&(psDBF->sHooks), psHooks,
sizeof(
SAHooks));
724 psDBF->nRecordLength = 1;
725 psDBF->nHeaderLength = 33;
727 psDBF->panFieldOffset = NULL;
728 psDBF->panFieldSize = NULL;
729 psDBF->panFieldDecimals = NULL;
730 psDBF->pachFieldType = NULL;
731 psDBF->pszHeader = NULL;
733 psDBF->nCurrentRecord = -1;
734 psDBF->bCurrentRecordModified =
FALSE;
735 psDBF->pszCurrentRecord = NULL;
737 psDBF->bNoHeader =
TRUE;
739 psDBF->iLanguageDriver = ldid > 0 ? ldid : 0;
740 psDBF->pszCodePage = NULL;
743 psDBF->pszCodePage = (
char *)
malloc(strlen(pszCodePage) + 1);
744 strcpy(psDBF->pszCodePage, pszCodePage);
SAFile(* FOpen)(const char *filename, const char *access)
SAOffset(* FWrite)(void *p, SAOffset size, SAOffset nmemb, SAFile file)
int(* Remove)(const char *filename)
int(* FClose)(SAFile file)