Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
7 NSData *copy = 8 [NSData dataWithContentsOfFile: file]; 9 NSData *mapped = 10 [NSData dataWithContentsOfMappedFile: file]; 11 NSData *read = [[NSFileHandle 12 fileHandleForReadingAtPath: file] 13 readDataToEndOfFile]; |
UNIX systems typically offer two ways of accessing a file: The read() and mmap() system calls. Most other systems—at least those that run on hardware with a memory management unit (MMU)—have equivalents of these. The first copies a stream of bytes from a file into a buffer. The second maps the file’s data into a region of memory.