File: File.html

package info (click to toggle)
libape 1.0.0-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,572 kB
  • ctags: 1,343
  • sloc: sh: 7,342; cpp: 3,418; makefile: 117
file content (214 lines) | stat: -rw-r--r-- 7,586 bytes parent folder | download
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<HTML><HEAD><TITLE>File Class</TITLE></HEAD>
<BODY bgcolor="#ffffff">

<H1>File 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>Portable disk file access.   <a href="#short">More...</a></P>
<P>
<code>
	#include &lt;<a href="file-h.html">file.h</a>&gt;
</code>

</P>

<H2>Public Members</H2>
<UL>
<LI> <b><a href="#ref0">File</a></b> (const char *fname, int access) 
</LI>
<LI> <b><a href="#ref1">File</a></b> (const char *fname, int access, int perm) 
</LI>
<LI> <b><a href="#ref2">File</a></b> (const File &amp;f) 
</LI>
<LI> <b><a href="#ref3">File</a></b> (int fd) 
</LI>
<LI>virtual <b><a href="#ref4">~File</a></b> () 
</LI>
<LI>int <b><a href="#ref5">Read</a></b> (void *buf, size_t len) 
</LI>
<LI>int <b><a href="#ref6">Write</a></b> (void *buf, size_t len) 
</LI>
<LI>int <b><a href="#ref7">Write</a></b> (char *buf) 
</LI>
<LI>pos_t <b><a href="#ref8">Position</a></b> (pos_t pos) 
</LI>
<LI>pos_t <b><a href="#ref9">Append</a></b> (void) 
</LI>
<LI>File&amp; <b><a name="ref10">operator=</a></b> (const File &amp;f) 
</LI>
<LI>friend int <b><a name="ref11">read</a></b> (File &amp;f, void *buf, size_t len) 
</LI>
<LI>friend int <b><a name="ref12">write</a></b> (File &amp;f, void *buf, size_t len) 
</LI>
<LI>friend int <b><a name="ref13">write</a></b> (File &amp;f, char *buf) 
</LI>
<LI>friend pos_t <b><a name="ref14">append</a></b> (File &amp;f) 
</LI>
<LI>friend pos_t <b><a name="ref15">position</a></b> (File &amp;f, pos_t pos) 
</LI>
</UL>

<H2>Protected Members</H2>
<UL>
<LI>	int <b><a name="ref16">_fd</a></b>
</LI>
</UL>
<HR>
<H2><a name="short">Detailed Description</a></H2>
<P>

 The purpose of this class is to define a low level file access
 class that is portable between Win32 and Posix systems.  In fact
 win32 lacks certain critical concepts related to multi-user file
 ownership and yet introduces some very odd concepts of cache control
 and configuration based on assumed application usage.  These combine
 to make this and the other related portable file access classes a 
 little odd, and certainly in need of further work.
 

</P><HR>
<H3><b> <a name="ref0"></a><a name="File">File</a>(const char *fname, int access)  </b><code>[public]</code></H3>
<p>Open an existing file of the given name with the given access
mode.  Valid access modes include FILE_OPEN_READONLY, FILE_OPEN_WRITEONLY,
FILE_OPEN_APPEND, FILE_OPEN_READWRITE, FILE_OPEN_SYNC, and FILE_OPEN_TRUNCATE.
A File "exception" is thrown if the file open fails.
</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">
mode for access to the given file.</td></tr>
<tr><td align="left" valign="top">
fname</td><td align="left" valign="top">
name of file path to open.</td></tr>
</table>
</dl>
<H3><b> <a name="ref1"></a><a name="File">File</a>(const char *fname, int access, int perm)  </b><code>[public]</code></H3>
<p>Create a new file and access for use by the File class.  Valid modes
include FILE_OPEN_WRITEONLY, FILE_OPEN_APPEND, FILE_OPEN_SYNC,
and FILE_OPEN_READWRITE.  The most generic permissions for your
newly created file include FILE_PERM_PRIVATE, FILE_PERM_GROUP, and
FILE_PERM_PUBIC.  On Posix systems, the standard chmod() permission
values may be directly used, as well as the stat.h defines.  As
with all APE classes, an exception is thrown if the create fails.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
fname</td><td align="left" valign="top">
name of file path to create and open.</td></tr>
</table>
</dl>
<H3><b> <a name="ref2"></a><a name="File">File</a>(const <a href="File.html">File</a> &amp;f)  </b><code>[public]</code></H3>
<p>Open a copy of an existing "File" through a duplicate object.  This 
essentially uses the Posix dup() call to duplicate the file
descriptor involved.
</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">
an existing File class to duplicate from.</td></tr>
</table>
</dl>
<H3><b> <a name="ref3"></a><a name="File">File</a>(int fd)  </b><code>[public]</code></H3>
<p>Create a File "class" to reference an existing and already open
file descriptor.  This is kind of like "fdopen" in purpose, and
simply allows any existing file descriptor to be manipulated
by the File methods.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
fd</td><td align="left" valign="top">
an existing and already open file descriptor.</td></tr>
</table>
</dl>
<H3><b> <a name="ref4"></a><a name="~File">~File</a>()  </b><code>[public virtual]</code></H3>
<p>The destructor normally closes the File descriptor and should
also release any allocated resources in a derived class.
</p>
<H3><b>int <a name="ref5"></a><a name="Read">Read</a>(void *buf, size_t len)  </b><code>[public]</code></H3>
<p>Read an arbitrary number of bytes from the File object.
</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 hold read data.</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 with success, or -1 on error.</dl>
<H3><b>int <a name="ref6"></a><a name="Write">Write</a>(void *buf, size_t len)  </b><code>[public]</code></H3>
<p>Write an arbitrary number of bytes to the File object.
</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 that will be written.</td></tr>
<tr><td align="left" valign="top">
len</td><td align="left" valign="top">
number of butes 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="ref7"></a><a name="Write">Write</a>(char *buf)  </b><code>[public]</code></H3>
<p>A quick and easy way to write a null terminated C string to
a file.
</p><p>
</p>
<dl><dt><b>Parameters</b>:<dd>
<table width="100%" border="0">
<tr><td align="left" valign="top">
pointer</td><td align="left" valign="top">
to null terminated string to write to the file.</td></tr>
</table>
</dl>
<dl><dt><b>Returns</b>:<dd>
number of bytes written on success, -1 on error.</dl>
<H3><b>pos_t <a name="ref8"></a><a name="Position">Position</a>(pos_t pos)  </b><code>[public]</code></H3>
<p>Set the current file position.  This is an absolute position
from the start of the file.
</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">
new file position to set file to.</td></tr>
</table>
</dl>
<dl><dt><b>Returns</b>:<dd>
current file position after operation.</dl>
<H3><b>pos_t <a name="ref9"></a><a name="Append">Append</a>(void)  </b><code>[public]</code></H3>
<p>Set the current file position to the end of the file.
</p><p>
</p>
<dl><dt><b>Returns</b>:<dd>
file position (length) of the end of the file.</dl>
<HR>
<TABLE WIDTH="100%"><TR><TD ALIGN="left" VALIGN="top">

<UL><LI><I>Author</I>: David Sugar &lt;dyfet@ostel.com&gt; </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>