LockedFile Class Reference

[APE Index] [APE Hierarchy] [Headers]


shared file access between different processes. More...

#include <file.h>

Inherits: File

Public Members


Detailed Description

Locked files are presumed to be shared between different processes. File locks are used to protect file access and specifically defined operations which must occur exclusivily by a single process, such as for logical record locks in a database. Record locking is assumed to be a blocking operation.


LockedFile(const char *fname, int access) [public]

Open an existing and named data file that may be shared by multiple processes. Throw an exception if the file doesn't exist or cannot be accessed.

Parameters:
access access mode (read, write, or rdwr) to use.
fname path name of disk file to open.
See Also:
File::File

LockedFile(const LockedFile &f) [public]

Duplicate an existing locked file's descriptor, but do not duplicate any outstanding locks.

Parameters:
f reference to another LockedFile.

~LockedFile() [public]

Release the locked file and any locks held by this object.

int Append(void *buf, size_t len) [public]

Recieve a lock from the end of the current file to inf and when successful write the specified data to the end. Upon completion, release the file lock.

Parameters:
buf pointer to data to write to the file.
len number of bytes to write.
Returns:
number of bytes written on success, -1 on error.

int Request(pos_t pos, void *buf, size_t len) [public]

Request a lock for a portion of the datafile and then read the exclusivily locked portion of the file into memory.

Parameters:
pos offset to portion of file to read.
buf pointer to memory to read data into.
len number of bytes to read.
Returns:
number of bytes read on success, -1 on error.

int Update(pos_t pos, void *buf, size_t len) [public]

Copy a presumably modified memory block back to a locked portion of a file as retrieved from a previous request, and then clear the file lock so that another process may now access that region. No check is made to assure the Update actually matches a previous Request.

Parameters:
pos offset to portion of file to write.
buf pointer to memory to write data from.
len number of bytes to write.
Returns:
number of bytes written on success, -1 on error.

int Clear(pos_t pos, size_t len) [public]

Release a lock held from a request without modifying any data in the file so that another process may now access the locked region. No check is made to assure the Clear actually matches an existing Request.

Parameters:
pos offset to portion of file that was locked.
len number of bytes originally requested.
Returns:
0 on success, -1 on error.

  • Author: David Sugar <dyfet@ostel.com>
  • Documentation generated by dyfet@home.sys on Thu Dec 16 09:54:26 EST 1999
Kdoc