1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
<HTML><HEAD><TITLE>LockedFile Class</TITLE></HEAD>
<BODY bgcolor="#ffffff">
<H1>LockedFile Class Reference</H1>
<p>
[<A HREF="index.html">APE Index</A>] [<A HREF="hier.html">APE Hierarchy</A>]
[<A HREF="header-list.html">Headers</A>]
</p>
<HR>
<P>shared file access between different processes. <a href="#short">More...</a></P>
<P>
<code>
#include <<a href="file-h.html">file.h</a>>
</code>
</P>
<P>
Inherits: <a href="File.html">File</a>
<P>
<H2>Public Members</H2>
<UL>
<LI> <b><a href="#ref0">LockedFile</a></b> (const char *fname, int access)
</LI>
<LI> <b><a href="#ref1">LockedFile</a></b> (const LockedFile &f)
</LI>
<LI> <b><a href="#ref2">~LockedFile</a></b> ()
</LI>
<LI>int <b><a href="#ref3">Append</a></b> (void *buf, size_t len)
</LI>
<LI>int <b><a href="#ref4">Request</a></b> (pos_t pos, void *buf, size_t len)
</LI>
<LI>int <b><a href="#ref5">Update</a></b> (pos_t pos, void *buf, size_t len)
</LI>
<LI>int <b><a href="#ref6">Clear</a></b> (pos_t pos, size_t len)
</LI>
</UL>
<HR>
<H2><a name="short">Detailed Description</a></H2>
<P>
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.
</P><HR>
<H3><b> <a name="ref0"></a><a name="LockedFile">LockedFile</a>(const char *fname, int access) </b><code>[public]</code></H3>
<p>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.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
access</td><td align="left" valign="top">
access mode (read, write, or rdwr) to use.</td></tr>
<tr><td align="left" valign="top">
fname</td><td align="left" valign="top">
path name of disk file to open.</td></tr>
</table>
</dl>
<dl><dt><b>See Also</b>:<dd><a href="File.html#File">File::File</a></dl>
<H3><b> <a name="ref1"></a><a name="LockedFile">LockedFile</a>(const <a href="LockedFile.html">LockedFile</a> &f) </b><code>[public]</code></H3>
<p>Duplicate an existing locked file's descriptor, but do not
duplicate any outstanding locks.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
f</td><td align="left" valign="top">
reference to another LockedFile.</td></tr>
</table>
</dl>
<H3><b> <a name="ref2"></a><a name="~LockedFile">~LockedFile</a>() </b><code>[public]</code></H3>
<p>Release the locked file and any locks held by this object.
</p>
<H3><b>int <a name="ref3"></a><a name="Append">Append</a>(void *buf, size_t len) </b><code>[public]</code></H3>
<p>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.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
buf</td><td align="left" valign="top">
pointer to data to write to the file.</td></tr>
<tr><td align="left" valign="top">
len</td><td align="left" valign="top">
number of bytes to write.</td></tr>
</table>
</dl>
<dl><dt><b>Returns</b>:<dd>
number of bytes written on success, -1 on error.</dl>
<H3><b>int <a name="ref4"></a><a name="Request">Request</a>(pos_t pos, void *buf, size_t len) </b><code>[public]</code></H3>
<p>Request a lock for a portion of the datafile and then read
the exclusivily locked portion of the file into memory.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
pos</td><td align="left" valign="top">
offset to portion of file to read.</td></tr>
<tr><td align="left" valign="top">
buf</td><td align="left" valign="top">
pointer to memory to read data into.</td></tr>
<tr><td align="left" valign="top">
len</td><td align="left" valign="top">
number of bytes to read.</td></tr>
</table>
</dl>
<dl><dt><b>Returns</b>:<dd>
number of bytes read on success, -1 on error.</dl>
<H3><b>int <a name="ref5"></a><a name="Update">Update</a>(pos_t pos, void *buf, size_t len) </b><code>[public]</code></H3>
<p>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.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
pos</td><td align="left" valign="top">
offset to portion of file to write.</td></tr>
<tr><td align="left" valign="top">
buf</td><td align="left" valign="top">
pointer to memory to write data from.</td></tr>
<tr><td align="left" valign="top">
len</td><td align="left" valign="top">
number of bytes to write.</td></tr>
</table>
</dl>
<dl><dt><b>Returns</b>:<dd>
number of bytes written on success, -1 on error.</dl>
<H3><b>int <a name="ref6"></a><a name="Clear">Clear</a>(pos_t pos, size_t len) </b><code>[public]</code></H3>
<p>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.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
pos</td><td align="left" valign="top">
offset to portion of file that was locked.</td></tr>
<tr><td align="left" valign="top">
len</td><td align="left" valign="top">
number of bytes originally requested.</td></tr>
</table>
</dl>
<dl><dt><b>Returns</b>:<dd>
0 on success, -1 on error.</dl>
<HR>
<TABLE WIDTH="100%"><TR><TD ALIGN="left" VALIGN="top">
<UL><LI><I>Author</I>: David Sugar <dyfet@ostel.com> </LI>
<LI>Documentation generated by dyfet@home.sys on Thu Dec 16 09:54:26 EST 1999
</LI>
</UL></TD><TD ALIGN="RIGHT" VALIGN="TOP">
<b>K</b><i>doc</i>
</TD>
</TR></TABLE></BODY></HTML>
|