aboutsummaryrefslogtreecommitdiff
path: root/docs/doxygen/nel/new__path_8cpp-source.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/doxygen/nel/new__path_8cpp-source.html')
-rw-r--r--docs/doxygen/nel/new__path_8cpp-source.html858
1 files changed, 858 insertions, 0 deletions
diff --git a/docs/doxygen/nel/new__path_8cpp-source.html b/docs/doxygen/nel/new__path_8cpp-source.html
new file mode 100644
index 00000000..c2f72a03
--- /dev/null
+++ b/docs/doxygen/nel/new__path_8cpp-source.html
@@ -0,0 +1,858 @@
+<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
+<HTML>
+<HEAD>
+ <TITLE>nevrax.org : docs</TITLE>
+ <LINK REL=stylesheet TYPE="text/css" HREF="http://www.nevrax.org/inc/css/nevrax.css">
+ <link href="doxygen.css" rel="stylesheet" type="text/css">
+</HEAD>
+<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
+
+<!-- uplinks -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.org><b>Home</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ <TD><IMG width=6 height=14 SRC="http://www.nevrax.org/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle>&nbsp;<A CLASS=uplinks HREF=http://www.nevrax.com><b>nevrax.com</B></FONT></A>&nbsp;&nbsp;&nbsp;</TD>
+ </TR>
+</TABLE>
+
+<!-- banner Nevrax -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
+ <TR><TD BGCOLOR="#000000" BACKGROUND="http://www.nevrax.org/inc/img/black_banner.jpg"><A HREF="http://www.nevrax.org"><IMG SRC="http://www.nevrax.org/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
+</TABLE>
+
+<!-- main table -->
+<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
+ <TR>
+ <TD WIDTH=16><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
+ <TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+ <!------ Begin Box ------>
+ <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
+ <FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
+ <TABLE cellspacing=0 cellpadding=1 border=0>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/news/" TITLE="News">News</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/docs/" TITLE="Documentation">Documentation</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/cvs/" TITLE="CVS Web">CVS</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
+ <tr><td ALIGN=middle><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=http://www.nevrax.org/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="http://www.nevrax.org/GPL.php3" TITLE="License">License</a></td></tr>
+ </TABLE>
+ </TD></TR></TABLE></TD></TR></TABLE>
+ <!------ End Box ------>
+
+ </TD>
+ <TD WIDTH=15><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
+ <TD ALIGN=left valign=top><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
+
+<!-- title -->
+<TABLE background="http://www.nevrax.org/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
+<A HREF="http://www.nevrax.org/docs/"><img src="http://www.nevrax.org/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
+</td><td><IMG SRC="http://www.nevrax.org/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
+</td></tr></table>
+&nbsp;
+
+<!-- block -->
+<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="http://www.nevrax.org/inc/img/reddots.gif"></TD>
+ <TD><B>Documentation</B></TD>
+ <TD ALIGN=RIGHT>&nbsp;</td>
+</tr></table>
+<!-- Generated by Doxygen 1.2.14 -->
+<center>
+<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="namespacemembers.html">Namespace Members</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; <a class="qindex" href="globals.html">File Members</a> &nbsp; <a class="qindex" href="pages.html">Related Pages</a> &nbsp; <a class="qindexRef" doxygen="_cgi:http://www.nevrax.org/cgi-bin/nel-search.cgi" href="http://www.nevrax.org/cgi-bin/nel-search.cgi">Search</a> &nbsp; </center>
+<hr><h1>new_path.cpp</h1><a href="new__path_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="preprocessor">#if 0</font>
+00002 <font class="preprocessor"></font>
+00008 <font class="comment">/* Copyright, 2000, 2001 Nevrax Ltd.</font>
+00009 <font class="comment"> *</font>
+00010 <font class="comment"> * This file is part of NEVRAX NEL.</font>
+00011 <font class="comment"> * NEVRAX NEL is free software; you can redistribute it and/or modify</font>
+00012 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
+00013 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
+00014 <font class="comment"> * any later version.</font>
+00015 <font class="comment"></font>
+00016 <font class="comment"> * NEVRAX NEL is distributed in the hope that it will be useful, but</font>
+00017 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
+00018 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
+00019 <font class="comment"> * General Public License for more details.</font>
+00020 <font class="comment"></font>
+00021 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
+00022 <font class="comment"> * along with NEVRAX NEL; see the file COPYING. If not, write to the</font>
+00023 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
+00024 <font class="comment"> * MA 02111-1307, USA.</font>
+00025 <font class="comment"> */</font>
+00026
+00027 <font class="preprocessor">#include &lt;fstream&gt;</font>
+00028
+00029 <font class="preprocessor">#include "<a class="code" href="debug_8h.html">nel/misc/debug.h</a>"</font>
+00030
+00031 <font class="preprocessor">#include "<a class="code" href="new__path_8h.html">nel/misc/new_path.h</a>"</font>
+00032
+00033 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00034 <font class="preprocessor"></font><font class="preprocessor"># include &lt;windows.h&gt;</font>
+00035 <font class="preprocessor">#else</font>
+00036 <font class="preprocessor"></font><font class="preprocessor"># include &lt;sys/types.h&gt;</font>
+00037 <font class="preprocessor"># include &lt;sys/stat.h&gt;</font>
+00038 <font class="preprocessor"># include &lt;dirent.h&gt;</font>
+00039 <font class="preprocessor"># include &lt;<a class="code" href="unistd_8h.html">unistd.h</a>&gt;</font>
+00040 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
+00041 <font class="preprocessor"></font>
+00042 <font class="keyword">using</font> <font class="keyword">namespace </font>std;
+00043
+00044 <font class="keyword">namespace </font>NLMISC {
+00045
+00046 <font class="comment">//</font>
+00047 <font class="comment">// Macros</font>
+00048 <font class="comment">//</font>
+00049
+00050 <font class="comment">// Use this define if you want to display info about the CPath.</font>
+00051 <font class="preprocessor">#define NL_DEBUG_PATH</font>
+00052 <font class="preprocessor"></font>
+00053 <font class="preprocessor">#ifdef NL_DEBUG_PATH</font>
+00054 <font class="preprocessor"></font><font class="preprocessor">#define NL_DISPLAY_PATH nlinfo</font>
+00055 <font class="preprocessor"></font><font class="preprocessor">#else </font>
+00056 <font class="preprocessor"></font><font class="preprocessor">#define NL_DISPLAY_PATH if(false)</font>
+00057 <font class="preprocessor"></font><font class="preprocessor">#endif</font>
+00058 <font class="preprocessor"></font>
+00059
+00060 <font class="comment">//</font>
+00061 <font class="comment">// Variables</font>
+00062 <font class="comment">//</font>
+00063
+00064 CNewPath *CNewPath::_Instance = NULL;
+00065
+00066
+00067 <font class="comment">//</font>
+00068 <font class="comment">// Functions</font>
+00069 <font class="comment">//</font>
+00070
+00071 CNewPath *CNewPath::getInstance ()
+00072 {
+00073 <font class="keywordflow">if</font> (_Instance == NULL)
+00074 {
+00075 _Instance = <font class="keyword">new</font> CNewPath;
+00076 }
+00077 <font class="keywordflow">return</font> _Instance;
+00078 }
+00079
+00080 <font class="keywordtype">void</font> CNewPath::clearMap ()
+00081 {
+00082 CNewPath *inst = CNewPath::getInstance();
+00083 inst-&gt;_Files.clear ();
+00084 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::clearMap(): map directory cleared"</font>);
+00085 }
+00086
+00087 <a class="code" href="types__nl_8h.html#a13">sint</a> CNewPath::findExtension (<font class="keyword">const</font> string &amp;ext1, <font class="keyword">const</font> string &amp;ext2)
+00088 {
+00089 CNewPath *inst = CNewPath::getInstance();
+00090 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> i = 0; i &lt; inst-&gt;_Extensions.size (); i++)
+00091 {
+00092 <font class="keywordflow">if</font> (inst-&gt;_Extensions[i].first == ext1 &amp;&amp; inst-&gt;_Extensions[i].second == ext2)
+00093 {
+00094 <font class="keywordflow">return</font> i;
+00095 }
+00096 }
+00097 <font class="keywordflow">return</font> -1;
+00098 }
+00099
+00100 <font class="keywordtype">void</font> CNewPath::remapExtension (<font class="keyword">const</font> string &amp;ext1, <font class="keyword">const</font> string &amp;ext2, <font class="keywordtype">bool</font> substitute)
+00101 {
+00102 CNewPath *inst = CNewPath::getInstance();
+00103
+00104 <font class="keywordflow">if</font> (ext1.empty() || ext2.empty())
+00105 {
+00106 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::remapExtension(%s, %s, %d): can't remap empty extension"</font>, ext1.c_str(), ext2.c_str(), substitute);
+00107 }
+00108
+00109 <font class="keywordflow">if</font> (!substitute)
+00110 {
+00111 <font class="comment">// remove the mapping from the mapping list</font>
+00112 <a class="code" href="types__nl_8h.html#a13">sint</a> n = inst-&gt;findExtension (ext1, ext2);
+00113 <a class="code" href="debug_8h.html#a6">nlassert</a> (n != -1);
+00114 inst-&gt;_Extensions.erase (inst-&gt;_Extensions.begin() + n);
+00115
+00116 <font class="comment">// remove mapping in the map</font>
+00117 map&lt;string, CNewFileEntry&gt;::iterator it = inst-&gt;_Files.begin();
+00118 map&lt;string, CNewFileEntry&gt;::iterator nit = it;
+00119 <font class="keywordflow">while</font> (it != inst-&gt;_Files.end ())
+00120 {
+00121 nit++;
+00122 <font class="keywordflow">if</font> ((*it).second.Remapped &amp;&amp; (*it).second.Extension == ext2)
+00123 {
+00124 inst-&gt;_Files.erase (it);
+00125 }
+00126 it = nit;
+00127 }
+00128 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::remapExtension(%s, %s, %d): extension removed"</font>, ext1.c_str(), ext2.c_str(), substitute);
+00129 }
+00130 <font class="keywordflow">else</font>
+00131 {
+00132 <a class="code" href="types__nl_8h.html#a13">sint</a> n = inst-&gt;findExtension (ext1, ext2);
+00133 <font class="keywordflow">if</font> (n != -1)
+00134 {
+00135 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::remapExtension(%s, %s, %d): remapping already set"</font>, ext1.c_str(), ext2.c_str(), substitute);
+00136 <font class="keywordflow">return</font>;
+00137 }
+00138
+00139 <font class="comment">// adding mapping into the mapping list</font>
+00140 inst-&gt;_Extensions.push_back (make_pair (ext1, ext2));
+00141
+00142 <font class="comment">// adding mapping into the map</font>
+00143 vector&lt;string&gt; newFiles;
+00144 map&lt;string, CNewFileEntry&gt;::iterator it = inst-&gt;_Files.begin();
+00145 <font class="keywordflow">while</font> (it != inst-&gt;_Files.end ())
+00146 {
+00147 <font class="keywordflow">if</font> (!(*it).second.Remapped &amp;&amp; (*it).second.Extension == ext1)
+00148 {
+00149 <font class="comment">// find if already exist</font>
+00150 <a class="code" href="types__nl_8h.html#a13">sint</a> pos = (*it).first.find_last_of (<font class="stringliteral">"."</font>);
+00151 <font class="keywordflow">if</font> (pos != string::npos)
+00152 {
+00153 string <a class="code" href="cf__lexical_8cpp.html#a95">file</a> = (*it).first.substr (0, pos + 1);
+00154 <a class="code" href="cf__lexical_8cpp.html#a95">file</a> += ext2;
+00155
+00156 map&lt;string, CNewFileEntry&gt;::iterator nit = inst-&gt;_Files.find (<a class="code" href="cf__lexical_8cpp.html#a95">file</a>);
+00157 <font class="keywordflow">if</font> (nit != inst-&gt;_Files.end())
+00158 {
+00159 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::remapExtension(%s, %s): The file '%s' is in conflict with the remapping file '%s', skip it"</font>, ext1.c_str(), ext2.c_str(), <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.c_str(), (*it).first.c_str());
+00160 }
+00161 <font class="keywordflow">else</font>
+00162 {
+00163 <font class="comment">// TODO perhaps a problem because I insert in the current map that i parcours</font>
+00164 insertFileInMap (<a class="code" href="cf__lexical_8cpp.html#a95">file</a>, (*it).second.Path, <font class="keyword">true</font>, ext2);
+00165 }
+00166 }
+00167 }
+00168 it++;
+00169 }
+00170 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::remapExtension(%s, %s, %d): extension added"</font>, ext1.c_str(), ext2.c_str(), substitute);
+00171 }
+00172 }
+00173
+00174 string CNewPath::lookup (<font class="keyword">const</font> string &amp;filename)
+00175 {
+00176 <font class="comment">// Try to find in the map directories</font>
+00177 CNewPath *inst = CNewPath::getInstance();
+00178 map&lt;string, CNewFileEntry&gt;::iterator it = inst-&gt;_Files.find (filename);
+00179 <font class="comment">// If found in the map, returns it</font>
+00180 <font class="keywordflow">if</font> (it != inst-&gt;_Files.end())
+00181 {
+00182 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::lookup(%s): found in the map directory: '%s'"</font>, filename.c_str(), (*it).second.Path.c_str());
+00183 <font class="keywordflow">return</font> (*it).second.Path;
+00184 }
+00185
+00186 <font class="comment">// Try to find in the alternative directories</font>
+00187 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> i = 0; i &lt; inst-&gt;_AlternativePaths.size(); i++)
+00188 {
+00189 string <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = inst-&gt;_AlternativePaths[i] + filename;
+00190 <font class="keywordflow">if</font> ( CNewFile::fileExists(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>) )
+00191 {
+00192 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::lookup(%s): found in the alternative directory: '%s'"</font>, filename.c_str(), <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>.c_str());
+00193 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00194 }
+00195
+00196 <font class="comment">// try with the remapping</font>
+00197 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> j = 0; j &lt; inst-&gt;_Extensions.size(); j++)
+00198 {
+00199 string rs = inst-&gt;_AlternativePaths[i] + CNewFile::getFilenameWithoutExtension (filename) + <font class="stringliteral">"."</font> + inst-&gt;_Extensions[j].first;
+00200 <font class="keywordflow">if</font> ( CNewFile::fileExists(rs) )
+00201 {
+00202 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::lookup(%s): found in the alternative directory: '%s'"</font>, filename.c_str(), rs.c_str());
+00203 <font class="keywordflow">return</font> rs;
+00204 }
+00205 }
+00206 }
+00207
+00208 <font class="comment">// Not found</font>
+00209 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::lookup(%s): file not found"</font>, filename.c_str());
+00210 <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
+00211 }
+00212
+00213 string CNewPath::standardizePath (<font class="keyword">const</font> string &amp;path, <font class="keywordtype">bool</font> addFinalSlash)
+00214 {
+00215 string newPath;
+00216
+00217 <font class="comment">// check empty path</font>
+00218 <font class="keywordflow">if</font> (path.empty()) <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
+00219
+00220 <font class="comment">// don't transform the first \\ for windows network path</font>
+00221 <font class="comment">/* if (path.size() &gt;= 2 &amp;&amp; path[0] == '\\' &amp;&amp; path[1] == '\\')</font>
+00222 <font class="comment"> {</font>
+00223 <font class="comment"> newPath += "\\\\";</font>
+00224 <font class="comment"> i = 2;</font>
+00225 <font class="comment"> }</font>
+00226 <font class="comment">*/</font>
+00227 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> i = 0; i &lt; path.size(); i++)
+00228 {
+00229 <font class="comment">// don't transform the first \\ for windows network path</font>
+00230 <font class="keywordflow">if</font> (path[i] == <font class="charliteral">'\\'</font>)
+00231 newPath += <font class="charliteral">'/'</font>;
+00232 <font class="keywordflow">else</font>
+00233 newPath += path[i];
+00234 }
+00235
+00236 <font class="comment">// add terminal slash</font>
+00237 <font class="keywordflow">if</font> (addFinalSlash &amp;&amp; newPath[path.size()-1] != <font class="charliteral">'/'</font>)
+00238 newPath += <font class="charliteral">'/'</font>;
+00239
+00240 <font class="keywordflow">return</font> newPath;
+00241 }
+00242
+00243 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00244 <font class="preprocessor"></font><font class="preprocessor"># define dirent WIN32_FIND_DATA</font>
+00245 <font class="preprocessor"></font><font class="preprocessor"># define DIR void</font>
+00246 <font class="preprocessor"></font>
+00247 <font class="keyword">static</font> string sDir;
+00248 <font class="keyword">static</font> <font class="keywordtype">char</font> sDirBackup[512];
+00249 <font class="keyword">static</font> WIN32_FIND_DATA findData;
+00250 <font class="keyword">static</font> HANDLE hFind;
+00251
+00252 DIR *opendir (<font class="keyword">const</font> <font class="keywordtype">char</font> *path)
+00253 {
+00254 <a class="code" href="debug_8h.html#a6">nlassert</a> (path != NULL);
+00255 <a class="code" href="debug_8h.html#a6">nlassert</a> (path[0] != <font class="charliteral">'\0'</font>);
+00256
+00257 <a class="code" href="debug_8h.html#a6">nlassert</a> (sDirBackup[0] == <font class="charliteral">'\0'</font>);
+00258 <font class="keywordflow">if</font> (GetCurrentDirectory (512, sDirBackup) == 0)
+00259 {
+00260 <font class="comment">// failed</font>
+00261 <font class="keywordflow">return</font> NULL;
+00262 }
+00263
+00264 <font class="keywordflow">if</font> (!CNewFile::isDirectory(path))
+00265 {
+00266 <font class="comment">// failed</font>
+00267 <font class="keywordflow">return</font> NULL;
+00268 }
+00269
+00270 sDir = path;
+00271
+00272 hFind = NULL;
+00273
+00274 <font class="keywordflow">return</font> (<font class="keywordtype">void</font> *)1;
+00275 }
+00276
+00277 <font class="keywordtype">int</font> closedir (DIR *dir)
+00278 {
+00279 <a class="code" href="debug_8h.html#a6">nlassert</a> (sDirBackup[0] != <font class="charliteral">'\0'</font>);
+00280 sDirBackup[0] = <font class="charliteral">'\0'</font>;
+00281 <font class="keywordflow">return</font> 0;
+00282 }
+00283
+00284 dirent *readdir (DIR *dir)
+00285 {
+00286 <font class="comment">// set the current path</font>
+00287 <a class="code" href="debug_8h.html#a6">nlassert</a> (!sDir.empty());
+00288 <font class="keywordflow">if</font> (SetCurrentDirectory (sDir.c_str()) == 0)
+00289 {
+00290 <font class="comment">// failed</font>
+00291 <font class="keywordflow">return</font> NULL;
+00292 }
+00293
+00294 <font class="keywordflow">if</font> (hFind == NULL)
+00295 {
+00296 hFind = FindFirstFile (<font class="stringliteral">"*"</font>, &amp;findData);
+00297 }
+00298 <font class="keywordflow">else</font>
+00299 {
+00300 <font class="keywordflow">if</font> (!FindNextFile (hFind, &amp;findData))
+00301 {
+00302 <a class="code" href="debug_8h.html#a6">nlassert</a> (sDirBackup[0] != <font class="charliteral">'\0'</font>);
+00303 SetCurrentDirectory (sDirBackup);
+00304 <font class="keywordflow">return</font> NULL;
+00305 }
+00306 }
+00307
+00308 <font class="comment">// restore the current path</font>
+00309 <a class="code" href="debug_8h.html#a6">nlassert</a> (sDirBackup[0] != <font class="charliteral">'\0'</font>);
+00310 SetCurrentDirectory (sDirBackup);
+00311
+00312 <font class="keywordflow">return</font> &amp;findData;
+00313 }
+00314
+00315 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
+00316 <font class="preprocessor"></font>
+00317 <font class="keywordtype">bool</font> <a class="code" href="namespaceNLMISC.html#a288">isdirectory</a> (dirent *de)
+00318 {
+00319 <a class="code" href="debug_8h.html#a6">nlassert</a> (de != NULL);
+00320 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00321 <font class="preprocessor"></font> <font class="keywordflow">return</font> (de-&gt;dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY) != 0;
+00322 <font class="preprocessor">#else</font>
+00323 <font class="preprocessor"></font> <font class="keywordflow">return</font> (de-&gt;d_type &amp; DT_DIR) != 0;
+00324 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
+00325 <font class="preprocessor"></font>}
+00326
+00327 <font class="keywordtype">bool</font> <a class="code" href="namespaceNLMISC.html#a289">isfile</a> (dirent *de)
+00328 {
+00329 <a class="code" href="debug_8h.html#a6">nlassert</a> (de != NULL);
+00330 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00331 <font class="preprocessor"></font> <font class="keywordflow">return</font> (de-&gt;dwFileAttributes &amp; FILE_ATTRIBUTE_DIRECTORY) == 0;
+00332 <font class="preprocessor">#else</font>
+00333 <font class="preprocessor"></font> <font class="keywordflow">return</font> (de-&gt;d_type &amp; DT_DIR) == 0;
+00334 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
+00335 <font class="preprocessor"></font>}
+00336
+00337 string <a class="code" href="namespaceNLMISC.html#a290">getname</a> (dirent *de)
+00338 {
+00339 <a class="code" href="debug_8h.html#a6">nlassert</a> (de != NULL);
+00340 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00341 <font class="preprocessor"></font> <font class="keywordflow">return</font> de-&gt;cFileName;
+00342 <font class="preprocessor">#else</font>
+00343 <font class="preprocessor"></font> <font class="keywordflow">return</font> de-&gt;d_name;
+00344 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
+00345 <font class="preprocessor"></font>}
+00346
+00347 <font class="keywordtype">void</font> CNewPath::getPathContent (<font class="keyword">const</font> string &amp;path, <font class="keywordtype">bool</font> recurse, <font class="keywordtype">bool</font> wantDir, <font class="keywordtype">bool</font> wantFile, vector&lt;string&gt; &amp;result)
+00348 {
+00349 DIR *dir = opendir (path.c_str());
+00350 <font class="keywordflow">if</font> (dir == NULL)
+00351 {
+00352 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::getPathContent(%s, %d, %d, %d): could not open the directory"</font>, path.c_str(), recurse, wantDir, wantFile);
+00353 <font class="keywordflow">return</font>;
+00354 }
+00355
+00356 <font class="comment">// contains path that we have to recurs into</font>
+00357 vector&lt;string&gt; recursPath;
+00358
+00359 <font class="keywordflow">while</font> (true)
+00360 {
+00361 dirent *de = readdir(dir);
+00362 <font class="keywordflow">if</font> (de == NULL)
+00363 {
+00364 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::getPathContent(%s, %d, %d, %d): end of directory"</font>, path.c_str(), recurse, wantDir, wantFile);
+00365 <font class="keywordflow">break</font>;
+00366 }
+00367
+00368 <font class="comment">// skip . and ..</font>
+00369 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLMISC.html#a290">getname</a> (de) == <font class="stringliteral">"."</font> || <a class="code" href="namespaceNLMISC.html#a290">getname</a> (de) == <font class="stringliteral">".."</font>)
+00370 <font class="keywordflow">continue</font>;
+00371
+00372 <font class="keywordflow">if</font> (<a class="code" href="namespaceNLMISC.html#a288">isdirectory</a>(de))
+00373 {
+00374 string stdName = standardizePath(path + <a class="code" href="namespaceNLMISC.html#a290">getname</a>(de));
+00375 <font class="keywordflow">if</font> (recurse)
+00376 {
+00377 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::getPathContent(%s, %d, %d, %d): need to recurse into '%s'"</font>, path.c_str(), recurse, wantDir, wantFile, stdName.c_str());
+00378 recursPath.push_back (stdName);
+00379 }
+00380
+00381 <font class="keywordflow">if</font> (wantDir)
+00382 {
+00383 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::getPathContent(%s, %d, %d, %d): adding path '%s'"</font>, path.c_str(), recurse, wantDir, wantFile, stdName.c_str());
+00384 result.push_back (stdName);
+00385 }
+00386 }
+00387 <font class="keywordflow">if</font> (wantFile &amp;&amp; <a class="code" href="namespaceNLMISC.html#a289">isfile</a>(de))
+00388 {
+00389 string stdName = path + <a class="code" href="namespaceNLMISC.html#a290">getname</a>(de);
+00390 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::getPathContent(%s, %d, %d, %d): adding file '%s'"</font>, path.c_str(), recurse, wantDir, wantFile, stdName.c_str());
+00391 result.push_back (stdName);
+00392 }
+00393 }
+00394
+00395 closedir (dir);
+00396
+00397 <font class="comment">// let s recurse</font>
+00398 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> i = 0; i &lt; recursPath.size (); i++)
+00399 getPathContent (recursPath[i], recurse, wantDir, wantFile, result);
+00400 }
+00401
+00402 <font class="keywordtype">void</font> CNewPath::addSearchPath (<font class="keyword">const</font> string &amp;path, <font class="keywordtype">bool</font> recurse, <font class="keywordtype">bool</font> alternative)
+00403 {
+00404 CNewPath *inst = CNewPath::getInstance();
+00405 string newPath = standardizePath(path);
+00406
+00407 <font class="comment">// check empty directory</font>
+00408 <font class="keywordflow">if</font> (newPath.empty())
+00409 {
+00410 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchPath(%s, %d, %d): can't add empty directory, skip it"</font>, path.c_str(), recurse, alternative);
+00411 <font class="keywordflow">return</font>;
+00412 }
+00413
+00414 <font class="comment">// check if it s a directory</font>
+00415 <font class="keywordflow">if</font> (!CNewFile::isExists (newPath))
+00416 {
+00417 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchPath(%s, %d, %d): '%s' is not found, skip it"</font>, path.c_str(), recurse, alternative, newPath.c_str());
+00418 <font class="keywordflow">return</font>;
+00419 }
+00420
+00421 <font class="comment">// check if it s a directory</font>
+00422 <font class="keywordflow">if</font> (!CNewFile::isDirectory (newPath))
+00423 {
+00424 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchPath(%s, %d, %d): '%s' is not a directory, skip it"</font>, path.c_str(), recurse, alternative, newPath.c_str());
+00425 <font class="keywordflow">return</font>;
+00426 }
+00427
+00428 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::addSearchPath(%s, %d, %d): try to add '%s'"</font>, path.c_str(), recurse, alternative, newPath.c_str());
+00429
+00430 <font class="keywordflow">if</font> (alternative)
+00431 {
+00432 vector&lt;string&gt; pathsToProcess;
+00433
+00434 <font class="comment">// add the current path</font>
+00435 pathsToProcess.push_back (newPath);
+00436
+00437 <font class="keywordflow">if</font> (recurse)
+00438 {
+00439 <font class="comment">// find all path and subpath</font>
+00440 getPathContent (newPath, recurse, <font class="keyword">true</font>, <font class="keyword">false</font>, pathsToProcess);
+00441 }
+00442
+00443 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> p = 0; p &lt; pathsToProcess.size(); p++)
+00444 {
+00445 <font class="comment">// check if the path not already in the vector</font>
+00446 <a class="code" href="types__nl_8h.html#a14">uint</a> i;
+00447 <font class="keywordflow">for</font> (i = 0; i &lt; inst-&gt;_AlternativePaths.size(); i++)
+00448 {
+00449 <font class="keywordflow">if</font> (inst-&gt;_AlternativePaths[i] == pathsToProcess[p])
+00450 <font class="keywordflow">break</font>;
+00451 }
+00452 <font class="keywordflow">if</font> (i == inst-&gt;_AlternativePaths.size())
+00453 {
+00454 <font class="comment">// add them in the alternative directory</font>
+00455 inst-&gt;_AlternativePaths.push_back (pathsToProcess[p]);
+00456 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::addSearchPath(%s, %d, %d): path '%s' added"</font>, newPath.c_str(), recurse, alternative, pathsToProcess[p].c_str());
+00457 }
+00458 <font class="keywordflow">else</font>
+00459 {
+00460 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchPath(%s, %d, %d): path '%s' already added"</font>, newPath.c_str(), recurse, alternative, pathsToProcess[p].c_str());
+00461 }
+00462 }
+00463 }
+00464 <font class="keywordflow">else</font>
+00465 {
+00466 vector&lt;string&gt; filesToProcess;
+00467 <font class="comment">// find all files in the path and subpaths</font>
+00468 getPathContent (newPath, recurse, <font class="keyword">false</font>, <font class="keyword">true</font>, filesToProcess);
+00469
+00470 <font class="comment">// add them in the map</font>
+00471 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> f = 0; f &lt; filesToProcess.size(); f++)
+00472 {
+00473 string filename = CNewFile::getFilename (filesToProcess[f]);
+00474 string filepath = CNewFile::getPath (filesToProcess[f]);
+00475 <font class="comment">// insertFileInMap (filename, filepath, false, CNewFile::getExtension(filename));</font>
+00476 addSearchFile (filesToProcess[f]);
+00477 }
+00478 }
+00479 }
+00480
+00481 <font class="keywordtype">void</font> CNewPath::addSearchFile (<font class="keyword">const</font> string &amp;<a class="code" href="cf__lexical_8cpp.html#a95">file</a>, <font class="keywordtype">bool</font> remap, <font class="keyword">const</font> string &amp;virtual_ext)
+00482 {
+00483 CNewPath *inst = CNewPath::getInstance();
+00484 string newFile = standardizePath(<a class="code" href="cf__lexical_8cpp.html#a95">file</a>, <font class="keyword">false</font>);
+00485
+00486 <font class="comment">// check empty file</font>
+00487 <font class="keywordflow">if</font> (newFile.empty())
+00488 {
+00489 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchFile(%s, %d, %s): can't add empty file, skip it"</font>, <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.c_str(), remap, virtual_ext.c_str());
+00490 <font class="keywordflow">return</font>;
+00491 }
+00492
+00493 <font class="comment">// check if the file exists</font>
+00494 <font class="keywordflow">if</font> (!CNewFile::isExists (newFile))
+00495 {
+00496 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchFile(%s, %d, %s): '%s' is not found, skip it"</font>, <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.c_str(), remap, virtual_ext.c_str(), newFile.c_str());
+00497 <font class="keywordflow">return</font>;
+00498 }
+00499
+00500 <font class="comment">// check if it s a file</font>
+00501 <font class="keywordflow">if</font> (CNewFile::isDirectory (newFile))
+00502 {
+00503 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchFile(%s, %d, %s): '%s' is not a file, skip it"</font>, <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.c_str(), remap, virtual_ext.c_str(), newFile.c_str());
+00504 <font class="keywordflow">return</font>;
+00505 }
+00506
+00507 string filenamewoext = CNewFile::getFilenameWithoutExtension (newFile);
+00508 string filename, ext;
+00509
+00510 <font class="keywordflow">if</font> (virtual_ext.empty())
+00511 {
+00512 filename = CNewFile::getFilename (newFile);
+00513 ext = CNewFile::getExtension (filename);
+00514 }
+00515 <font class="keywordflow">else</font>
+00516 {
+00517 filename = filenamewoext + <font class="stringliteral">"."</font> + virtual_ext;
+00518 ext = virtual_ext;
+00519 }
+00520
+00521 map&lt;string, CNewFileEntry&gt;::iterator it = inst-&gt;_Files.find (filename);
+00522 <font class="keywordflow">if</font> (it == inst-&gt;_Files.end ())
+00523 {
+00524 <font class="comment">// ok, the room is empty, let s add it</font>
+00525 insertFileInMap (filename, newFile, remap, ext);
+00526 }
+00527 <font class="keywordflow">else</font>
+00528 {
+00529 <font class="keywordflow">if</font> (remap)
+00530 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchPath(%s, %d, %s): remapped file '%s' already inserted in the map directory"</font>, <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.c_str(), remap, virtual_ext.c_str(), filename.c_str());
+00531 <font class="keywordflow">else</font>
+00532 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchPath(%s, %d, %s): file '%s' already inserted in the map directory"</font>, <a class="code" href="cf__lexical_8cpp.html#a95">file</a>.c_str(), remap, virtual_ext.c_str(), filename.c_str());
+00533 }
+00534
+00535 <font class="keywordflow">if</font> (!remap &amp;&amp; !ext.empty())
+00536 {
+00537 <font class="comment">// now, we have to see extension and insert in the map the remapped files</font>
+00538 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> i = 0; i &lt; inst-&gt;_Extensions.size (); i++)
+00539 {
+00540 <font class="keywordflow">if</font> (inst-&gt;_Extensions[i].first == ext)
+00541 {
+00542 <font class="comment">// need to remap</font>
+00543 addSearchFile (newFile, <font class="keyword">true</font>, inst-&gt;_Extensions[i].second);
+00544 }
+00545 }
+00546 }
+00547 }
+00548
+00549 <font class="keywordtype">void</font> CNewPath::addSearchListFile (<font class="keyword">const</font> string &amp;filename, <font class="keywordtype">bool</font> recurse, <font class="keywordtype">bool</font> alternative)
+00550 {
+00551 CNewPath *inst = CNewPath::getInstance();
+00552
+00553 <font class="comment">// check empty file</font>
+00554 <font class="keywordflow">if</font> (filename.empty())
+00555 {
+00556 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchListFile(%s, %d, %d): can't add empty file, skip it"</font>, filename.c_str(), recurse, alternative);
+00557 <font class="keywordflow">return</font>;
+00558 }
+00559
+00560 <font class="comment">// check if the file exists</font>
+00561 <font class="keywordflow">if</font> (!CNewFile::isExists (filename))
+00562 {
+00563 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchListFile(%s, %d, %d): '%s' is not found, skip it"</font>, filename.c_str(), recurse, alternative, filename.c_str());
+00564 <font class="keywordflow">return</font>;
+00565 }
+00566
+00567 <font class="comment">// check if it s a file</font>
+00568 <font class="keywordflow">if</font> (CNewFile::isDirectory (filename))
+00569 {
+00570 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchListFile(%s, %d, %d): '%s' is not a file, skip it"</font>, filename.c_str(), recurse, alternative, filename.c_str());
+00571 <font class="keywordflow">return</font>;
+00572 }
+00573
+00574 <font class="comment">// TODO lire le fichier et ajouter les fichiers qui sont dedans</font>
+00575
+00576 }
+00577
+00578
+00579 <font class="keywordtype">void</font> CNewPath::addSearchBigFile (<font class="keyword">const</font> string &amp;filename, <font class="keywordtype">bool</font> recurse, <font class="keywordtype">bool</font> alternative)
+00580 {
+00581 <font class="comment">// TODO &amp; CHECK</font>
+00582 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::addSearchBigFile(): not impremented"</font>);
+00583 }
+00584
+00585 <font class="keywordtype">void</font> CNewPath::insertFileInMap (<font class="keyword">const</font> string &amp;filename, <font class="keyword">const</font> string &amp;filepath, <font class="keywordtype">bool</font> remap, <font class="keyword">const</font> string &amp;extension)
+00586 {
+00587 CNewPath *inst = CNewPath::getInstance();
+00588
+00589 <font class="comment">// find if the file already exist</font>
+00590 map&lt;string, CNewFileEntry&gt;::iterator it = inst-&gt;_Files.find (filename);
+00591 <font class="keywordflow">if</font> (it != inst-&gt;_Files.end ())
+00592 {
+00593 <a class="code" href="debug_8h.html#a2">nlwarning</a> (<font class="stringliteral">"CNewPath::insertFileInMap(%s, %s, %d, %s): already inserted from '%s', skip it"</font>, filename.c_str(), filepath.c_str(), remap, extension.c_str(), (*it).second.Path.c_str());
+00594 }
+00595 <font class="keywordflow">else</font>
+00596 {
+00597 inst-&gt;_Files.insert (make_pair (filename, CNewFileEntry (filepath, remap, extension)));
+00598 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<font class="stringliteral">"CNewPath::insertFileInMap(%s, %s, %d, %s): added"</font>, filename.c_str(), filepath.c_str(), remap, extension.c_str());
+00599 }
+00600 }
+00601
+00602 <font class="keywordtype">void</font> CNewPath::display ()
+00603 {
+00604 CNewPath *inst = CNewPath::getInstance ();
+00605 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"Contents of the map:"</font>);
+00606 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%-25s %-5s %-5s %s"</font>, <font class="stringliteral">"filename"</font>, <font class="stringliteral">"ext"</font>, <font class="stringliteral">"remap"</font>, <font class="stringliteral">"full path"</font>);
+00607 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"----------------------------------------------------"</font>);
+00608 <font class="keywordflow">for</font> (map&lt;string, CNewFileEntry&gt;::iterator it = inst-&gt;_Files.begin(); it != inst-&gt;_Files.end (); it++)
+00609 {
+00610 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"%-25s %-5s %-5d %s"</font>, (*it).first.c_str(), (*it).second.Extension.c_str(), (*it).second.Remapped, (*it).second.Path.c_str());
+00611 }
+00612 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">""</font>);
+00613 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"Contents of the alternative directory:"</font>);
+00614 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> i = 0; i &lt; inst-&gt;_AlternativePaths.size(); i++)
+00615 {
+00616 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"'%s'"</font>, inst-&gt;_AlternativePaths[i].c_str ());
+00617 }
+00618 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">""</font>);
+00619 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"Contents of the remapped entension table:"</font>);
+00620 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a14">uint</a> j = 0; j &lt; inst-&gt;_Extensions.size(); j++)
+00621 {
+00622 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"'%s' -&gt; '%s'"</font>, inst-&gt;_Extensions[j].first.c_str (), inst-&gt;_Extensions[j].second.c_str ());
+00623 }
+00624 <a class="code" href="debug_8h.html#a1">nlinfo</a> (<font class="stringliteral">"End of display"</font>);
+00625 }
+00626
+00638
+00639 <font class="preprocessor">#if 0</font>
+00640 <font class="preprocessor"></font><font class="comment">/*</font>
+00641 <font class="comment"> * Adds a search path</font>
+00642 <font class="comment"> */</font>
+00643 <font class="keywordtype">void</font> CPath::addSearchPath( <font class="keyword">const</font> string&amp; path )
+00644 {
+00645 <font class="keywordflow">if</font> ( path == <font class="stringliteral">""</font> )
+00646 {
+00647 <font class="keywordflow">return</font>;
+00648 }
+00649 string <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = path;
+00650 <font class="keyword">const</font> <font class="keywordtype">char</font> slash = <font class="charliteral">'/'</font>;
+00651
+00652 <font class="comment">// Add an ending slash if necessary</font>
+00653 <font class="keywordflow">if</font> ( path[path.size()-1] != slash )
+00654 {
+00655 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> += slash;
+00656 }
+00657
+00658 <font class="comment">// Add path to the search paths</font>
+00659 _SearchPaths.push_back( <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> );
+00660 }
+00661
+00662
+00663 <font class="comment">/* Returns the long name (path and filename) for the specified file, using search paths</font>
+00664 <font class="comment"> * stored by addSearchPath.</font>
+00665 <font class="comment"> */</font>
+00666 string CPath::lookup (<font class="keyword">const</font> string &amp;filename, <font class="keywordtype">bool</font> throwException)
+00667 {
+00668 <font class="keywordflow">if</font>(!filename.empty())
+00669 {
+00670 <font class="keywordflow">if</font> ( CNewFile::fileExists(filename) )
+00671 {
+00672 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(filename);
+00673 <font class="keywordflow">return</font> filename;
+00674 }
+00675 CStringVector::iterator isv;
+00676 string <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00677 <font class="keywordflow">for</font> ( isv=CPath::_SearchPaths.begin(); isv!=CPath::_SearchPaths.end(); ++isv )
+00678 {
+00679 <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a> = *isv + filename;
+00680 <font class="keywordflow">if</font> ( CNewFile::fileExists(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>) )
+00681 {
+00682 <a class="code" href="path_8cpp.html#a0">NL_DISPLAY_PATH</a>(<a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>);
+00683 <font class="keywordflow">return</font> <a class="code" href="driver__opengl__extension__def_8h.html#a383">s</a>;
+00684 }
+00685 }
+00686 }
+00687
+00688 <font class="keywordflow">if</font> (throwException)
+00689 <font class="keywordflow">throw</font> EPathNotFound( filename );
+00690
+00691 <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
+00692 }
+00693
+00694 <font class="preprocessor">#endif</font>
+00695 <font class="preprocessor"></font>
+00696 <font class="comment">//********************************* CNewFile</font>
+00697
+00698 <font class="keywordtype">int</font> CNewFile::getLastSeparator (<font class="keyword">const</font> string &amp;filename)
+00699 {
+00700 <font class="keywordtype">int</font> pos = filename.find_last_of (<font class="charliteral">'/'</font>);
+00701 <font class="keywordflow">if</font> (pos == string::npos)
+00702 {
+00703 pos = filename.find_last_of (<font class="charliteral">'\\'</font>);
+00704 }
+00705 <font class="keywordflow">return</font> pos;
+00706 }
+00707
+00708 string CNewFile::getFilename (<font class="keyword">const</font> string &amp;filename)
+00709 {
+00710 <font class="keywordtype">int</font> pos = CNewFile::getLastSeparator(filename);
+00711 <font class="keywordflow">if</font> (pos != string::npos)
+00712 <font class="keywordflow">return</font> filename.substr (pos + 1);
+00713 <font class="keywordflow">else</font>
+00714 <font class="keywordflow">return</font> filename;
+00715 }
+00716
+00717 string CNewFile::getFilenameWithoutExtension (<font class="keyword">const</font> string &amp;filename)
+00718 {
+00719 string filename2 = getFilename (filename);
+00720 <font class="keywordtype">int</font> pos = filename2.find_last_of (<font class="charliteral">'.'</font>);
+00721 <font class="keywordflow">if</font> (pos == string::npos)
+00722 <font class="keywordflow">return</font> filename2;
+00723 <font class="keywordflow">else</font>
+00724 <font class="keywordflow">return</font> filename2.substr (0, pos);
+00725 }
+00726
+00727 string CNewFile::getExtension (<font class="keyword">const</font> string &amp;filename)
+00728 {
+00729 <font class="keywordtype">int</font> pos = filename.find_last_of (<font class="charliteral">'.'</font>);
+00730 <font class="keywordflow">if</font> (pos == string::npos)
+00731 <font class="keywordflow">return</font> <font class="stringliteral">""</font>;
+00732 <font class="keywordflow">else</font>
+00733 <font class="keywordflow">return</font> filename.substr (pos + 1);
+00734 }
+00735
+00736 string CNewFile::getPath (<font class="keyword">const</font> string &amp;filename)
+00737 {
+00738 <font class="keywordtype">int</font> pos = CNewFile::getLastSeparator(filename);
+00739 <font class="keywordflow">if</font> (pos != string::npos)
+00740 <font class="keywordflow">return</font> filename.substr (0, pos + 1);
+00741 <font class="keywordflow">else</font>
+00742 <font class="keywordflow">return</font> filename;
+00743 }
+00744
+00745 <font class="keywordtype">bool</font> CNewFile::isDirectory (<font class="keyword">const</font> string &amp;filename)
+00746 {
+00747 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00748 <font class="preprocessor"></font> DWORD <a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a> = GetFileAttributes(filename.c_str());
+00749 <a class="code" href="debug_8h.html#a6">nlassert</a> (<a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a> != -1);
+00750 <font class="keywordflow">return</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a400">res</a> &amp; FILE_ATTRIBUTE_DIRECTORY) != 0;
+00751 <font class="preprocessor">#else // NL_OS_WINDOWS</font>
+00752 <font class="preprocessor"></font> <font class="keyword">struct </font>stat buf;
+00753 <font class="keywordtype">int</font> result = stat (filename.c_str (), &amp;buf);
+00754 <a class="code" href="debug_8h.html#a6">nlassert</a> (result == 0);
+00755 <font class="keywordflow">return</font> (buf.st_mode &amp; S_IFDIR) != 0;
+00756 <font class="preprocessor">#endif // NL_OS_WINDOWS</font>
+00757 <font class="preprocessor"></font>}
+00758
+00759 <font class="keywordtype">bool</font> CNewFile::isExists (<font class="keyword">const</font> string &amp;filename)
+00760 {
+00761 <font class="preprocessor">#ifdef NL_OS_WINDOWS</font>
+00762 <font class="preprocessor"></font> <font class="keywordflow">return</font> (GetFileAttributes(filename.c_str()) != -1);
+00763 <font class="preprocessor">#else // NL_OS_WINDOWS</font>
+00764 <font class="preprocessor"></font> <font class="keyword">struct </font>stat buf;
+00765 <font class="keywordflow">return</font> stat (filename.c_str (), &amp;buf) == 0;
+00766 <font class="preprocessor">#endif NL_OS_WINDOWS</font>
+00767 <font class="preprocessor"></font>}
+00768
+00769 <font class="keywordtype">bool</font> CNewFile::fileExists (<font class="keyword">const</font> string&amp; filename)
+00770 {
+00771 <font class="keywordflow">return</font> ! ! fstream( filename.c_str(), ios::in );
+00772 }
+00773
+00774
+00775 string CNewFile::findNewFile (<font class="keyword">const</font> string &amp;filename)
+00776 {
+00777 <font class="keywordtype">int</font> pos = filename.find_last_of (<font class="charliteral">'.'</font>);
+00778 <font class="keywordflow">if</font> (pos == string::npos)
+00779 <font class="keywordflow">return</font> filename;
+00780
+00781 string start = filename.substr (0, pos);
+00782 string end = filename.substr (pos);
+00783
+00784 <a class="code" href="types__nl_8h.html#a14">uint</a> <a class="code" href="driver__opengl__extension__def_8h.html#a410">num</a> = 0;
+00785 <font class="keywordtype">char</font> numchar[4];
+00786 string npath;
+00787 <font class="keywordflow">do</font>
+00788 {
+00789 npath = start;
+00790 <a class="code" href="namespaceNLMISC.html#a203">smprintf</a>(numchar,4,<font class="stringliteral">"%03d"</font>,<a class="code" href="driver__opengl__extension__def_8h.html#a410">num</a>++);
+00791 npath += numchar;
+00792 npath += end;
+00793 <font class="keywordflow">if</font> (!CNewFile::fileExists(npath)) <font class="keywordflow">break</font>;
+00794 }
+00795 <font class="keywordflow">while</font> (<a class="code" href="driver__opengl__extension__def_8h.html#a410">num</a>&lt;999);
+00796 <font class="keywordflow">return</font> npath;
+00797 }
+00798
+00799 } <font class="comment">// NLMISC</font>
+00800 <font class="preprocessor">#endif</font>
+</pre></div>
+
+<!-- footer -->
+<BR><FONT Size=+5>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </FONT>
+</TD>
+<TD WIDTH=15><IMG SRC=http://www.nevrax.org/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
+</TR>
+</TABLE>
+</BODY>
+</HTML>