开发者

How does NSFileHandle offsetInFile work?

开发者 https://www.devze.com 2023-03-12 18:50 出处:网络
I am just wanting to know how offsetInFile works? and what is the difference between seekToFileOffSet. and code examples you know of would be helpfull as 开发者_Python百科well :)For standard file desc

I am just wanting to know how offsetInFile works? and what is the difference between seekToFileOffSet. and code examples you know of would be helpfull as 开发者_Python百科well :)


For standard file descriptors, -[NSFileHandle offsetInFile] and -seekToFileOffset: have straightforward POSIX equivalents:

[handle offsetInFile];
    => off_t offset = lseek([handle fileDescriptor], 0, SEEK_CUR);

[handle seekToFileOffset:off];
    => off_t offset = lseek([handle fileDescriptor], off, SEEK_SET);

The difference between them is that the first returns the current offset, while the second changes the offset.

0

精彩评论

暂无评论...
验证码 换一张
取 消