Xref: utzoo comp.sys.ibm.pc.programmer:1779 alt.msdos.programmer:1715 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!execu!sequoia!attdso!hriso!atti07!ulysses!dptg!pegasus!dmt From: dmt@pegasus.ATT.COM (Dave Tutelman) Newsgroups: comp.sys.ibm.pc.programmer,alt.msdos.programmer Subject: Re: Problem with disk full in programs compiled with Turbo-C Summary: A few additional notes... Message-ID: <4810@pegasus.ATT.COM> Date: 3 Jun 90 15:38:03 GMT References: <5705@ncsugn.ncsu.edu> <22661.2612e98b@kuhub.cc.ukans.edu> Reply-To: dmt@pegasus1.ATT.COM (Dave Tutelman) Organization: AT&T Bell Labs - Lincroft, NJ Lines: 36 In article <22661.2612e98b@kuhub.cc.ukans.edu> 2fjomummer@kuhub.cc.ukans.edu writes: >In article <5705@ncsugn.ncsu.edu>, emigh@ncsugn.ncsu.edu (Ted H. Emigh) writes: >> I am using Turbo-C (Version 2.0), and am having trouble determining if the >> disk is full. I have tried the obvious (at least to me obvious): >> 1) ... [ return the result of a printf ] .... MSDOS I/O to disk is buffered. If DOS can write to the buffer, it says OK, only to find out later that it can't flush the buffer to the disk. >Although I've never actually tried it, there is an MS-DOS function that reports >the free space on a drive. >... > AX = sectors per cluster > BX = available cluster count > CX = bytes per sector >So, the total number of free bytes is simply AX * BX * CX. Warning!!!! The result will be a LONG, not an INT. If you do your multiplication in the "wrong" order, partial results may also be long. The safest way to do this is to call the function, explicitly convert all three results to long, then multiply into a long. Failure to do this can result in strange answers. And don't assume that you "got away with it" just because you get right answers on your setup. I experienced problems with this on a program that had worked for years, then started failing ONLY on MSDOS 4.0 with large unpartitioned disks. Cheers. Dave +---------------------------------------------------------------+ | Dave Tutelman | | Physical - AT&T Bell Labs - Lincroft, NJ | | Logical - ...att!pegasus!dmt | | Audible - (201) 576 2194 | +---------------------------------------------------------------+