📄 pfilesys_8h-source.html
字号:
<!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>pfilesys.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</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> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>pfilesys.h</h1><div class="fragment"><pre>00001 <span class="comment">/*</span>00002 <span class="comment"> ZIG - An extendable, portable game engine focused on networking & scripting</span>00003 <span class="comment"> Project Home: http://zige.sourceforge.net</span>00004 <span class="comment"> Copyright (C) 2002 F醔io Reis Cecin <fcecin AT inf DOT ufrgs DOT br></span>00005 <span class="comment"></span>00006 <span class="comment"> This library is free software; you can redistribute it and/or</span>00007 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>00008 <span class="comment"> License as published by the Free Software Foundation; either</span>00009 <span class="comment"> version 2.1 of the License, or (at your option) any later version.</span>00010 <span class="comment"></span>00011 <span class="comment"> This library is distributed in the hope that it will be useful,</span>00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>00014 <span class="comment"> Lesser General Public License for more details.</span>00015 <span class="comment"></span>00016 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>00017 <span class="comment"> License along with this library; if not, write to the Free Software</span>00018 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </span>00019 <span class="comment">*/</span>00020 <span class="comment">/*</span>00021 <span class="comment"></span>00022 <span class="comment"> PFILESYS : portable file system access functions</span>00023 <span class="comment"> - findfirst/findnext</span>00024 <span class="comment"> - file device/path/name/extension set/get/modify routines</span>00025 <span class="comment"></span>00026 <span class="comment">*/</span>00027 00028 <span class="preprocessor">#ifndef _ZIG_HEADER_PFILESYS_H_</span>00029 <span class="preprocessor"></span><span class="preprocessor">#define _ZIG_HEADER_PFILESYS_H_</span>00030 <span class="preprocessor"></span>00031 <span class="comment">//some internal #define's that control the implementation.</span>00032 <span class="preprocessor">#include "zigdefs.h"</span>00033 00034 <span class="preprocessor">#include <string></span>00035 <span class="comment">//using namespace std;</span>00036 00037 <span class="comment">//includes for implementation</span>00038 <span class="preprocessor">#if defined WINDOWS || WIN32 || WIN64</span>00039 <span class="preprocessor"></span><span class="comment">// WINDOWS includes</span>00040 <span class="preprocessor">#include <windows.h></span>00041 <span class="preprocessor">#include <direct.h></span>00042 <span class="preprocessor">#else</span>00043 <span class="preprocessor"></span><span class="comment">//UNIX standard v3 includes</span>00044 <span class="preprocessor">#include <sys/types.h></span> <span class="comment">//mdir()</span>00045 <span class="preprocessor">#include <sys/stat.h></span> <span class="comment">//mdir()/stat()/fstat()</span>00046 <span class="preprocessor">#include <unistd.h></span> <span class="comment">//rmdir()</span>00047 <span class="preprocessor">#include <dirent.h></span> <span class="comment">//opendir()/closedir()/readdir()</span>00048 <span class="preprocessor">#endif</span>00049 <span class="preprocessor"></span><a name="l00051"></a><a class="code" href="classfile__c.html">00051</a> <span class="keyword">class </span><a class="code" href="classfile__c.html">file_c</a> {00052 <span class="keyword">public</span>:00053 00055 <a class="code" href="classfile__c.html#a0">file_c</a>();00056 00059 <a class="code" href="classfile__c.html#a0">file_c</a>(std::string spec, <span class="keywordtype">bool</span> force_path_only = <span class="keyword">false</span>);00060 00062 <span class="keyword">virtual</span> <a class="code" href="classfile__c.html#a2">~file_c</a>();00063 00065 <a class="code" href="classfile__c.html#a0">file_c</a>(<span class="keyword">const</span> <a class="code" href="classfile__c.html">file_c</a> &f);00066 00068 <a class="code" href="classfile__c.html">file_c</a>& <a class="code" href="classfile__c.html#a4">operator=</a>(<span class="keyword">const</span> <a class="code" href="classfile__c.html">file_c</a> &f);00069 00073 <span class="keywordtype">bool</span> <a class="code" href="classfile__c.html#a5">make_dir</a>(std::string dirname);00074 00076 <span class="keywordtype">bool</span> <a class="code" href="classfile__c.html#a6">remove_dir</a>(std::string dirname);00077 00079 <span class="keywordtype">bool</span> <a class="code" href="classfile__c.html#a7">delete_file</a>(std::string filename = <span class="stringliteral">""</span>);00080 00083 <span class="keywordtype">void</span> <a class="code" href="classfile__c.html#a8">set</a>(std::string spec, <span class="keywordtype">bool</span> force_path_only = <span class="keyword">false</span>);00084 00086 <span class="keywordtype">void</span> <a class="code" href="classfile__c.html#a9">replace_filename</a>(std::string newfilename);00087 00089 <span class="keywordtype">void</span> <a class="code" href="classfile__c.html#a10">replace_path</a>(std::string newpath);00090 00092 <span class="keywordtype">void</span> <a class="code" href="classfile__c.html#a11">cd</a>(std::string dir);00093 <a name="l00095"></a><a class="code" href="classfile__c.html#a12">00095</a> std::string <a class="code" href="classfile__c.html#a12">get_absolute</a>() { <span class="keywordflow">return</span> (path + filename); }00096 <a name="l00098"></a><a class="code" href="classfile__c.html#a13">00098</a> std::string <a class="code" href="classfile__c.html#a13">get_filename</a>() { <span class="keywordflow">return</span> (filename); }00099 <a name="l00101"></a><a class="code" href="classfile__c.html#a14">00101</a> std::string <a class="code" href="classfile__c.html#a14">get_name</a>() { <span class="keywordflow">return</span> name; }00102 <a name="l00104"></a><a class="code" href="classfile__c.html#a15">00104</a> std::string <a class="code" href="classfile__c.html#a15">get_path</a>() { <span class="keywordflow">return</span> path; }00105 <a name="l00107"></a><a class="code" href="classfile__c.html#a16">00107</a> std::string <a class="code" href="classfile__c.html#a16">get_extension</a>() { <span class="keywordflow">return</span> ext; }00108 <a name="l00110"></a><a class="code" href="classfile__c.html#m0">00110</a> <span class="keywordtype">int</span> <a class="code" href="classfile__c.html#m0">size</a>;00111 00112 <span class="keyword">protected</span>:00113 00114 <span class="comment">//file attributes, when file_c is used to return a result from file_finder_c</span>00115 <span class="comment">//int attrib;</span>00116 00117 <span class="comment">//root path, filename(name+'.'+ext), name, extension</span>00118 std::string path, filename, name, ext;00119 };00120 <a name="l00122"></a><a class="code" href="classfile__finder__c.html">00122</a> <span class="keyword">class </span><a class="code" href="classfile__finder__c.html">file_finder_c</a> {00123 <span class="keyword">public</span>:00124 00126 <a class="code" href="classfile__finder__c.html#a0">file_finder_c</a>();00127 00129 <span class="keyword">virtual</span> <a class="code" href="classfile__finder__c.html#a1">~file_finder_c</a>();00130 00134 <span class="keywordtype">void</span> <a class="code" href="classfile__finder__c.html#a2">start_search</a>(std::string spec, <span class="keywordtype">bool</span> files, <span class="keywordtype">bool</span> dirs, <span class="keywordtype">bool</span> weirdos = <span class="keyword">false</span>);00135 00139 <span class="keywordtype">bool</span> <a class="code" href="classfile__finder__c.html#a3">has_next</a>();00140 00143 <a class="code" href="classfile__c.html">file_c</a> <a class="code" href="classfile__finder__c.html#a4">next</a>();00144 00145 <span class="keyword">protected</span>:00146 00147 <span class="comment">//process find result. this can actually do a new search (find-next) if we're</span>00148 <span class="comment">//skipping non-directories (exclude_non_directories == true)</span>00149 <span class="keywordtype">void</span> process_find_result();00150 00151 <span class="comment">//the search dir</span>00152 <a class="code" href="classfile__c.html">file_c</a> search_dir;00153 00154 <span class="comment">// Win32 internal search structure</span>00155 <span class="preprocessor">#if defined WINDOWS || WIN32 || WIN64</span>00156 <span class="preprocessor"></span>00157 HANDLE hFind; <span class="comment">//a handle</span>00158 BOOL bContinue; <span class="comment">//a flag</span>00159 WIN32_FIND_DATA data; <span class="comment">//the search struct</span>00160 00161 <span class="preprocessor">#else</span>00162 <span class="preprocessor"></span>00163 <span class="comment">//UNIX:</span>00164 DIR *dir; <span class="comment">//dir handle, if ==0 (NULL) then it's invalid</span>00165 dirent *dp; <span class="comment">//result of readdir()</span>00166 00167 <span class="preprocessor">#endif</span>00168 <span class="preprocessor"></span>00169 <span class="comment">// if true, exclude non-directories from result</span>00170 <span class="keywordtype">bool</span> exclude_non_directories;00171 00172 <span class="comment">// if true, exclude directories from result</span>00173 <span class="keywordtype">bool</span> exclude_directories;00174 00175 <span class="comment">// if true, excludes weird entries like the "." and ".." directories</span>00176 <span class="keywordtype">bool</span> exclude_weirdos;00177 00178 <span class="comment">// the result fetched by "has_next()"</span>00179 <a class="code" href="classfile__c.html">file_c</a> result;00180 00181 <span class="comment">//bool value indicates wether the result variable is valid.</span>00182 <span class="keywordtype">bool</span> valid_result;00183 00184 <span class="comment">//if it's the first has_next() call after start_search();</span>00185 <span class="keywordtype">bool</span> first_find;00186 };00187 00188 <span class="preprocessor">#endif // _PFILESYS_H_</span>00189 <span class="preprocessor"></span></pre></div><hr><address style="align: right;"><small>Generated on Mon Jan 24 21:14:23 2005 for ZIG 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.18 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -