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
|
<!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.17 -->
<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="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> </center>
<hr><h1>filemgr.h</h1><div class="fragment"><pre>00001 <span class="comment">/******************************************************************************</span>
00002 <span class="comment"> * filemgr.h - definition of class FileMgr used for pooling file handles</span>
00003 <span class="comment"> *</span>
00004 <span class="comment"> * $Id: filemgr_8h-source.html,v 1.9 2002/10/31 11:30:15 joachim Exp $</span>
00005 <span class="comment"> *</span>
00006 <span class="comment"> * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)</span>
00007 <span class="comment"> * CrossWire Bible Society</span>
00008 <span class="comment"> * P. O. Box 2528</span>
00009 <span class="comment"> * Tempe, AZ 85280-2528</span>
00010 <span class="comment"> *</span>
00011 <span class="comment"> * This program is free software; you can redistribute it and/or modify it</span>
00012 <span class="comment"> * under the terms of the GNU General Public License as published by the</span>
00013 <span class="comment"> * Free Software Foundation version 2.</span>
00014 <span class="comment"> *</span>
00015 <span class="comment"> * This program is distributed in the hope that it will be useful, but</span>
00016 <span class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</span>
00017 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
00018 <span class="comment"> * General Public License for more details.</span>
00019 <span class="comment"> *</span>
00020 <span class="comment"> */</span>
00021
00022 <span class="preprocessor">#ifndef FILEMGR_H</span>
00023 <span class="preprocessor"></span><span class="preprocessor">#define FILEMGR_H</span>
00024 <span class="preprocessor"></span>
00025 <span class="preprocessor">#include <sys/stat.h></span>
00026 <span class="preprocessor">#include <fcntl.h></span>
00027
00028 <span class="preprocessor">#include <defs.h></span>
00029
00030 SWORD_NAMESPACE_START
00031
00032 <span class="keyword">class </span>SWDLLEXPORT FileMgr;
00033
00034 <span class="keyword">class </span>SWDLLEXPORT FileDesc
00035 {
00036
00037 <span class="keyword">friend</span> <span class="keyword">class </span>FileMgr;
00038
00039 <span class="keywordtype">long</span> offset;
00040 <span class="keywordtype">int</span> fd; <span class="comment">// -77 closed;</span>
00041 FileMgr *parent;
00042 FileDesc *next;
00043
00044 <span class="keyword">public</span>:
00045 FileDesc (FileMgr * parent, <span class="keywordtype">char</span> *path, <span class="keywordtype">int</span> mode, <span class="keywordtype">int</span> perms, <span class="keywordtype">bool</span> tryDowngrade);
00046 <span class="keyword">virtual</span> ~FileDesc ();
00047 <span class="keywordtype">int</span> getFd ();
00048 <span class="keywordtype">char</span> *path;
00049 <span class="keywordtype">int</span> mode;
00050 <span class="keywordtype">int</span> perms;
00051 <span class="keywordtype">bool</span> tryDowngrade;
00052 };
00053
00054
00055 <span class="keyword">class </span>FileMgr
00056 {
00057
00058 <span class="keyword">friend</span> <span class="keyword">class </span>FileDesc;
00059
00060 FileDesc *files;
00061 <span class="keywordtype">int</span> sysOpen (FileDesc * file);
00062 <span class="keyword">public</span>:
00063
00064 FileMgr (<span class="keywordtype">int</span> maxFiles = 35);
00065 ~FileMgr ();
00066 FileDesc *open (<span class="keywordtype">char</span> *path, <span class="keywordtype">int</span> mode, <span class="keywordtype">bool</span> tryDowngrade);
00067 FileDesc *open (<span class="keywordtype">char</span> *path, <span class="keywordtype">int</span> mode, <span class="keywordtype">int</span> perms = S_IREAD | S_IWRITE, <span class="keywordtype">bool</span> tryDowngrade = <span class="keyword">false</span>);
00068 <span class="keywordtype">void</span> close (FileDesc *);
00069
00070 <span class="keyword">static</span> <span class="keywordtype">signed</span> <span class="keywordtype">char</span> existsFile (<span class="keyword">const</span> <span class="keywordtype">char</span> *ipath, <span class="keyword">const</span> <span class="keywordtype">char</span> *ifileName = 0);
00071 <span class="keyword">static</span> <span class="keywordtype">signed</span> <span class="keywordtype">char</span> existsDir (<span class="keyword">const</span> <span class="keywordtype">char</span> *ipath, <span class="keyword">const</span> <span class="keywordtype">char</span> *idirName = 0);
00072 <span class="comment">// to truncate a file at its current position</span>
00073 <span class="comment">// leaving byte at current possition intact</span>
00074 <span class="comment">// deleting everything afterward.</span>
00075 <span class="keywordtype">signed</span> <span class="keywordtype">char</span> trunc (FileDesc *);
00076
00077 <span class="keywordtype">int</span> maxFiles;
00078 <span class="keyword">static</span> FileMgr systemFileMgr;
00079 };
00080
00081
00082 SWORD_NAMESPACE_END
00083 <span class="preprocessor">#endif</span>
</pre></div><hr><address style="align: right;"><small>Generated on Thu Oct 31 12:11:28 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.17 </small></address>
</body>
</html>
|