Fixes for new filesdatabase structure
This commit is contained in:
@@ -325,15 +325,19 @@ int CheckTicGroup(char *Area, int SendUplink, faddr *f)
|
||||
/*
|
||||
* Create download database
|
||||
*/
|
||||
sprintf(temp, "%s/fdb/fdb%ld.data", getenv("MBSE_ROOT"), AreaNr);
|
||||
sprintf(temp, "%s/fdb/file%ld.data", getenv("MBSE_ROOT"), AreaNr);
|
||||
if ((fp = fopen(temp, "r+")) == NULL) {
|
||||
Syslog('f', "Creating new %s", temp);
|
||||
if ((fp = fopen(temp, "a+")) == NULL) {
|
||||
WriteError("$Can't create %s", temp);
|
||||
} else {
|
||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
||||
fdbhdr.recsize = sizeof(fdb);
|
||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
} else {
|
||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
chmod(temp, 0660);
|
||||
|
@@ -79,7 +79,7 @@ void Delete(int UnDel, int Area, char *File)
|
||||
die(MBERR_GENERAL);
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), Area);
|
||||
sprintf(temp, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
||||
|
||||
if ((fp = fopen(temp, "r+")) == NULL)
|
||||
die(MBERR_GENERAL);
|
||||
|
@@ -230,7 +230,7 @@ void Kill(void)
|
||||
* we run into trouble later on.
|
||||
*/
|
||||
fseek(pFile, 0, SEEK_SET);
|
||||
sprintf(sTemp, "%s/fdb/fdbtmp.data", getenv("MBSE_ROOT"));
|
||||
sprintf(sTemp, "%s/fdb/filetmp.data", getenv("MBSE_ROOT"));
|
||||
|
||||
if ((pTemp = fopen(sTemp, "a+")) != NULL) {
|
||||
fwrite(&fdbhdr, fdbhdr.hdrsize, 1, pTemp);
|
||||
|
@@ -443,7 +443,7 @@ int CheckFDB(int Area, char *Path)
|
||||
int rc = FALSE;
|
||||
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(temp, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), Area);
|
||||
sprintf(temp, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
|
||||
|
||||
/*
|
||||
* Open the file database, create new one if it doesn't excist.
|
||||
@@ -454,9 +454,13 @@ int CheckFDB(int Area, char *Path)
|
||||
WriteError("$Can't create %s", temp);
|
||||
rc = TRUE;
|
||||
} else {
|
||||
fdbhdr.hdrsize = sizeof(fdbhdr);
|
||||
fdbhdr.recsize = sizeof(fdb);
|
||||
fwrite(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
} else {
|
||||
fread(&fdbhdr, sizeof(fdbhdr), 1, fp);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user