Subj : Committing file changes To : Coridon Henshaw From : Herbert Rosenau Date : Sun Aug 13 2000 12:41 pm Am 11.08.00 23:38 schrieb Coridon Henshaw CH> What's the proper way to 'checkpoint' an open file so as to ensure that the CH> file's control structures are consistant on disk? I would have thought CH> that calling fflush() after every file write would be sufficient, but a CH> recent trap proved that calling fflush() after file writes was no CH> protection against CHKDSK truncating the file well before the last write. CH> I suppose I could close and reopen the file after every update, but I was CH> hoping to find a more elegant solution. Any ideas? Don't use the C runtime! Use DosOpen(....OPEN_FLAGS_WRITE_THROUGH....) and other Dos... APIs instead. The C runtime can't handle OS/2 specific flags. fflush() does nothing than flush the runtime buffers - not the filesystem/device ones. This means the runtime doen#t always write directly to disk. And if it has to do so (eg. fflush() the driver itself doen't it because the filesystem cache (cache.exe/diskcache) doesn't it. If a file is closed the filesystem my delay the last write until the disk is idle for a time. The only way YOU can define exactly that the file is written directly to disk is using DosOpen and set the flag. This will disable the cache for that given file and all DosWrite goes directly on disk. But absolutly nothing will get you sure the file is clean if a unpropper reboot occures. The only you can do is to hold the window small - AND make a clean shutdown. --- Sqed/32 1.15/development 1122: * Origin: Lieber arm und gesund, als reich und beim Bund (2:2476/493) .