[ Iznogud @ 04.09.2002. 21:58 ] @
Kako se brise zapis iz datoteke?
Da li ga je moguce potpuno fizicki ukloniti iz datoteke, tj da se brisanje ne svodi na punjenje polja zapisa nulama.
Ima li neka f-ja za to?
[ turncoat @ 06.09.2002. 22:03 ] @
A da probas da svaki zapis iza tog pomeris za jedno polje u levo? (kao izbacivanje clanova iz niza). Posle samo treba da mu kazes da skrati fajl za jedan zapis; u pascal-u postoji funkcija trunc koja na mestu na kom se nalazi file pointer udara EOF, tako da se datoteka skracuje. Ako mozes da koristis WinAPI imas funkciju SetEndOfFile (opis na kraju). Verovatno takva neka funkcija ima i u standardnoj biblioteci (ili mozda mozes samo da ispises znak za EOF u fajl?)


The SetEndOfFile function moves the end-of-file (EOF) position for the specified file to the current position of the file pointer.

BOOL SetEndOfFile(
HANDLE hFile // handle of file whose EOF is to be set
);

Parameters
hFile
Identifies the file to have its EOF position moved. The file handle must have been created with GENERIC_WRITE access to the file.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
This function can be used to truncate or extend a file. If the file is extended, the contents of the file between the old EOF position and the new position are not defined.
If you called CreateFileMapping to create a file-mapping object for hFile, you must first call UnmapViewOfFile to unmap all views and call CloseHandle to close the file-mapping object before you can call SetEndOfFile.
[ Iznogud @ 08.09.2002. 16:56 ] @
Izgleda da je jedini nacin da komplet datoteku uvucem u memoriju pa da je tu modifikujem tj. da obrisiem zapise koji mi ne trebaju i onda takvu da je ponovo zapisem u datoteku.
Medjutim sta ako je datoteka velika da bi se pohranila u memoriju?