Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!portal!cup.portal.com!Devin_E_Ben-Hur From: Devin_E_Ben-Hur@cup.portal.com Newsgroups: comp.sys.ibm.pc Subject: Re: Open files when PC goes down Message-ID: <15982@cup.portal.com> Date: 18 Mar 89 22:31:18 GMT References: <1939@holos0.UUCP> Distribution: usa Organization: The Portal System (TM) Lines: 20 Len Reed asks about how to assure that data written to an open file is recoverable after a system crash before the file close. The accepted procedure for this is to duplicate the file handle and close the duplicate. This will flush internal dos buffers to disk and write the FAT and directory info associated with the file, but will leave the original file handle open and correctly positioned. Here's an asm fragment to do this: mov bx,file_handle mov ah,045h ;duplicate handle func int 021h jc error xchg bx,ax ;move duplicate handle to bx mov ah,03Eh ;close file func int 021h jc error Devin_Ben-Hur@Cup.Portal.Com ...ucbvax!sun!portal!cup.portal.com!devin_ben-hur