Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

Reading a File

From: readFile.m

 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.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial