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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>filemgr.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>filemgr.h</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> * filemgr.h - definition of class FileMgr used for pooling file handles</font>
00003 <font class="comment"> *</font>
00004 <font class="comment"> * $Id: filemgr_8h-source.html,v 1.7 2002/06/20 20:23:08 mgruner Exp $</font>
00005 <font class="comment"> *</font>
00006 <font class="comment"> * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)</font>
00007 <font class="comment"> * CrossWire Bible Society</font>
00008 <font class="comment"> * P. O. Box 2528</font>
00009 <font class="comment"> * Tempe, AZ 85280-2528</font>
00010 <font class="comment"> *</font>
00011 <font class="comment"> * This program is free software; you can redistribute it and/or modify it</font>
00012 <font class="comment"> * under the terms of the GNU General Public License as published by the</font>
00013 <font class="comment"> * Free Software Foundation version 2.</font>
00014 <font class="comment"> *</font>
00015 <font class="comment"> * This program is distributed in the hope that it will be useful, but</font>
00016 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00017 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00018 <font class="comment"> * General Public License for more details.</font>
00019 <font class="comment"> *</font>
00020 <font class="comment"> */</font>
00021
00022 <font class="preprocessor">#ifndef FILEMGR_H</font>
00023 <font class="preprocessor"></font><font class="preprocessor">#define FILEMGR_H</font>
00024 <font class="preprocessor"></font>
00025 <font class="preprocessor">#include <sys/stat.h></font>
00026 <font class="preprocessor">#include <fcntl.h></font>
00027
00028 <font class="preprocessor">#include <defs.h></font>
00029
00030 <font class="keyword">class </font>SWDLLEXPORT FileMgr;
00031
00032 <font class="keyword">class </font>SWDLLEXPORT FileDesc
00033 {
00034
00035 <font class="keyword">friend</font> <font class="keyword">class </font>FileMgr;
00036
00037 <font class="keywordtype">long</font> offset;
00038 <font class="keywordtype">int</font> fd; <font class="comment">// -77 closed;</font>
00039 FileMgr *parent;
00040 FileDesc *next;
00041
00042 <font class="keyword">public</font>:
00043 FileDesc (FileMgr * parent, <font class="keywordtype">char</font> *path, <font class="keywordtype">int</font> mode, <font class="keywordtype">int</font> perms, <font class="keywordtype">bool</font> tryDowngrade);
00044 <font class="keyword">virtual</font> ~FileDesc ();
00045 <font class="keywordtype">int</font> getFd ();
00046 <font class="keywordtype">char</font> *path;
00047 <font class="keywordtype">int</font> mode;
00048 <font class="keywordtype">int</font> perms;
00049 <font class="keywordtype">bool</font> tryDowngrade;
00050 };
00051
00052
00053 <font class="keyword">class </font>FileMgr
00054 {
00055
00056 <font class="keyword">friend</font> <font class="keyword">class </font>FileDesc;
00057
00058 FileDesc *files;
00059 <font class="keywordtype">int</font> sysOpen (FileDesc * file);
00060 <font class="keyword">public</font>:
00061
00062 FileMgr (<font class="keywordtype">int</font> maxFiles = 35);
00063 ~FileMgr ();
00064 FileDesc *open (<font class="keywordtype">char</font> *path, <font class="keywordtype">int</font> mode, <font class="keywordtype">bool</font> tryDowngrade);
00065 FileDesc *open (<font class="keywordtype">char</font> *path, <font class="keywordtype">int</font> mode, <font class="keywordtype">int</font> perms = S_IREAD | S_IWRITE, <font class="keywordtype">bool</font> tryDowngrade = <font class="keyword">false</font>);
00066 <font class="keywordtype">void</font> close (FileDesc *);
00067
00068 <font class="keyword">static</font> <font class="keywordtype">signed</font> <font class="keywordtype">char</font> existsFile (<font class="keyword">const</font> <font class="keywordtype">char</font> *ipath, <font class="keyword">const</font> <font class="keywordtype">char</font> *ifileName = 0);
00069 <font class="keyword">static</font> <font class="keywordtype">signed</font> <font class="keywordtype">char</font> existsDir (<font class="keyword">const</font> <font class="keywordtype">char</font> *ipath, <font class="keyword">const</font> <font class="keywordtype">char</font> *idirName = 0);
00070 <font class="comment">// to truncate a file at its current position</font>
00071 <font class="comment">// leaving byte at current possition intact</font>
00072 <font class="comment">// deleting everything afterward.</font>
00073 <font class="keywordtype">signed</font> <font class="keywordtype">char</font> trunc (FileDesc *);
00074
00075 <font class="keywordtype">int</font> maxFiles;
00076 <font class="keyword">static</font> FileMgr systemFileMgr;
00077 };
00078
00079
00080
00081
00082 <font class="preprocessor">#endif</font>
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:12:59 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>
|