[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] trouble copying file contents




I'm hoping someone can help me with this.  The following code is used to
pack the entire contents of one file into another file, which contains
other data as well.  This works fine for small files, but today I
discovered that it fails with rather large files and I don't see why.  I
have a 180 MB file of which the app copies aprox 45 MB. It then moves on
to the next file and copies that fine and so on.

$catInfo = FSpGetCatInfo($fileToPack);
my $dataSize = $catInfo->ioFlLgLen();
$t = MacPack('long', $dataSize);
push (@temp, $t);
$localSize += 4;
			
$localSize += $dataSize;


my $data = '';my $b = 1;my $remain = 0;
open (FILETOCOPY, "<$fileToPack") || die($!);
if ($dataSize > 262144) {
	$b = 262144;
	$remain = ($dataSize % 262144);
 }

# the following loops 731 times
# which is the proper amount for this file #however only 45 MB of the
# 191627264 bytes is actually copied to the new file even though
# $b(blocksize) is set to 262144

for ($t = 1; $t <= ($dataSize / $b); $t++) {
	read (FILETOCOPY, $data, $b);
	print TARGETFILE $data;
}

read (FILETOCOPY, $data, $remain);
print TARGETFILE $data;

close (FILETOCOPY);



David Ackerman


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org