Fixes for new filesdatabase structure

This commit is contained in:
Michiel Broek
2004-03-07 11:24:21 +00:00
parent cf922872da
commit ea5a8aa2a9
9 changed files with 22 additions and 10 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}