PDA

View Full Version : FSWriteFork in MAC OS to write data to a file.



vishal.chauhan
29th June 2007, 09:15
Hi All,

I m using Qt 4.1.5 on my MAC.

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)Siz eToRead,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.

marcel
29th June 2007, 12:18
You should use fsFromMarker.
It means you're writing beginning at the current file position. If you write 20mb, then the current file pos is at the end.

vishal.chauhan
29th June 2007, 13:09
Thanks for reply.

Actually I m writing total data 4 GB but because I can not read buffer of 4 GB from harddisk I m reading 20 MB at a time and then write it to the fork using this function and so..on until total of 4 GB written to the file.

If I use fsAtMark with FSWriteFork then if I get the size of file it is 4 GB but if I open it with Hex Editor then it says No Resource Fork found then what should I do?

marcel
29th June 2007, 14:53
I suggested using fsFromMark, not the other one.

Regards

marcel
29th June 2007, 14:56
Position Mode Constants
Together with an offset, specify a position within a fork.

enum {
fsAtMark = 0,
fsFromStart = 1,
fsFromLEOF = 2,
fsFromMark = 3
};
Constants
fsAtMark
The starting point is the access path’s current position. The offset is ignored.

Available in Mac OS X v10.0 and later.

fsFromStart
The starting point is offset bytes from the start of the fork. The offset must be non-negative.

Available in Mac OS X v10.0 and later.

fsFromLEOF
The starting point is offset bytes from the logical end of the fork. The offset must not be positive.

Available in Mac OS X v10.0 and later.

fsFromMark
The starting point is offset bytes from the access path’s current position. The offset may be positive or negative.

Available in Mac OS X v10.0 and later.

Discussion
These constants are used in the ioPosMode and positionMode fields and parameters of the HFS and HFS Plus file access functions. These functions include those for reading from and writing to files or forks, changing the current position within a file or fork, changing the size of a file or fork, and allocating space to a file or fork.

For the FSReadFork and FSWriteFork calls, you may also add either of the pleaseCacheMask or noCacheMask constants to hint whether the data should be cached or not. See Cache Constants.


There it is.
Regards

vishal.chauhan
2nd July 2007, 06:48
Thanks Marcel.

Actually I think its the error of HexEdit I m using It can not open file larger than 2 GB.

So can u suggest any hexeditor which can open the file larger than 2 GB.