0
#include "abstractfile.h"
0
-#define
BUFSIZE 1024*10240
+#define
HFS_BUFSIZE 327680
void writeToFile(HFSPlusCatalogFile* file, AbstractFile* output, Volume* volume) {
0
- unsigned char buffer[
BUFSIZE];
0
+ unsigned char buffer[
HFS_BUFSIZE];
0
@@ -26,15 +26,15 @@ void writeToFile(HFSPlusCatalogFile* file, AbstractFile* output, Volume* volume)
0
bytesLeft = file->dataFork.logicalSize;
0
- if(bytesLeft > BUFSIZE) {
0
- if(!READ(io, curPosition, BUFSIZE, buffer)) {
0
+ if(bytesLeft > HFS_BUFSIZE) {
0
+ if(!READ(io, curPosition, HFS_BUFSIZE, buffer)) {
0
panic("error reading");
0
- if(output->write(output, buffer,
BUFSIZE) != BUFSIZE) {
0
+ if(output->write(output, buffer,
HFS_BUFSIZE) != HFS_BUFSIZE) {
0
panic("error writing");
0
- curPosition += BUFSIZE;
0
+ curPosition += HFS_BUFSIZE;
0
+ bytesLeft -= HFS_BUFSIZE;
0
if(!READ(io, curPosition, bytesLeft, buffer)) {
0
panic("error reading");
0
@@ -50,7 +50,7 @@ void writeToFile(HFSPlusCatalogFile* file, AbstractFile* output, Volume* volume)
0
void writeToHFSFile(HFSPlusCatalogFile* file, AbstractFile* input, Volume* volume) {
0
- unsigned char buffer[
BUFSIZE];
0
+ unsigned char buffer[
HFS_BUFSIZE];
0
@@ -59,7 +59,6 @@ void writeToHFSFile(HFSPlusCatalogFile* file, AbstractFile* input, Volume* volum
0
io = openRawFile(file->fileID, &file->dataFork, (HFSPlusCatalogRecord*)file, volume);
0
- panic("error opening file");
0
@@ -68,21 +67,21 @@ void writeToHFSFile(HFSPlusCatalogFile* file, AbstractFile* input, Volume* volum
0
allocate((RawFile*)io->data, bytesLeft);
0
- if(bytesLeft > BUFSIZE) {
0
- if(input->read(input, buffer, BUFSIZE) != BUFSIZE) {
0
- panic("error reading");
0
+ if(bytesLeft > HFS_BUFSIZE) {
0
+ if(input->read(input, buffer, HFS_BUFSIZE) != HFS_BUFSIZE) {
0
- if(!WRITE(io, curPosition, BUFSIZE, buffer)) {
0
- panic("error writing");
0
+ if(!WRITE(io, curPosition, HFS_BUFSIZE, buffer)) {
0
- curPosition += BUFSIZE;
0
+ curPosition += HFS_BUFSIZE;
0
+ bytesLeft -= HFS_BUFSIZE;
0
if(input->read(input, buffer, (size_t)bytesLeft) != (size_t)bytesLeft) {
0
-
panic("error reading");
0
if(!WRITE(io, curPosition, (size_t)bytesLeft, buffer)) {
0
-
panic("error reading");
0
curPosition += bytesLeft;
0
bytesLeft -= bytesLeft;
Comments
No one has commented yet.