HFFileReference Class Reference

A reference to an open file. More...

Inheritance diagram for HFFileReference:

HFPrivilegedFileReference HFUnprivilegedFileReference

List of all members.

Public Member Functions

(id) - initWritableWithPath:error:
(id) - initWithPath:error:
(void) - close
(void) - readBytes:length:from:
(int) - writeBytes:length:to:
(unsigned long long) - length
(BOOL) - setLength:error:
(BOOL) - isEqual:


Detailed Description

HFFileReference encapsulates a reference to an open file. Multiple instances of HFFileByteSlice may share an HFFileReference, so that the file only needs to be opened once.

HFFileReference is an abstract class. You must instantiate either HFUnprivilegedFileReference or HFPrivilegedFileReference.

All HFFileReferences use non-caching IO (F_NOCACHE is set).


Member Function Documentation

- (id) initWritableWithPath: (NSString *)  path
error: (NSError **)  error 

Open a file for reading and writing at the given path. The permissions mode of any newly created file is 0744. Returns nil if the file could not be opened, in which case the error parameter (if not nil) will be set.

- (id) initWithPath: (NSString *)  path
error: (NSError **)  error 

Open a file for reading only at the given path. Returns nil if the file could not be opened, in which case the error parameter (if not nil) will be set.

- (void) close  

Closes the file.

- (void) readBytes: (unsigned char *)  buff
length: (NSUInteger)  length
from: (unsigned long long)  offset 

Reads from the file into a local memory buffer. The sum of the length and the offset must not exceed the length of the file.

Parameters:
buff The buffer to read into.
length The number of bytes to read.
offset The offset in the file to read.

- (int) writeBytes: (const unsigned char *)  buff
length: (NSUInteger)  length
to: (unsigned long long)  offset 

Writes data to the file, which must have been opened writable.

Parameters:
buff The data to write.
length The number of bytes to write.
offset The offset in the file to write to.
Returns:
0 on success, or an errno-style error code on failure

- (unsigned long long) length  

Returns the length of the file, as a 64 bit unsigned long long.

- (BOOL) setLength: (unsigned long long)  length
error: (NSError **)  error 

Changes the length of the file via ftruncate. Returns YES on success, NO on failure; on failure it optionally returns an NSError by reference.

- (BOOL) isEqual: (id)  val  

isEqual: returns whether two file references both reference the same file, as in have the same inode and device.


The documentation for this class was generated from the following file:

Generated on Thu Dec 8 10:06:35 2011 for HexFiend by  doxygen 1.5.9