# writing data to file using FSWriteFork?



## vishal.chauhan (Jun 29, 2007)

Hi All,


I am reading raw data from disk and writing them to buffer and then trying to write that Buffer in file through FSWriteFork which is in FileSystem API of the Apple.
I m using the following line

error 
	
	



```
= FSWriteFork(refnum,fsFromStart,NULL,(ByteCount)SizeToRead,pBuff, NULL);
```

But if I use fsFromStart it always write the buffer at the starting that is suppose I want to write 4 Gb data from the disk to file and I read a 20 MB buffer and write it in a loop to the buffer the final size of the file will only be 20 MB instead of 4 GB.

there are other value as well
fsAtMark 
fsFromStart 
fsFromLEOF 
 fsFromMark 

But I donot know which value should I use to write whole size and then be able to open the file.


If anybody knows then plz help me.

Thanks.


----------



## szymczyk (Jun 29, 2007)

If you're going to be writing 4 GB of data by calling FSWriteFork() every 20 MB, use fsFromLEOF as the position mode. Using fsFromLEOF tells the File Manager to append the data you're writing to the end of the file, which is what you need to write all the data to the file.


----------



## vishal.chauhan (Jul 2, 2007)

Thanks for reply.

Actually I think its the problem of Hex editor i m using it can not open file larger than 2 Gb.

So can u plz suggest any Hex editor available for Mac Tiger.


----------



## szymczyk (Jul 2, 2007)

Have you tried HexFiend? It says it can handle files as large as 118 GB.


----------

