[comp.lang.pascal] Read/WriteBlock procedures in TP 5.x

reino@cs.eur.nl (Reino de Boer) (11/14/89)

bundalo@iitmax.IIT.EDU (Predrag S. Bundalo) writes:

>	I've written a file copier using the above procedures.

>	Everything works fine, BUT when I've copied as many files
>	as can fit on the disk, doing a DIR on that disks reports
>	zero (0) bytes free.  Everytime I fill a disk!!  This is
>	incorrect because if you take the time to add up all of
>	the bytes from all of the files, you'll notice that there
>	should be some bytes on the disk free.

>	My question is: why does this happen?  I've checked
>	my code numerous times and there's nothing in it that
>	would cause this sort of problem.  Replies would be
>	MOST appreciated.

Debugging someone else's code works better when being able to look at
the code. 

reino

-- 
Reino R. A. de Boer
Erasmus University Rotterdam ( Informatica )
e-mail: reino@cs.eur.nl

bundalo@iitmax.IIT.EDU (Predrag S. Bundalo) (11/15/89)

In article <1989Nov14.073916.10338@cs.eur.nl> reino@cs.eur.nl (Reino de Boer) writes:
>bundalo@iitmax.IIT.EDU (Predrag S. Bundalo) writes:
>
>>	I've written a file copier using the above procedures.
>
	I've received numerous explanations ( thanks ! ), but not
	a one solution.  Now I know about the way DOS allocates
	space for files, and clusters, and all that, but I don't
	know how to go about overcoming the problem.  Would truncating
	the file to the right size deallocate the extra space DOS
	conveniently allocated for me?  How does DOS's "copy" program
	work?  I mean how does IT overcome the allocation problem?

	I've also noticed that it (dos's copy program) reads in quite
	a bit before writing.  Anyone know how much?  Is this documented
	in the DOS Technical Reference manual?

	Thanks,

	-Pred
-- 
 ______________________________________________________________________________

  Predrag S. Bundalo                  BITNET:  SysPredrag@IITVax.iit.edu.BITNET 
  Illinois Institute of Technology
  Academic Computing Center           UseNet:  bundalo@iitmax.iit.EDU 
  VAX/VMS and Unix Systems Staff 
  Chicago, Illinois

richardw@uunet.uu.net (11/15/89)

|>From: "Predrag S. Bundalo" <uunet!iitmax.iit.edu!bundalo>
|Subject: Re: Read/WriteBlock procedures in TP 5.x
|
|        I've received numerous explanations ( thanks ! ), but not
|        a one solution.  Now I know about the way DOS allocates
|        space for files, and clusters, and all that, but I don't
|        know how to go about overcoming the problem.  Would truncating
|        the file to the right size deallocate the extra space DOS
|        conveniently allocated for me?  How does DOS's "copy" program
|        work?  I mean how does IT overcome the allocation problem?

There isn't any way to get around the problem with a FAT based file system.
The cluster allocation goes on below the layer dealing with file sizes.  The
space allocated is always going to be (filesize div clustersize) + 1 clusters
if filesize mod clustersize <> 0.  COPY doesn't get around the problem, either.

|        I've also noticed that it (dos's copy program) reads in quite
|        a bit before writing.  Anyone know how much?  Is this documented
|        in the DOS Technical Reference manual?

Program specifics are generally not listed in the DOS TechRef.  However, the
most you can read in with a single DOS call is 64K-1 bytes, I would hazard a
guess that that is the size that COPY is using.


-Richard Ward
uunet!microsoft!richardw
microsoft!richardw@uunet.uu.net
The above has no relation to Microsoft corporate policy.