HexFiend
Instance Methods | Properties | List of all members
HFFileReference Class Reference

A reference to an open file. More...

Inheritance diagram for HFFileReference:
HFConcreteFileReference

Instance Methods

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

Properties

BOOL isPrivileged
 
BOOL isFixedLength
 

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

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

Method Documentation

§ initWritableWithPath:error:()

- (instancetype) 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.

§ initWithPath:error:()

- (instancetype) 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.

§ close()

- (void) close

Closes the file.

§ readBytes:length:from:()

- (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
buffThe buffer to read into.
lengthThe number of bytes to read.
offsetThe offset in the file to read.

§ writeBytes:length:to:()

- (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
buffThe data to write.
lengthThe number of bytes to write.
offsetThe offset in the file to write to.
Returns
0 on success, or an errno-style error code on failure

§ length()

- (unsigned long long) length

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

§ setLength:error:()

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

§ isEqual:()

- (BOOL) isEqual: (id)  val

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

Property Documentation

§ isPrivileged

- (BOOL) isPrivileged
readatomicassign

§ isFixedLength

- (BOOL) isFixedLength
readatomicassign

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