dos12.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DosBufReset (1.2)
Function Group  Overview                          Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_DOSFILEMGR
 
USHORT DosBufReset(hf)
HFILE hf;    /* file handle */
 
The DosBufReset function flushes the file buffers for the specified file by
writing the current contents of the file buffer to the corresponding device.
If the file is a disk file, the function writes to the disk and updates the
directory information for the file.
 
Although DosBufReset flushes and updates information as if the file were
closed, the file remains open.
 
The DosBufReset function is a family API function.
 
Parameter  Description
────────────────────────────────────────────────────────────────────────────
 
hf         Identifies the file whose buffers are flushed. This handle must
           have been created by using the DosOpen function. If this
           parameter is set to 0xFFFF, the function flushes buffers for all
           currently open files.
 
Return Value
 
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be one of the following:
 
     ERROR_ACCESS_DENIED
     ERROR_FILE_NOT_FOUND
     ERROR_INVALID_HANDLE
 
Comments
 
If the process has several open files on removable disks, the function may
have the effect of requiring the user to repeatedly swap disks.
 
For named pipes, DosBufReset blocks the caller until all data written by the
caller has been successfully read by the other end of the pipe. This allows
communicating processes to synchronize their access to the pipe.
 
Example
 
This example opens the file abc and writes the contents of the abBuf buffer
to the file. It then writes the data to the disk by calling the DosBufReset
function to flush the buffers.
 
BYTE abBuf[512];
HFILE hf;
USHORT usAction, cbBytesWritten, usError;
usError = DosOpen("abc", &hf, &usAction, 0L, FILE_NORMAL,
    FILE_CREATE | FILE_OPEN,
    OPEN_ACCESS_WRITEONLY | OPEN_SHARE_DENYWRITE, 0L);
if (!usError) {
    DosWrite(hf, abBuf, sizeof(abBuf), &cbBytesWritten);
    DosBufReset(hf);    /* flush buffers */
 
See Also
 
DosClose, DosOpen, DosWrite