pfFile(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfFile(3pf)NAMEpfFile - Asynchronous real-time file access operations
FUNCTION SPECIFICATION
#include <Performer/pr/pfFile.h>
static pfFile* pfFile::create(char *path, mode_t mode);
static pfFile* pfFile::open(char *fname, int oflag, ...);
int pfFile::close(void);
int pfFile::read(char *buf, int nbyte);
off_t pfFile::seek(off_t off, int whence);
int pfFile::write(char *buf, int nbyte);
int pfFile::getStatus(int attr);
static pfType * pfFile::getClassType(void);
PARENT CLASS FUNCTIONS
The OpenGL Performer class pfFile is derived from the parent class
pfObject, so each of these member functions of class pfObject are also
directly usable with objects of class pfFile. This is also true for
ancestor classes of class pfObject.
void* pfObject::operator new(size_t);
void* pfObject::operator new(size_t, void *arena);
void* pfObject::operator new(size_t, pfFluxMemory *fmem);
void pfObject::setUserData(void *data);
void pfObject::setUserData(int slot, void *data);
void* pfObject::getUserData(pfObject *obj);
void* pfObject::getUserData(pfObject *obj, int slot);
int pfObject::getNumUserData();
Since the class pfObject is itself derived from the parent class
pfMemory, objects of class pfFile can also be used with these functions
designed for objects of class pfMemory.
void* pfMemory::getData(const void *ptr);
pfType * pfMemory::getType();
int pfMemory::isOfType(pfType *type);
int pfMemory::isExactType(pfType *type);
const char * pfMemory::getTypeName();
int pfMemory::copy(pfMemory *src);
int pfMemory::compare(const pfMemory *mem);
void pfMemory::print(uint which, uint verbose, char *prefix,
FILE *file);
Page 1
pfFile(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfFile(3pf)
int pfMemory::getArena(void *ptr);
void* pfMemory::getArena();
int pfMemory::ref();
int pfMemory::unref();
int pfMemory::unrefDelete();
int pfMemory::unrefGetRef();
int pfMemory::getRef();
int pfMemory::checkDelete();
int pfMemory::isFluxed();
void * pfMemory::getArena();
int pfMemory::getSize();
DESCRIPTION
The pfFile member functions create, open, close, read, write, and seek
operate in an identical fashion and take similar arguments as the
standard UNIX file I/O functions: creat, open, close, read, write, and
lseek. The difference is that they return immediately without blocking
while the physical file-system access operation completes and also that
instead of an integer file descriptor, a pfFile handle is used. OpenGL
Performer supports a maximum of PFRTF_MAXREQ pending file I/O requests.
When called, pfFile::open and pfFile::create create a new process using
the sproc mechanism that manages the file operations asynchronously with
the calling process. If the calling process has super-user privileges,
the new process will assign itself to processor 0, and lower its
priority. The spawned process will exit when either its pfFile is closed
via pfFile::close or when its parent process (that which called the
member function pfFile::open or pfFile::create) exits. The pfFile
structure is created on the process heap.
pfFile::close closes the open file and terminates the I/O process created
by pfFile::open or pfFile::close. close does not free file - use
pfDelete for that purpose.
pfFile::getClassType returns the pfType* for the class pfFile. The
pfType* returned by pfGetFileClassType is the same as the pfType*
returned by invoking the member function getType on any instance of class
pfFile. Because OpenGL Performer allows subclassing of built-in types,
when decisions are made based on the type of an object, it is usually
better to use the member function isOfType to test if an object is of a
type derived from a Performer type rather than to test for strict
equality of the pfType*'s.
pfFile::getStatus returns the status of file corresponding to attr which
may be one of:
PFRTF_STATUS Return 0 if last action complete and no other
actions pending. 1 if action in progress, and
-1 if last action failed.
Page 2
pfFile(3pf) OpenGL Performer 3.2.2 libpr C++ Reference Pages pfFile(3pf)
PFRTF_CMD Return the current (or last) file I/O action,
one of the following:
PFRTF_NOACTION
PFRTF_CREATE
PFRTF_OPEN
PFRTF_READ
PFRTF_WRITE
PFRTF_SEEK
PFRTF_CLOSE
PFRTF_PENDING
PFRTF_BYTES Return the number of bytes from the last read or
write action.
PFRTF_OFFSET Return the offset from the last seek action.
PFRTF_PID Return the process id of the I/O process
associated with file.
NOTES
OpenGL Performer for Linux does not currently support Direct File I/O.
The need for the pfFile facility has been largely superseded by the IRIX
5 asynchronous I/O facility. These capabilities are accessible through
aio_cancel, aio_error, aio_init, aio_read, aio_return, aio_suspend, and
aio_write. Users are encouraged to use the aio functions for performing
asynchronous file operations in programs now in development.
The calling process should always call pfFile::close to close a file
before exiting. If the calling program exits without doing so, the file
will not be closed. Such files can be challenging to remove from the
file system.
SEE ALSO
access, aio_cancel, aio_error, aio_init, aio_read, aio_return,
aio_suspend, aio_write, close, creat, fcntl, lseek, open, read, write
Page 3