Xref: utzoo comp.lang.pascal:4790 comp.os.msdos.programmer:2281 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uwm.edu!psuvax1!rutgers!gatech!ncsuvx!news From: bank@lea.ncsu.edu (Dave The DM) Newsgroups: comp.lang.pascal,comp.os.msdos.programmer Subject: Re: Statusof a msdos file after dos error Message-ID: <1990Dec7.053930.14807@ncsuvx.ncsu.edu> Date: 7 Dec 90 05:39:30 GMT References: <2350@bnlux0.bnl.gov> Organization: /etc/organization Lines: 61 In article <2350@bnlux0.bnl.gov> kushmer@bnlux0.bnl.gov (christopher kushmerick) writes: >After a file has been opened (Via assign, reset/rewrite) what is its >status following a disk operation that results in dos reporting an io error? > > >Here is the exact situation: > >turbo pascal 5.0 > >I open a file. the reset/rewite occurs with success. > >Now I do an operation, and it fails, perhas, for example, because the >user took the diskette out of the drive. What is the status of the file? >Do I have to close it? Can I close it? should I close it? > >It should be obvious that I am compiling this with {$I-} set so that I may >process my own io errors. > > > >-- >Chris Kushmerick >kushmer@bnlux0.bnl.gov <===Try this one first >kushmerick@pofvax.sunysb.edu 1) What do you mean by "status"?? The location of the file pointer is (in most situations) undefined. The file is probably still there. I'm not sure what you're looking for here. 2) Implicit in your question is "Is the file still open?" Yes, it is (well, in all the PC language implementations I have worked in - TP 2.0 thru 5.0, MS C 5.1 thru 6.00a, etc). Do you "have" to close it?? I dunno. What do you want to do with it. You may want to retry your operation. Or you may want to close it, then reopen, then retry. You don't HAVE to close it, altho in some cases this can be a good idea (depends on the nature of the I/O error). 3) Can you close it?? Again, depends on the exact I/O error. If the problem came about because some lobotomized pea-brain opened a diskette drive door, then I daresay that a close operation won't have much success. If it was just a system burp, then you may not have any problem. 4) Should you close it?? See 2) above. It all depends on exactly what the problem was and what you are doing with the file. Depending on what you're using for, closing the file can range from a great idea (perhaps its your master database file) to a so-so idea (its your temporary data file). Its rarely a bad idea. File ops are always a pain. The DOS 3.x critical error handler lists gobs and gobs of different error codes for file operations (which is a good thing - I HATE not knowing >>exactly<< what the system thinks went wrong. ) Anyway, hope this helps. Dave the DM bank@lea.csc.ncsu.edu