Article View: alt.msdos.programmer
Article #1056Re: How do I get starting sector of file?
From: Ralf.Brown
Date: Fri, 22 Jan 1993 14:22
Date: Fri, 22 Jan 1993 14:22
29 lines
2175 bytes
2175 bytes
In article <1jo1afINNps3@gap.caltech.edu>, jkubicky@cco.caltech.edu (Joseph J. Kubicky) wrote:
}I want to know how to read the starting sector of a file. I also
}want to know how to create a sequential file of fixed length. I want
}to do all this so I can do more direct I/O to the disk and (hopefully)
}realize some performance gains over normal DOS or C-lib file I/O functions.
I doubt that a 3-5% performance increase will be worth the effort and
possible incompatibilities of bypassing DOS.... You can get around 97%
of the theoretical maximum throughput using only DOS services if you
a) use large reads (at least 32K at a time),
b) do all reads in multiples of the sector size (thus transferring
directly between your buffer and disk, without going through
the DOS disk buffers),
c) ensure enough disk buffers to keep the FAT in memory
and
d) keep the disk defragmented.
Having said that, you can determine the starting cluster of a file from
its directory entry; to get that, you should use the old-style FCB
findfirst/findnext calls (INT 21/AH=11h,12h). Then, get the DOS Disk
Parameter Block for the drive with INT 21/AH=1Fh or INT 21/AH=32h,
and compute the starting sector based on the number of the first data
sector and the number of sectors per cluster.
--
Internet: RALF+@CS.CMU.EDU |The University would disclaim this if it knew...
FIDO: Ralf Brown 1:129/26.1 |
BIT: RALF%CS.CMU.EDU@CARNEGIE|"Fall seven times, stand up eight."
AT&Tnet: (412)268-3053 school| -- Japanese proverb
Technical Details
Message-ID:
<2b601151@ralf>Path:
arc1-ca.pugleaf.net!sparky!uunet!news.univie.ac.at!scsing.switch.ch!ira.uka.de!sol.ctr.columbia.edu!spool.mu.edu!agate!linus!alliant!merk!spdcc!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!ralfShow Full Headers
Complete Article Headers
Newsgroups: alt.msdos.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!news.univie.ac.at!scsing.switch.ch!ira.uka.de!sol.ctr.columbia.edu!spool.mu.edu!agate!linus!alliant!merk!spdcc!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!ralf From: Ralf.Brown@B.GP.CS.CMU.EDU Subject: Re: How do I get starting sector of file? In-Reply-To: <1jo1afINNps3@gap.caltech.edu> Message-ID: <2b601151@ralf> Originator: ralf@B.GP.CS.CMU.EDU Sender: news@cs.cmu.edu (Usenet News System) Nntp-Posting-Host: b.gp.cs.cmu.edu Organization: Carnegie Mellon University School of Computer Science Date: Fri, 22 Jan 1993 14:22:57 GMT Lines: 29