问题
I'm developing an iphone app, I need to create a certain size file on filesystem and filled with NO data first, then seek to a offset and write data when get data from somewhere else
How can I do it?
回答1:
The lseek BSD function is explicitly capable of that.
man lseek
:
The lseek() function allows the file offset to be set beyond the end of the existing end-of-file of the file. If data is later written at this point, subsequent reads of the data in the gap return bytes of zeros (until data is actually written into the gap).
回答2:
NSMutableData or fseek is probably what you want
来源:https://stackoverflow.com/questions/3967577/create-a-certain-size-file-and-filled-with-no-data-on-ios