Microsoft KB Archive/31223

Data Lost on Disk Full - File Status Not Helpful

PSS ID Number: Q31223 Article last modified on 04-21-1993

2.20 MS-DOS

Summary:

Question: When run from a floppy disk with less than 1024 available bytes free, a COBOL program creates a Line Sequential file and successfully writes a number of records to the file/buffer (as indicated by the file status). When attempting to WRITE more than 512 bytes, a file status of “34” (Disk space full) is generated, as expected. However, after closing the file (status “00”) and exiting the program, the floppy disk contains a data file with a zero-byte length. What happened to all of the records that were written successfully? Should the file status for the CLOSE statement indicate that it was unsuccessful because data was lost?

Response: The “00” file status returned from the WRITE commands indicates that the records were written successfully to the file buffer; it is not an indication that the information was written successfully to the disk. The “00” file status returned from the CLOSE command indicates that the operating system encountered no errors during the close operation (i.e., closing file, deallocating file handle(s), updating directory, etc.). Other than monitoring available bytes free or closing and reopening the file after writing each record, it is difficult to prevent losing the information that is currently in the file buffer when available disk space is exhausted.

Additional reference words: 2.20 Copyright Microsoft Corporation 1993.