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: |
HFFileReference is an abstract class. You must instantiate either HFUnprivilegedFileReference or HFPrivilegedFileReference.
All HFFileReferences use non-caching IO (F_NOCACHE is set).
- (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.
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.
buff | The data to write. | |
length | The number of bytes to write. | |
offset | The offset in the file to write to. |
- (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.