C File Clugger....
Posted: Wed Aug 10, 2005 7:22 am
ugh....
I've wrote (or really, trying to write) a system which takes entrys (of about 10kb) and stores them in a single file. Basically each entry has a 50-byte name, and to find it it will load until the name entry in the loaded temporary class instance is what it's looking for.
The problem is, when It goes back to write it/update it in the file (some time later, after closing the file, it has to open it again) it writes it in the right place, but all the other data has mysteriously...turned into remnants of files that have been deleted (of course I know that's becuase windows only erases FAT entries, not the entire file).
I get to the position in the file by taking the index variable (p), multiplying it by the size of each entry (about 10,760 bytes) and then using fsetpos(fp, pos);
Of course I do something like this really:
f_pos Pos = p*sizeof(History);
fsetpos(fp, &Pos);
The file is opened for write-only in binary mode.
I've wrote (or really, trying to write) a system which takes entrys (of about 10kb) and stores them in a single file. Basically each entry has a 50-byte name, and to find it it will load until the name entry in the loaded temporary class instance is what it's looking for.
The problem is, when It goes back to write it/update it in the file (some time later, after closing the file, it has to open it again) it writes it in the right place, but all the other data has mysteriously...turned into remnants of files that have been deleted (of course I know that's becuase windows only erases FAT entries, not the entire file).
I get to the position in the file by taking the index variable (p), multiplying it by the size of each entry (about 10,760 bytes) and then using fsetpos(fp, pos);
Of course I do something like this really:
f_pos Pos = p*sizeof(History);
fsetpos(fp, &Pos);
The file is opened for write-only in binary mode.