简体   繁体   中英

How does NSFileHandle offsetInFile work?

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM