Added fdb insert code

This commit is contained in:
Michiel Broek 2004-05-05 14:21:15 +00:00
parent 0dc7b8911b
commit fa460d8597
2 changed files with 21 additions and 4 deletions

View File

@ -219,7 +219,7 @@ int mbsedb_InsertFDB(struct _fdbarea *fdb_area, struct FILE_record frec, int Add
* No records yet, simply append this first record. * No records yet, simply append this first record.
*/ */
Syslog('f', "append first record"); Syslog('f', "append first record");
fwrite(&frec, sizeof(frec), 1, fdb_area->fp); fwrite(&frec, fdbhdr.recsize, 1, fdb_area->fp);
mbsedb_UnlockFDB(fdb_area); mbsedb_UnlockFDB(fdb_area);
return TRUE; return TRUE;
} }
@ -260,7 +260,7 @@ int mbsedb_InsertFDB(struct _fdbarea *fdb_area, struct FILE_record frec, int Add
* Copy entries untill the insert point. * Copy entries untill the insert point.
*/ */
for (i = 0; i < Insert; i++) { for (i = 0; i < Insert; i++) {
fread(&fdb, fdbhdr.hdrsize, 1, fdb_area->fp); fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
/* /*
* If we see a magic that is the new magic, remove * If we see a magic that is the new magic, remove
* the old one. * the old one.

View File

@ -304,9 +304,14 @@ int UnpackFile(char *File)
*/ */
int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, char *LinkPath) int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, char *LinkPath)
{ {
char *temp1, *temp2; int rc;
#ifdef USE_EXPERIMENT
struct _fdbarea *fdb_area = NULL;
#else
int i, Insert, Done = FALSE, Found = FALSE;
FILE *fp1, *fp2; FILE *fp1, *fp2;
int i, rc, Insert, Done = FALSE, Found = FALSE; char *temp1, *temp2;
#endif
/* /*
* Copy file to the final destination and make a hard link with the * Copy file to the final destination and make a hard link with the
@ -338,6 +343,17 @@ int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, c
} }
} }
#ifdef USE_EXPERIMENT
if ((fdb_area = mbsedb_OpenFDB(Area, 30))) {
Syslog('f', "opened");
rc = mbsedb_InsertFDB(fdb_area, f_db, TRUE);
mbsedb_CloseFDB(fdb_area);
return rc;
} else {
Syslog('f', "not opened");
return FALSE;
}
#else
temp1 = calloc(PATH_MAX, sizeof(char)); temp1 = calloc(PATH_MAX, sizeof(char));
temp2 = calloc(PATH_MAX, sizeof(char)); temp2 = calloc(PATH_MAX, sizeof(char));
sprintf(temp1, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area); sprintf(temp1, "%s/fdb/file%d.data", getenv("MBSE_ROOT"), Area);
@ -432,6 +448,7 @@ int AddFile(struct FILE_record f_db, int Area, char *DestPath, char *FromPath, c
free(temp1); free(temp1);
free(temp2); free(temp2);
return TRUE; return TRUE;
#endif
} }