diff options
author | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2018-08-11 20:21:34 +0200 |
commit | 0ea5fc66924303d1bf73ba283a383e2aadee02f2 (patch) | |
tree | 2568e71a7ccc44ec23b8bb3f0ff97fb6bf2ed709 /docs/doxygen/nel/a03072.html | |
download | nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.tar.xz nevrax-website-self-hostable-0ea5fc66924303d1bf73ba283a383e2aadee02f2.zip |
Initial commit
Diffstat (limited to '')
-rw-r--r-- | docs/doxygen/nel/a03072.html | 2811 |
1 files changed, 2811 insertions, 0 deletions
diff --git a/docs/doxygen/nel/a03072.html b/docs/doxygen/nel/a03072.html new file mode 100644 index 00000000..9aef0a9a --- /dev/null +++ b/docs/doxygen/nel/a03072.html @@ -0,0 +1,2811 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> +<title>NeL: NLMISC::CPath class Reference</title> +<link href="doxygen.css" rel="stylesheet" type="text/css"> +</head><body> +<!-- Generated by Doxygen 1.3.6 --> +<div class="qindex"> <form class="search" action="search.php" method="get"> +<a class="qindex" href="main.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">Data Structures</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">Data Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div> +<h1>NLMISC::CPath Class Reference</h1><code>#include <<a class="el" href="a06168.html">path.h</a>></code> +<p> +<hr><a name="_details"></a><h2>Detailed Description</h2> +Utility class for searching files in differents paths. <dl compact><dt><b>Warning:</b></dt><dd><a class="el" href="a03072.html#NLMISC_1_1CPathe5">addSearchPath()</a>, <a class="el" href="a03072.html#NLMISC_1_1CPathe6">clearMap()</a> and <a class="el" href="a03072.html#NLMISC_1_1CPathe19">remapExtension()</a> are not reentrant. <p> +all path and files are *case sensitive* on linux. </dd></dl> +<dl compact><dt><b>Author:</b></dt><dd>Vianney Lecroart <p> +Nevrax France </dd></dl> +<dl compact><dt><b>Date:</b></dt><dd>2001 </dd></dl> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00055">55</a> of file <a class="el" href="a06168.html">path.h</a>.<table border=0 cellpadding=0 cellspacing=0> +<tr><td></td></tr> +<tr><td colspan=2><br><h2>Static Public Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe0">addIgnoredDoubleFile</a> (const std::string &ignoredFile)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe1">addSearchBigFile</a> (const std::string &<a class="el" href="a04560.html#a1">filename</a>, bool recurse, bool alternative, class <a class="el" href="a03873.html">NLMISC::IProgressCallback</a> *progressCallBack=NULL)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe2">addSearchFile</a> (const std::string &<a class="el" href="a04115.html#a95">file</a>, bool remap=false, const std::string &virtual_ext="", class <a class="el" href="a03873.html">NLMISC::IProgressCallback</a> *progressCallBack=NULL)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe3">addSearchListFile</a> (const std::string &<a class="el" href="a04560.html#a1">filename</a>, bool recurse, bool alternative)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe4">addSearchPath</a> (const std::string &path)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe5">addSearchPath</a> (const std::string &path, bool recurse, bool alternative, class <a class="el" href="a03873.html">IProgressCallback</a> *progressCallBack=NULL)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe6">clearMap</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe7">display</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe8">exists</a> (const std::string &<a class="el" href="a04560.html#a1">filename</a>)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::string </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe9">getCurrentPath</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe10">getFileList</a> (const std::string &extension, std::vector< std::string > &filenames)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::string </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe11">getFullPath</a> (const std::string &path, bool addFinalSlash=true)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe12">getPathContent</a> (const std::string &path, bool recurse, bool wantDir, bool wantFile, std::vector< std::string > &result, class <a class="el" href="a03873.html">IProgressCallback</a> *progressCallBack=NULL, bool showEverything=false)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe13">isMemoryCompressed</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe14">loadRemappedFiles</a> (const std::string &<a class="el" href="a04115.html#a95">file</a>)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::string </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe15">lookup</a> (const std::string &<a class="el" href="a04560.html#a1">filename</a>, bool throwException=true, bool displayWarning=true, bool lookupInLocalDirectory=true)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe16">makePathRelative</a> (const char *basePath, std::string &relativePath)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe17">memoryCompress</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe18">memoryUncompress</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe19">remapExtension</a> (const std::string &ext1, const std::string &ext2, bool substitute)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe20">remapFile</a> (const std::string &file1, const std::string &file2)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe21">removeAllAlternativeSearchPath</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe22">setCurrentPath</a> (const char *)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::string </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe23">standardizeDosPath</a> (const std::string &path)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::string </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a> (const std::string &path, bool addFinalSlash=true)</td></tr> + +<tr><td colspan=2><br><h2>Private Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top> </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a04558.html#a14">sint</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathd1">findExtension</a> (const std::string &ext1, const std::string &ext2)</td></tr> + +<tr><td colspan=2><br><h2>Static Private Member Functions</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03072.html">CPath</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathh0">getInstance</a> ()</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>void </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathh1">insertFileInMap</a> (const std::string &<a class="el" href="a04560.html#a1">filename</a>, const std::string &filepath, bool remap, const std::string &extension)</td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03075.html">CMCFileEntry</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathh2">MCfind</a> (const std::string &<a class="el" href="a04560.html#a1">filename</a>)</td></tr> + +<tr><td colspan=2><br><h2>Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>char * </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr0">_AllFileNames</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< std::string > </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr1">_AlternativePaths</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< std::pair< std::string,<br> + std::string > > </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr2">_Extensions</a></td></tr> + +<tr><td class="mdescLeft"> </td><td class="mdescRight">first ext1, second ext2 (ext1 could remplace ext2) <a href="#NLMISC_1_1CPathr2"></a><br><br></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top>std::map< std::string, <a class="el" href="a03073.html">CFileEntry</a> > </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr3">_Files</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< <a class="el" href="a03075.html">CMCFileEntry</a> > </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr4">_MCFiles</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>bool </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr5">_MemoryCompressed</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::map< std::string, std::string > </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr6">_RemappedFiles</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top>std::vector< std::string > </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr7">IgnoredFiles</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03441.html">CStaticStringMapper</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr8">SSMext</a></td></tr> + +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03441.html">CStaticStringMapper</a> </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathr9">SSMpath</a></td></tr> + +<tr><td colspan=2><br><h2>Static Private Attributes</h2></td></tr> +<tr><td class="memItemLeft" nowrap align=right valign=top><a class="el" href="a03072.html">CPath</a> * </td><td class="memItemRight" valign=bottom><a class="el" href="a03072.html#NLMISC_1_1CPathv0">_Instance</a> = NULL</td></tr> + +</table> +<hr><h2>Constructor & Destructor Documentation</h2> +<a class="anchor" name="NLMISC_1_1CPathd0" doxytag="NLMISC::CPath::CPath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> NLMISC::CPath::CPath </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline, private]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00223">223</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +References <a class="el" href="a06168.html#l00239">_MemoryCompressed</a>. +<p> +<div class="fragment"><pre>00224 { +00225 <a class="code" href="a03072.html#NLMISC_1_1CPathr5">_MemoryCompressed</a> = <span class="keyword">false</span>; +00226 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Member Function Documentation</h2> +<a class="anchor" name="NLMISC_1_1CPathe0" doxytag="NLMISC::CPath::addIgnoredDoubleFile" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::addIgnoredDoubleFile </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>ignoredFile</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +If File in this list is added more than one in an addSearchPath, it doesn't launch a warning. +<p> +Definition at line <a class="el" href="a06167.html#l01133">1133</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>. +<p> +<div class="fragment"><pre>01134 { +01135 NL_ALLOC_CONTEXT (MiPath); +01136 CPath::getInstance ()->IgnoredFiles.push_back(ignoredFile); +01137 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe1" doxytag="NLMISC::CPath::addSearchBigFile" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::addSearchBigFile </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>filename</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>recurse</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>alternative</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>class <a class="el" href="a03873.html">NLMISC::IProgressCallback</a> * </td> + <td class="mdname" nowrap> <em>progressCallBack</em> = NULL</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Same as AddSearchPath but with a big file "c:/test.nbf" all files name contain in the big file will be included (the extention (Nel Big File) is used to know that it's a big file) +<p> +Definition at line <a class="el" href="a06167.html#l01025">1025</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a05622.html#l00135">nlwarning</a>. +<p> +<div class="fragment"><pre>01026 { +01027 <span class="comment">//#ifndef NL_OS_WINDOWS</span> +01028 <span class="comment">// nlerror( "BNP currently not supported on Unix" ); // test of BNP failed on Linux</span> +01029 <span class="comment">//#endif</span> +01030 +01031 <span class="comment">// Check if filename is not empty</span> +01032 <span class="keywordflow">if</span> (sBigFilename.empty()) +01033 { +01034 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchBigFile(%s, %d, %d): can't add empty file, skip it"</span>, sBigFilename.c_str(), recurse, alternative); +01035 <span class="keywordflow">return</span>; +01036 } +01037 <span class="comment">// Check if the file exists</span> +01038 <span class="keywordflow">if</span> (!CFile::isExists (sBigFilename)) +01039 { +01040 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchBigFile(%s, %d, %d): '%s' is not found, skip it"</span>, sBigFilename.c_str(), recurse, alternative, sBigFilename.c_str()); +01041 <span class="keywordflow">return</span>; +01042 } +01043 <span class="comment">// Check if it s a file</span> +01044 <span class="keywordflow">if</span> (CFile::isDirectory (sBigFilename)) +01045 { +01046 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchBigFile(%s, %d, %d): '%s' is not a file, skip it"</span>, sBigFilename.c_str(), recurse, alternative, sBigFilename.c_str()); +01047 <span class="keywordflow">return</span>; +01048 } +01049 <span class="comment">// Open and read the big file header</span> +01050 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +01051 <a class="code" href="a04199.html#a6">nlassert</a>(!inst->_MemoryCompressed); +01052 +01053 FILE *Handle = fopen (sBigFilename.c_str(), <span class="stringliteral">"rb"</span>); +01054 <span class="keywordflow">if</span> (Handle == NULL) +01055 { +01056 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchBigFile(%s, %d, %d): can't open file, skip it"</span>, sBigFilename.c_str(), recurse, alternative); +01057 <span class="keywordflow">return</span>; +01058 } +01059 +01060 <span class="comment">// add the link with the CBigFile singleton</span> +01061 <span class="keywordflow">if</span> (<a class="code" href="a02261.html#NLMISC_1_1CBigFilee0">CBigFile::getInstance</a>().<a class="code" href="a02261.html#NLMISC_1_1CBigFilea0">add</a> (sBigFilename, BF_ALWAYS_OPENED | BF_CACHE_FILE_ON_OPEN)) +01062 { +01063 <span class="comment">// also add the bigfile name in the map to retreive the full path of a .bnp when we want modification date of the bnp for example</span> +01064 <a class="code" href="a03072.html#NLMISC_1_1CPathh1">insertFileInMap</a> (CFile::getFilename (sBigFilename), sBigFilename, <span class="keyword">false</span>, CFile::getExtension(sBigFilename)); +01065 +01066 <span class="comment">// parse the big file to add file in the map</span> +01067 <a class="code" href="a04558.html#a11">uint32</a> nFileSize=CFile::getFileSize (Handle); +01068 <span class="comment">//nlfseek64 (Handle, 0, SEEK_END);</span> +01069 <span class="comment">//uint32 nFileSize = ftell (Handle);</span> +01070 <a class="code" href="a05378.html#a284">nlfseek64</a> (Handle, nFileSize-4, SEEK_SET); +01071 <a class="code" href="a04558.html#a11">uint32</a> nOffsetFromBegining; +01072 fread (&nOffsetFromBegining, <span class="keyword">sizeof</span>(<a class="code" href="a04558.html#a11">uint32</a>), 1, Handle); +01073 <a class="code" href="a05378.html#a284">nlfseek64</a> (Handle, nOffsetFromBegining, SEEK_SET); +01074 <a class="code" href="a04558.html#a11">uint32</a> nNbFile; +01075 fread (&nNbFile, <span class="keyword">sizeof</span>(<a class="code" href="a04558.html#a11">uint32</a>), 1, Handle); +01076 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a11">uint32</a> i = 0; i < nNbFile; ++i) +01077 { +01078 <span class="comment">// Progress bar</span> +01079 <span class="keywordflow">if</span> (progressCallBack) +01080 { +01081 progressCallBack->progress ((<span class="keywordtype">float</span>)i/(<span class="keywordtype">float</span>)nNbFile); +01082 progressCallBack->pushCropedValues ((<span class="keywordtype">float</span>)i/(<span class="keywordtype">float</span>)nNbFile, (<span class="keywordtype">float</span>)(i+1)/(<span class="keywordtype">float</span>)nNbFile); +01083 } +01084 +01085 <span class="keywordtype">char</span> FileName[256]; +01086 <a class="code" href="a04558.html#a7">uint8</a> nStringSize; +01087 fread (&nStringSize, 1, 1, Handle); +01088 fread (FileName, 1, nStringSize, Handle); +01089 FileName[nStringSize] = 0; +01090 <a class="code" href="a04558.html#a11">uint32</a> nFileSize2; +01091 fread (&nFileSize2, <span class="keyword">sizeof</span>(<a class="code" href="a04558.html#a11">uint32</a>), 1, Handle); +01092 <a class="code" href="a04558.html#a11">uint32</a> nFilePos; +01093 fread (&nFilePos, <span class="keyword">sizeof</span>(<a class="code" href="a04558.html#a11">uint32</a>), 1, Handle); +01094 string sTmp = <a class="code" href="a05378.html#a273">strlwr</a>(string(FileName)); +01095 <span class="keywordflow">if</span> (sTmp.empty()) +01096 { +01097 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchBigFile(%s, %d, %d): can't add empty file, skip it"</span>, sBigFilename.c_str(), recurse, alternative); +01098 <span class="keywordflow">continue</span>; +01099 } +01100 string bigfilenamealone = CFile::getFilename (sBigFilename); +01101 string filenamewoext = CFile::getFilenameWithoutExtension (sTmp); +01102 string ext = <a class="code" href="a05378.html#a273">strlwr</a>(CFile::getExtension(sTmp)); +01103 +01104 <a class="code" href="a03072.html#NLMISC_1_1CPathh1">insertFileInMap</a> (sTmp, bigfilenamealone + <span class="stringliteral">"</span><span class="stringliteral">@" + sTmp, false, ext); + + for (uint j = 0; j < inst->_Extensions.size (); j++) + { + if (inst->_Extensions[j].first == ext) + { + // need to remap + insertFileInMap (filenamewoext+"</span>."+inst->_Extensions[j].second, +01105 bigfilenamealone + <span class="stringliteral">"</span><span class="stringliteral">@" + sTmp, + true, + inst->_Extensions[j].first); + } + } + + // Progress bar + if (progressCallBack) + { + progressCallBack->popCropedValues (); + } + } + } + else + { + nlwarning ("</span>PATH: CPath::addSearchBigFile(%s, %d, %d): can't add the big file", sBigFilename.c_str(), recurse, alternative); +01106 } +01107 +01108 fclose (Handle); +01109 } +01110 </pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe2" doxytag="NLMISC::CPath::addSearchFile" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::addSearchFile </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>file</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>remap</em> = false, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const std::string & </td> + <td class="mdname" nowrap> <em>virtual_ext</em> = "", </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>class <a class="el" href="a03873.html">NLMISC::IProgressCallback</a> * </td> + <td class="mdname" nowrap> <em>progressCallBack</em> = NULL</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Same as AddSearchPath but with a file "c:/autoexec.bat" this file only will included. wildwards *doesn't* work +<p> +Definition at line <a class="el" href="a06167.html#l00929">929</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a05538.html#l02654">file</a>. +<p> +<div class="fragment"><pre>00930 { +00931 NL_ALLOC_CONTEXT (MiPath); +00932 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00933 <a class="code" href="a04199.html#a6">nlassert</a>(!inst->_MemoryCompressed); +00934 +00935 string newFile = <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a>(file, <span class="keyword">false</span>); +00936 +00937 <span class="comment">// check empty file</span> +00938 <span class="keywordflow">if</span> (newFile.empty()) +00939 { +00940 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchFile(%s, %d, %s): can't add empty file, skip it"</span>, <a class="code" href="a04115.html#a95">file</a>.c_str(), remap, virtual_ext.c_str()); +00941 <span class="keywordflow">return</span>; +00942 } +00943 +00944 <span class="comment">// check if the file exists</span> +00945 <span class="keywordflow">if</span> (!CFile::isExists (newFile)) +00946 { +00947 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchFile(%s, %d, %s): '%s' is not found, skip it"</span>, <a class="code" href="a04115.html#a95">file</a>.c_str(), remap, virtual_ext.c_str(), newFile.c_str()); +00948 <span class="keywordflow">return</span>; +00949 } +00950 +00951 <span class="comment">// check if it s a file</span> +00952 <span class="keywordflow">if</span> (CFile::isDirectory (newFile)) +00953 { +00954 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchFile(%s, %d, %s): '%s' is not a file, skip it"</span>, <a class="code" href="a04115.html#a95">file</a>.c_str(), remap, virtual_ext.c_str(), newFile.c_str()); +00955 <span class="keywordflow">return</span>; +00956 } +00957 +00958 <span class="comment">// check if it s a big file</span> +00959 <span class="keywordflow">if</span> (CFile::getExtension(newFile) == <span class="stringliteral">"bnp"</span>) +00960 { +00961 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a> (<span class="stringliteral">"PATH: CPath::addSearchFile(%s, %d, %s): '%s' is a big file, add it"</span>, <a class="code" href="a04115.html#a95">file</a>.c_str(), remap, virtual_ext.c_str(), newFile.c_str()); +00962 <a class="code" href="a03072.html#NLMISC_1_1CPathe1">addSearchBigFile</a>(file, <span class="keyword">false</span>, <span class="keyword">false</span>, progressCallBack); +00963 <span class="keywordflow">return</span>; +00964 } +00965 +00966 string filenamewoext = CFile::getFilenameWithoutExtension (newFile); +00967 string <a class="code" href="a05377.html#a2">filename</a>, ext; +00968 +00969 <span class="keywordflow">if</span> (virtual_ext.empty()) +00970 { +00971 <a class="code" href="a05377.html#a2">filename</a> = CFile::getFilename (newFile); +00972 ext = CFile::getExtension (filename); +00973 } +00974 <span class="keywordflow">else</span> +00975 { +00976 <a class="code" href="a05377.html#a2">filename</a> = filenamewoext + <span class="stringliteral">"."</span> + virtual_ext; +00977 ext = CFile::getExtension (newFile); +00978 } +00979 +00980 <a class="code" href="a03072.html#NLMISC_1_1CPathh1">insertFileInMap</a> (filename, newFile, remap, ext); +00981 +00982 <span class="keywordflow">if</span> (!remap && !ext.empty()) +00983 { +00984 <span class="comment">// now, we have to see extension and insert in the map the remapped files</span> +00985 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < inst->_Extensions.size (); i++) +00986 { +00987 <span class="keywordflow">if</span> (inst->_Extensions[i].first == <a class="code" href="a05378.html#a273">strlwr</a>(ext)) +00988 { +00989 <span class="comment">// need to remap</span> +00990 <a class="code" href="a03072.html#NLMISC_1_1CPathe2">addSearchFile</a> (newFile, <span class="keyword">true</span>, inst->_Extensions[i].second, progressCallBack); +00991 } +00992 } +00993 } +00994 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe3" doxytag="NLMISC::CPath::addSearchListFile" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::addSearchListFile </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>filename</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>recurse</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>alternative</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Same as AddSearchPath but with a path file "c:/test.pth" all files name contain in this file will be included (the extention is used to know that it's a path file) +<p> +Definition at line <a class="el" href="a06167.html#l00996">996</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +<div class="fragment"><pre>00997 { +00998 NL_ALLOC_CONTEXT (MiPath); +00999 <span class="comment">// check empty file</span> +01000 <span class="keywordflow">if</span> (<a class="code" href="a05377.html#a2">filename</a>.empty()) +01001 { +01002 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchListFile(%s, %d, %d): can't add empty file, skip it"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str(), recurse, alternative); +01003 <span class="keywordflow">return</span>; +01004 } +01005 +01006 <span class="comment">// check if the file exists</span> +01007 <span class="keywordflow">if</span> (!CFile::isExists (filename)) +01008 { +01009 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchListFile(%s, %d, %d): '%s' is not found, skip it"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str(), recurse, alternative, <a class="code" href="a05377.html#a2">filename</a>.c_str()); +01010 <span class="keywordflow">return</span>; +01011 } +01012 +01013 <span class="comment">// check if it s a file</span> +01014 <span class="keywordflow">if</span> (CFile::isDirectory (filename)) +01015 { +01016 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchListFile(%s, %d, %d): '%s' is not a file, skip it"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str(), recurse, alternative, <a class="code" href="a05377.html#a2">filename</a>.c_str()); +01017 <span class="keywordflow">return</span>; +01018 } +01019 +01020 <span class="comment">// TODO lire le fichier et ajouter les fichiers qui sont dedans</span> +01021 +01022 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe4" doxytag="NLMISC::CPath::addSearchPath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::addSearchPath </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>path</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline, static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Used only for compatibility with the old <a class="el" href="a03072.html">CPath</a>. In this case, we don't use the map to have the same behavior as the old <a class="el" href="a03072.html">CPath</a> +<p> +Definition at line <a class="el" href="a06168.html#l00078">78</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +References <a class="el" href="a06167.html#l00807">addSearchPath()</a>. +<p> +<div class="fragment"><pre>00078 { <a class="code" href="a03072.html#NLMISC_1_1CPathe5">addSearchPath</a> (path, <span class="keyword">false</span>, <span class="keyword">true</span>, NULL); } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe5" doxytag="NLMISC::CPath::addSearchPath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::addSearchPath </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>path</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>recurse</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>alternative</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>class <a class="el" href="a03873.html">IProgressCallback</a> * </td> + <td class="mdname" nowrap> <em>progressCallBack</em> = NULL</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Adds a search path. The path is a directory "c:/temp" all files in the directory will be included (and recursively if asked)<p> +Alternative directories are not precached (instead of non Alternative files) and will used when a file is not found in the standard directories. For example, local data will be in the cached directories and server repository files will be in the Alternative files. If a new file is not found in the local data, we'll try to find it on the repositrory.<p> +When Alternative is false, all added file names must be uniq or a warning will be display. In the Alternative directories, it could have more than one file with the same name.<p> +<dl compact><dt><b>Warning:</b></dt><dd>the path you provide is case sensitive, you must be sure that the path name is exactly the same</dd></dl> +<dl compact><dt><b>Parameters:</b></dt><dd> + <table border="0" cellspacing="2" cellpadding="0"> + <tr><td valign=top><em>path</em> </td><td>the path name. The separator for directories could be '/' or '\' (bit '\' will be translate into '/' in the function). </td></tr> + <tr><td valign=top><em>recurse</em> </td><td>true if you want the function recurse in sub-directories. </td></tr> + <tr><td valign=top><em>Alternative</em> </td><td>true if you want to add the path in the Alternative directories. </td></tr> + <tr><td valign=top><em>progressCallBack</em> </td><td>is a progression callback interface pointer.</td></tr> + </table> +</dl> + +<p> +Definition at line <a class="el" href="a06167.html#l00807">807</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +Referenced by <a class="el" href="a06168.html#l00078">addSearchPath()</a>. +<p> +<div class="fragment"><pre>00808 { +00809 NL_ALLOC_CONTEXT (MiPath); +00810 <a class="code" href="a04365.html#a5">H_AUTO_INST</a>(addSearchPath); +00811 +00812 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00813 <a class="code" href="a04199.html#a6">nlassert</a>(!inst->_MemoryCompressed); +00814 +00815 <span class="comment">// check empty directory</span> +00816 <span class="keywordflow">if</span> (path.empty()) +00817 { +00818 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchPath(%s, %d, %d): can't add empty directory, skip it"</span>, path.c_str(), recurse, alternative); +00819 <span class="keywordflow">return</span>; +00820 } +00821 +00822 <span class="comment">// check if it s a directory</span> +00823 <span class="keywordflow">if</span> (!CFile::isDirectory (path)) +00824 { +00825 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: CPath::addSearchPath(%s, %d, %d): '%s' is not a directory, I'll call addSearchFile()"</span>, path.c_str(), recurse, alternative, path.c_str()); +00826 <a class="code" href="a03072.html#NLMISC_1_1CPathe2">addSearchFile</a> (path, <span class="keyword">false</span>, <span class="stringliteral">""</span>, progressCallBack); +00827 <span class="keywordflow">return</span>; +00828 } +00829 +00830 string newPath = <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a>(path); +00831 +00832 <span class="comment">// check if it s a directory</span> +00833 <span class="keywordflow">if</span> (!CFile::isExists (newPath)) +00834 { +00835 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchPath(%s, %d, %d): '%s' is not found, skip it"</span>, path.c_str(), recurse, alternative, newPath.c_str()); +00836 <span class="keywordflow">return</span>; +00837 } +00838 +00839 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: CPath::addSearchPath(%s, %d, %d): adding the path '%s'"</span>, path.c_str(), recurse, alternative, newPath.c_str()); +00840 +00841 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::addSearchPath(%s, %d, %d): try to add '%s'"</span>, path.c_str(), recurse, alternative, newPath.c_str()); +00842 +00843 <span class="keywordflow">if</span> (alternative) +00844 { +00845 vector<string> pathsToProcess; +00846 +00847 <span class="comment">// add the current path</span> +00848 pathsToProcess.push_back (newPath); +00849 +00850 <span class="keywordflow">if</span> (recurse) +00851 { +00852 <span class="comment">// find all path and subpath</span> +00853 <a class="code" href="a03072.html#NLMISC_1_1CPathe12">getPathContent</a> (newPath, recurse, <span class="keyword">true</span>, <span class="keyword">false</span>, pathsToProcess, progressCallBack); +00854 } +00855 +00856 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> p = 0; p < pathsToProcess.size(); p++) +00857 { +00858 <span class="comment">// check if the path not already in the vector</span> +00859 <a class="code" href="a04558.html#a15">uint</a> i; +00860 <span class="keywordflow">for</span> (i = 0; i < inst->_AlternativePaths.size(); i++) +00861 { +00862 <span class="keywordflow">if</span> (inst->_AlternativePaths[i] == pathsToProcess[p]) +00863 <span class="keywordflow">break</span>; +00864 } +00865 <span class="keywordflow">if</span> (i == inst->_AlternativePaths.size()) +00866 { +00867 <span class="comment">// add them in the alternative directory</span> +00868 inst->_AlternativePaths.push_back (pathsToProcess[p]); +00869 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::addSearchPath(%s, %d, %d): path '%s' added"</span>, newPath.c_str(), recurse, alternative, pathsToProcess[p].c_str()); +00870 } +00871 <span class="keywordflow">else</span> +00872 { +00873 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::addSearchPath(%s, %d, %d): path '%s' already added"</span>, newPath.c_str(), recurse, alternative, pathsToProcess[p].c_str()); +00874 } +00875 } +00876 } +00877 <span class="keywordflow">else</span> +00878 { +00879 vector<string> filesToProcess; +00880 +00881 <span class="comment">// Progree bar</span> +00882 <span class="keywordflow">if</span> (progressCallBack) +00883 { +00884 progressCallBack->progress (0); +00885 progressCallBack->pushCropedValues (0, 0.5f); +00886 } +00887 +00888 <span class="comment">// find all files in the path and subpaths</span> +00889 <a class="code" href="a03072.html#NLMISC_1_1CPathe12">getPathContent</a> (newPath, recurse, <span class="keyword">false</span>, <span class="keyword">true</span>, filesToProcess, progressCallBack); +00890 +00891 <span class="comment">// Progree bar</span> +00892 <span class="keywordflow">if</span> (progressCallBack) +00893 { +00894 progressCallBack->popCropedValues (); +00895 progressCallBack->progress (0.5); +00896 progressCallBack->pushCropedValues (0.5f, 1); +00897 } +00898 +00899 <span class="comment">// add them in the map</span> +00900 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> f = 0; f < filesToProcess.size(); f++) +00901 { +00902 <span class="comment">// Progree bar</span> +00903 <span class="keywordflow">if</span> (progressCallBack) +00904 { +00905 progressCallBack->progress ((<span class="keywordtype">float</span>)f/(<span class="keywordtype">float</span>)filesToProcess.size()); +00906 progressCallBack->pushCropedValues ((<span class="keywordtype">float</span>)f/(<span class="keywordtype">float</span>)filesToProcess.size(), (<span class="keywordtype">float</span>)(f+1)/(<span class="keywordtype">float</span>)filesToProcess.size()); +00907 } +00908 +00909 string <a class="code" href="a05377.html#a2">filename</a> = CFile::getFilename (filesToProcess[f]); +00910 string filepath = CFile::getPath (filesToProcess[f]); +00911 <span class="comment">// insertFileInMap (filename, filepath, false, CFile::getExtension(filename));</span> +00912 <a class="code" href="a03072.html#NLMISC_1_1CPathe2">addSearchFile</a> (filesToProcess[f], <span class="keyword">false</span>, <span class="stringliteral">""</span>, progressCallBack); +00913 +00914 <span class="comment">// Progree bar</span> +00915 <span class="keywordflow">if</span> (progressCallBack) +00916 { +00917 progressCallBack->popCropedValues (); +00918 } +00919 } +00920 +00921 <span class="comment">// Progree bar</span> +00922 <span class="keywordflow">if</span> (progressCallBack) +00923 { +00924 progressCallBack->popCropedValues (); +00925 } +00926 } +00927 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe6" doxytag="NLMISC::CPath::clearMap" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::clearMap </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Clears the map that contains all cached files (Use this function to take into account new files). +<p> +Definition at line <a class="el" href="a06167.html#l00153">153</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a06168.html#l00254">_Files</a>, <a class="el" href="a06168.html#l00239">_MemoryCompressed</a>, <a class="el" href="a06167.html#l00071">NL_DISPLAY_PATH</a>, and <a class="el" href="a05622.html#l00290">nlassert</a>. +<p> +<div class="fragment"><pre>00154 { +00155 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00156 <a class="code" href="a04199.html#a6">nlassert</a>(!inst->_MemoryCompressed); +00157 inst->_Files.clear (); +00158 <a class="code" href="a02261.html#NLMISC_1_1CBigFilee0">CBigFile::getInstance</a>().<a class="code" href="a02261.html#NLMISC_1_1CBigFilea6">removeAll</a> (); +00159 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::clearMap(): map directory cleared"</span>); +00160 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe7" doxytag="NLMISC::CPath::display" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::display </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06167.html#l01195">1195</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +<div class="fragment"><pre>01196 { +01197 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance (); +01198 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: Contents of the map:"</span>); +01199 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: %-25s %-5s %-5s %s"</span>, <span class="stringliteral">"filename"</span>, <span class="stringliteral">"ext"</span>, <span class="stringliteral">"remap"</span>, <span class="stringliteral">"full path"</span>); +01200 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: ----------------------------------------------------"</span>); +01201 <span class="keywordflow">if</span> (inst->_MemoryCompressed) +01202 { +01203 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < inst->_MCFiles.size(); ++i) +01204 { +01205 <span class="keyword">const</span> CMCFileEntry &fe = inst->_MCFiles[i]; +01206 string ext = inst->SSMext.get(fe.idExt); +01207 string path = inst->SSMpath.get(fe.idPath); +01208 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: %-25s %-5s %-5d %s"</span>, fe.Name, ext.c_str(), fe.Remapped, path.c_str()); +01209 } +01210 } +01211 <span class="keywordflow">else</span> +01212 { +01213 <span class="keywordflow">for</span> (map<string, CFileEntry>::iterator it = inst->_Files.begin(); it != inst->_Files.end (); it++) +01214 { +01215 string ext = inst->SSMext.get((*it).second.idExt); +01216 string path = inst->SSMpath.get((*it).second.idPath); +01217 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: %-25s %-5s %-5d %s"</span>, (*it).first.c_str(), ext.c_str(), (*it).second.Remapped, path.c_str()); +01218 } +01219 } +01220 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: "</span>); +01221 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: Contents of the alternative directory:"</span>); +01222 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < inst->_AlternativePaths.size(); i++) +01223 { +01224 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: '%s'"</span>, inst->_AlternativePaths[i].c_str ()); +01225 } +01226 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: "</span>); +01227 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: Contents of the remapped entension table:"</span>); +01228 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> j = 0; j < inst->_Extensions.size(); j++) +01229 { +01230 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: '%s' -> '%s'"</span>, inst->_Extensions[j].first.c_str (), inst->_Extensions[j].second.c_str ()); +01231 } +01232 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: End of display"</span>); +01233 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe8" doxytag="NLMISC::CPath::exists" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPath::exists </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>filename</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Return if a file is present in the lookup map. The function changes filename into lower case and removes ended spaces before searching.<p> +<dl compact><dt><b>Warning:</b></dt><dd>This function checks *only* in the map, not in local dir or alternative dir</dd></dl> +<dl compact><dt><b>Parameters:</b></dt><dd> + <table border="0" cellspacing="2" cellpadding="0"> + <tr><td valign=top><em>filename</em> </td><td>the file name you are seeking. (ex: "test.txt") </td></tr> + <tr><td valign=top><em>lookupInLocalDirectory</em> </td><td>if true, the <a class="el" href="a03072.html#NLMISC_1_1CPathe15">lookup()</a> will first try to open the file without path. </td></tr> + </table> +</dl> +<dl compact><dt><b>Returns:</b></dt><dd>true if the filename exists in the map used by lookup to know where the file is, false otherwise</dd></dl> + +<p> +Definition at line <a class="el" href="a06167.html#l00421">421</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +<div class="fragment"><pre>00422 { +00423 <span class="comment">// Try to find in the map directories</span> +00424 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00425 string str = <a class="code" href="a05378.html#a273">strlwr</a>(filename); +00426 +00427 <span class="comment">// Remove end spaces</span> +00428 <span class="keywordflow">while</span> ((!str.empty()) && (str[str.size()-1] == <span class="charliteral">' '</span>)) +00429 { +00430 str.resize (str.size()-1); +00431 } +00432 +00433 +00434 <span class="keywordflow">if</span> (inst->_MemoryCompressed) +00435 { +00436 CMCFileEntry *pMCFE = <a class="code" href="a03072.html#NLMISC_1_1CPathh2">MCfind</a>(str); +00437 <span class="comment">// If found in the vector, returns it</span> +00438 <span class="keywordflow">if</span> (pMCFE != NULL) +00439 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00440 } +00441 <span class="keywordflow">else</span> +00442 { +00443 map<string, CFileEntry>::iterator it = inst->_Files.find (str); +00444 <span class="comment">// If found in the map, returns it</span> +00445 <span class="keywordflow">if</span> (it != inst->_Files.end()) +00446 <span class="keywordflow">return</span> <span class="keyword">true</span>; +00447 } +00448 +00449 <span class="keywordflow">return</span> <span class="keyword">false</span>; +00450 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathd1" doxytag="NLMISC::CPath::findExtension" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a04558.html#a14">sint</a> NLMISC::CPath::findExtension </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>ext1</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const std::string & </td> + <td class="mdname" nowrap> <em>ext2</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [private]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06167.html#l00177">177</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a06168.html#l00302">_Extensions</a>, <a class="el" href="a05981.html#l00104">sint</a>, and <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00190">remapExtension()</a>. +<p> +<div class="fragment"><pre>00178 { +00179 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00180 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < inst->_Extensions.size (); i++) +00181 { +00182 <span class="keywordflow">if</span> (inst->_Extensions[i].first == ext1 && inst->_Extensions[i].second == ext2) +00183 { +00184 <span class="keywordflow">return</span> i; +00185 } +00186 } +00187 <span class="keywordflow">return</span> -1; +00188 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe9" doxytag="NLMISC::CPath::getCurrentPath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::string NLMISC::CPath::getCurrentPath </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Returns the current path of the applicated. +<p> +Definition at line <a class="el" href="a06167.html#l00504">504</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a05646.html#l00649">buffer</a>. +<p> +<div class="fragment"><pre>00505 { +00506 <span class="keywordtype">char</span> <a class="code" href="a04223.html#a589">buffer</a> [10000]; +00507 +00508 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span> +00509 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a>(_getcwd(buffer, 10000), <span class="keyword">false</span>); +00510 <span class="preprocessor">#else</span> +00511 <span class="preprocessor"></span> <span class="keywordflow">return</span> <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a>(getcwd(buffer, 10000), <span class="keyword">false</span>); +00512 <span class="preprocessor">#endif</span> +00513 <span class="preprocessor"></span>} +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe10" doxytag="NLMISC::CPath::getFileList" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::getFileList </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>extension</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>std::vector< std::string > & </td> + <td class="mdname" nowrap> <em>filenames</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Create a list of file having the requested extension. +<p> +Definition at line <a class="el" href="a06167.html#l00087">87</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a06168.html#l00254">_Files</a>, <a class="el" href="a06168.html#l00270">_MCFiles</a>, <a class="el" href="a06168.html#l00239">_MemoryCompressed</a>, <a class="el" href="a06469.html#l00167">NLMISC::CStaticStringMapper::get()</a>, <a class="el" href="a06167.html#l00142">getInstance()</a>, and <a class="el" href="a06168.html#l00240">SSMext</a>. +<p> +Referenced by <a class="el" href="a05926.html#l00522">loadForm()</a>. +<p> +<div class="fragment"><pre>00088 { +00089 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = <a class="code" href="a03072.html#NLMISC_1_1CPathh0">getInstance</a>(); +00090 +00091 <span class="keywordflow">if</span> (!inst->_MemoryCompressed) +00092 { +00093 std::map<std::string, CFileEntry>::iterator first(inst->_Files.begin()), last(inst->_Files.end()); +00094 +00095 <span class="keywordflow">if</span>( !extension.empty() ) +00096 { +00097 <span class="keywordflow">for</span> (; first != last; ++ first) +00098 { +00099 string ext = inst->SSMext.get(first->second.idExt); +00100 <span class="keywordflow">if</span> (ext == extension) +00101 { +00102 filenames.push_back(first->first); +00103 } +00104 } +00105 } +00106 <span class="comment">// if extension is empty we keep all files</span> +00107 <span class="keywordflow">else</span> +00108 { +00109 <span class="keywordflow">for</span> (; first != last; ++ first) +00110 { +00111 filenames.push_back(first->first); +00112 } +00113 } +00114 } +00115 <span class="keywordflow">else</span> +00116 { +00117 <span class="comment">// compressed memory version</span> +00118 std::vector<CPath::CMCFileEntry>::iterator first(inst->_MCFiles.begin()), last(inst->_MCFiles.end()); +00119 +00120 <span class="keywordflow">if</span>( !extension.empty() ) +00121 { +00122 <span class="keywordflow">for</span> (; first != last; ++ first) +00123 { +00124 string ext = inst->SSMext.get(first->idExt); +00125 <span class="keywordflow">if</span> (ext == extension) +00126 { +00127 filenames.push_back(first->Name); +00128 } +00129 } +00130 } +00131 <span class="comment">// if extension is empty we keep all files</span> +00132 <span class="keywordflow">else</span> +00133 { +00134 <span class="keywordflow">for</span> (; first != last; ++ first) +00135 { +00136 filenames.push_back(first->Name); +00137 } +00138 } +00139 } +00140 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe11" doxytag="NLMISC::CPath::getFullPath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::string NLMISC::CPath::getFullPath </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>path</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>addFinalSlash</em> = true</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Get the full path based on a file/path and the current directory. Example, imagine that the current path is c: and toto is a directory getFullPath ("toto") returns "c:/temp/toto/" getFullPath ("../toto") returns "c:/temp/../toto/" getFullPath ("d:\dir\toto") returns "d:/dir/toto/" getFullPath ("\toto") returns "c:/toto/" getFullPath ("") returns "c:/temp/"<p> +<dl compact><dt><b>Parameters:</b></dt><dd> + <table border="0" cellspacing="2" cellpadding="0"> + <tr><td valign=top><em>path</em> </td><td>the path </td></tr> + </table> +</dl> +<dl compact><dt><b>Returns:</b></dt><dd>the full path</dd></dl> + +<p> +Definition at line <a class="el" href="a06167.html#l00525">525</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +Referenced by <a class="el" href="a05597.html#l00297">NLMISC::CConfigFile::reparse()</a>. +<p> +<div class="fragment"><pre>00526 { +00527 string currentPath = <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a> (getCurrentPath ()); +00528 string sPath = <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a> (path, addFinalSlash); +00529 +00530 <span class="comment">// current path</span> +00531 <span class="keywordflow">if</span> (path.empty() || sPath == <span class="stringliteral">"."</span> || sPath == <span class="stringliteral">"./"</span>) +00532 { +00533 <span class="keywordflow">return</span> currentPath; +00534 } +00535 +00536 <span class="comment">// windows full path</span> +00537 <span class="keywordflow">if</span> (path.size() >= 2 && path[1] == <span class="charliteral">':'</span>) +00538 { +00539 <span class="keywordflow">return</span> sPath; +00540 } +00541 +00542 <span class="keywordflow">if</span> (path.size() >= 2 && (path[0] == <span class="charliteral">'/'</span> || path[0] == <span class="charliteral">'\\'</span>) && (path[1] == <span class="charliteral">'/'</span> || path[1] == <span class="charliteral">'\\'</span>)) +00543 { +00544 <span class="keywordflow">return</span> sPath; +00545 } +00546 +00547 +00548 <span class="comment">// from root</span> +00549 <span class="keywordflow">if</span> (path [0] == <span class="charliteral">'/'</span> || path[0] == <span class="charliteral">'\\'</span>) +00550 { +00551 <span class="keywordflow">if</span> (currentPath.size() > 2 && currentPath[1] == <span class="charliteral">':'</span>) +00552 { +00553 <span class="keywordflow">return</span> currentPath.substr(0,3) + sPath.substr(1); +00554 } +00555 <span class="keywordflow">else</span> +00556 { +00557 <span class="keywordflow">return</span> sPath; +00558 } +00559 } +00560 +00561 <span class="comment">// default case</span> +00562 <span class="keywordflow">return</span> currentPath + sPath; +00563 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathh0" doxytag="NLMISC::CPath::getInstance" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03072.html">CPath</a> * NLMISC::CPath::getInstance </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static, private]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06167.html#l00142">142</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00087">getFileList()</a>, and <a class="el" href="a06168.html#l00215">isMemoryCompressed()</a>. +<p> +<div class="fragment"><pre>00143 { +00144 <span class="keywordflow">if</span> (<a class="code" href="a03072.html#NLMISC_1_1CPathv0">_Instance</a> == NULL) +00145 { +00146 <span class="preprocessor">#undef new</span> +00147 <span class="preprocessor"></span> <a class="code" href="a03072.html#NLMISC_1_1CPathv0">_Instance</a> = <span class="keyword">new</span> <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a>; +00148 <span class="preprocessor">#define new NL_NEW</span> +00149 <span class="preprocessor"></span> } +00150 <span class="keywordflow">return</span> <a class="code" href="a03072.html#NLMISC_1_1CPathv0">_Instance</a>; +00151 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe12" doxytag="NLMISC::CPath::getPathContent" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::getPathContent </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>path</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>recurse</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>wantDir</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>wantFile</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>std::vector< std::string > & </td> + <td class="mdname" nowrap> <em>result</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>class <a class="el" href="a03873.html">IProgressCallback</a> * </td> + <td class="mdname" nowrap> <em>progressCallBack</em> = NULL, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>showEverything</em> = false</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +List all files in a directory. <dl compact><dt><b>Parameters:</b></dt><dd> + <table border="0" cellspacing="2" cellpadding="0"> + <tr><td valign=top><em>path</em> </td><td>path where files are scanned. No-op if empty </td></tr> + <tr><td valign=top><em>recurse</em> </td><td>true if want to recurs directories </td></tr> + <tr><td valign=top><em>wantDir</em> </td><td>true if want to add directorires in result </td></tr> + <tr><td valign=top><em>wantFile</em> </td><td>true if want to add files in result </td></tr> + <tr><td valign=top><em>result</em> </td><td>list of string where directories/files names are added. </td></tr> + <tr><td valign=top><em>progressCallBack</em> </td><td>is a progression callback interface pointer. </td></tr> + <tr><td valign=top><em>showEverything</em> </td><td>false skips *.log files and CVS directories</td></tr> + </table> +</dl> + +<p> +Definition at line <a class="el" href="a06167.html#l00688">688</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a06167.html#l00071">NL_DISPLAY_PATH</a>. +<p> +Referenced by <a class="el" href="a05449.html#l00155">NL3D::CAnimationSet::loadFromFiles()</a>. +<p> +<div class="fragment"><pre>00689 { +00690 <span class="keywordflow">if</span>( path.empty() ) +00691 { +00692 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::getPathContent(): Empty input Path"</span>); +00693 <span class="keywordflow">return</span>; +00694 } +00695 +00696 <span class="preprocessor">#ifndef NL_OS_WINDOWS</span> +00697 <span class="preprocessor"></span> <a class="code" href="a05378.html#a31">BasePathgetPathContent</a> = CPath::standardizePath (path); +00698 <span class="preprocessor">#endif</span> +00699 <span class="preprocessor"></span> +00700 DIR *dir = opendir (path.c_str()); +00701 +00702 <span class="keywordflow">if</span> (dir == NULL) +00703 { +00704 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::getPathContent(%s, %d, %d, %d): could not open the directory"</span>, path.c_str(), recurse, wantDir, wantFile); +00705 <span class="keywordflow">return</span>; +00706 } +00707 +00708 <span class="comment">// contains path that we have to recurs into</span> +00709 vector<string> recursPath; +00710 +00711 <span class="keywordflow">while</span> (<span class="keyword">true</span>) +00712 { +00713 dirent *de = readdir(dir); +00714 <span class="keywordflow">if</span> (de == NULL) +00715 { +00716 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::getPathContent(%s, %d, %d, %d): end of directory"</span>, path.c_str(), recurse, wantDir, wantFile); +00717 <span class="keywordflow">break</span>; +00718 } +00719 +00720 string fn = <a class="code" href="a05378.html#a343">getname</a> (de); +00721 +00722 <span class="comment">// skip . and ..</span> +00723 <span class="keywordflow">if</span> (fn == <span class="stringliteral">"."</span> || fn == <span class="stringliteral">".."</span>) +00724 <span class="keywordflow">continue</span>; +00725 +00726 <span class="keywordflow">if</span> (<a class="code" href="a05378.html#a341">isdirectory</a>(de)) +00727 { +00728 <span class="comment">// skip CVS directory</span> +00729 <span class="keywordflow">if</span> ((!showEverything) && (fn == <span class="stringliteral">"CVS"</span>)) +00730 { +00731 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::getPathContent(%s, %d, %d, %d): skip CVS directory"</span>, path.c_str(), recurse, wantDir, wantFile); +00732 <span class="keywordflow">continue</span>; +00733 } +00734 +00735 string stdName = <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a>(<a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a>(path) + fn); +00736 <span class="keywordflow">if</span> (recurse) +00737 { +00738 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::getPathContent(%s, %d, %d, %d): need to recurse into '%s'"</span>, path.c_str(), recurse, wantDir, wantFile, stdName.c_str()); +00739 recursPath.push_back (stdName); +00740 } +00741 +00742 <span class="keywordflow">if</span> (wantDir) +00743 { +00744 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::getPathContent(%s, %d, %d, %d): adding path '%s'"</span>, path.c_str(), recurse, wantDir, wantFile, stdName.c_str()); +00745 result.push_back (stdName); +00746 } +00747 } +00748 <span class="keywordflow">if</span> (wantFile && <a class="code" href="a05378.html#a342">isfile</a>(de)) +00749 { +00750 <span class="keywordflow">if</span> ( (!showEverything) && (fn.size() >= 4 && fn.substr (fn.size()-4) == <span class="stringliteral">".log"</span>)) +00751 { +00752 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::getPathContent(%s, %d, %d, %d): skip *.log files (%s)"</span>, path.c_str(), recurse, wantDir, wantFile, fn.c_str()); +00753 <span class="keywordflow">continue</span>; +00754 } +00755 +00756 <span class="comment">/* int lastSep = CFile::getLastSeparator(path);</span> +00757 <span class="comment"> #ifdef NL_OS_WINDOWS</span> +00758 <span class="comment"> char sep = lastSep == std::string::npos ? '\\'</span> +00759 <span class="comment"> : path[lastSep];</span> +00760 <span class="comment"> #else</span> +00761 <span class="comment"> char sep = lastSep == std::string::npos ? '/'</span> +00762 <span class="comment"> : path[lastSep];</span> +00763 <span class="comment"> #endif</span> +00764 <span class="comment">*/</span> +00765 string stdName = <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a>(path) + <a class="code" href="a05378.html#a343">getname</a>(de); +00766 +00767 +00768 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::getPathContent(%s, %d, %d, %d): adding file '%s'"</span>, path.c_str(), recurse, wantDir, wantFile, stdName.c_str()); +00769 result.push_back (stdName); +00770 } +00771 } +00772 +00773 closedir (dir); +00774 +00775 <span class="preprocessor">#ifndef NL_OS_WINDOWS</span> +00776 <span class="preprocessor"></span> <a class="code" href="a05378.html#a31">BasePathgetPathContent</a> = <span class="stringliteral">""</span>; +00777 <span class="preprocessor">#endif</span> +00778 <span class="preprocessor"></span> +00779 <span class="comment">// let s recurse</span> +00780 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < recursPath.size (); i++) +00781 { +00782 <span class="comment">// Progress bar</span> +00783 <span class="keywordflow">if</span> (progressCallBack) +00784 { +00785 progressCallBack->progress ((<span class="keywordtype">float</span>)i/(<span class="keywordtype">float</span>)recursPath.size ()); +00786 progressCallBack->pushCropedValues ((<span class="keywordtype">float</span>)i/(<span class="keywordtype">float</span>)recursPath.size (), (<span class="keywordtype">float</span>)(i+1)/(<span class="keywordtype">float</span>)recursPath.size ()); +00787 } +00788 +00789 <a class="code" href="a03072.html#NLMISC_1_1CPathe12">getPathContent</a> (recursPath[i], recurse, wantDir, wantFile, result, progressCallBack); +00790 +00791 <span class="comment">// Progress bar</span> +00792 <span class="keywordflow">if</span> (progressCallBack) +00793 { +00794 progressCallBack->popCropedValues (); +00795 } +00796 } +00797 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathh1" doxytag="NLMISC::CPath::insertFileInMap" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::insertFileInMap </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>filename</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const std::string & </td> + <td class="mdname" nowrap> <em>filepath</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>remap</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const std::string & </td> + <td class="mdname" nowrap> <em>extension</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static, private]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06167.html#l01139">1139</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00190">remapExtension()</a>. +<p> +<div class="fragment"><pre>01140 { +01141 NL_ALLOC_CONTEXT (MiPath); +01142 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +01143 <a class="code" href="a04199.html#a6">nlassert</a>(!inst->_MemoryCompressed); +01144 <span class="comment">// find if the file already exist</span> +01145 map<string, CFileEntry>::iterator it = inst->_Files.find (<a class="code" href="a05378.html#a273">strlwr</a>(filename)); +01146 <span class="keywordflow">if</span> (it != inst->_Files.end ()) +01147 { +01148 string path = inst->SSMpath.get((*it).second.idPath); +01149 <span class="keywordflow">if</span> (path.find(<span class="stringliteral">"</span><span class="stringliteral">@") != string::npos && filepath.find("</span><span class="stringliteral">@") == string::npos) + { + // if there's a file in a big file and a file in a path, the file in path wins + // replace with the new one + nlinfo ("</span>PATH: CPath::insertFileInMap(%s, %s, %d, %s): already inserted from '%s' but special case so overide it", <a class="code" href="a05377.html#a2">filename</a>.c_str(), filepath.c_str(), remap, extension.c_str(), path.c_str()); +01150 string sTmp = filepath.substr(0,filepath.rfind(<span class="charliteral">'/'</span>)+1); +01151 (*it).second.idPath = inst->SSMpath.add(sTmp); +01152 (*it).second.Remapped = remap; +01153 (*it).second.idExt = inst->SSMext.add(extension); +01154 (*it).second.Name = <a class="code" href="a05377.html#a2">filename</a>; +01155 } +01156 <span class="keywordflow">else</span> +01157 { +01158 <span class="keywordflow">for</span>(<a class="code" href="a04558.html#a15">uint</a> i = 0; i < inst->IgnoredFiles.size(); i++) +01159 { +01160 <span class="comment">// if we don't want to display a warning, skip it</span> +01161 <span class="keywordflow">if</span>(<a class="code" href="a05377.html#a2">filename</a> == inst->IgnoredFiles[i]) +01162 <span class="keywordflow">return</span>; +01163 } +01164 <span class="comment">// if the path is the same, don't warn</span> +01165 string path2 = inst->SSMpath.get((*it).second.idPath); +01166 string sPathOnly = filepath.substr(0,filepath.rfind(<span class="charliteral">'@'</span>)+1); +01167 <span class="keywordflow">if</span> (path2 == sPathOnly) +01168 <span class="keywordflow">return</span>; +01169 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::insertFileInMap(%s, %s, %d, %s): already inserted from '%s', skip it"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str(), filepath.c_str(), remap, extension.c_str(), path2.c_str()); +01170 } +01171 } +01172 <span class="keywordflow">else</span> +01173 { +01174 CFileEntry fe; +01175 fe.idExt = inst->SSMext.add(extension); +01176 fe.Remapped = remap; +01177 string sTmp; +01178 <span class="keywordflow">if</span> (filepath.find(<span class="stringliteral">"</span><span class="stringliteral">@") == string::npos) + sTmp = filepath.substr(0,filepath.rfind('/')+1); + else + sTmp = filepath.substr(0,filepath.rfind('@')+1); + + fe.idPath = inst->SSMpath.add(sTmp); + fe.Name = filename; + + inst->_Files.insert (make_pair(strlwr(filename), fe)); + NL_DISPLAY_PATH("</span>PATH: CPath::insertFileInMap(%s, %s, %d, %s): added", <a class="code" href="a05378.html#a273">strlwr</a>(filename).c_str(), filepath.c_str(), remap, <a class="code" href="a05378.html#a273">strlwr</a>(extension).c_str()); +01179 } +01180 } +01181 </pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe13" doxytag="NLMISC::CPath::isMemoryCompressed" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPath::isMemoryCompressed </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [inline, static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00215">215</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +References <a class="el" href="a06168.html#l00239">_MemoryCompressed</a>, and <a class="el" href="a06167.html#l00142">getInstance()</a>. +<p> +<div class="fragment"><pre>00215 { <span class="keywordflow">return</span> <a class="code" href="a03072.html#NLMISC_1_1CPathh0">getInstance</a>()->_MemoryCompressed; } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe14" doxytag="NLMISC::CPath::loadRemappedFiles" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::loadRemappedFiles </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>file</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Load a file containing the remapped file (you must have done addsearchpath, this method use lookup) Format is remapped_name_file, real_file separators are , and <br> + +<p> +Definition at line <a class="el" href="a06167.html#l00293">293</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a05708.html#l00349">NLMISC::CIFile::eof()</a>, <a class="el" href="a05538.html#l02654">file</a>, <a class="el" href="a05708.html#l00306">NLMISC::CIFile::getline()</a>, <a class="el" href="a06167.html#l00320">lookup()</a>, <a class="el" href="a05708.html#l00135">NLMISC::CIFile::open()</a>, <a class="el" href="a06167.html#l00270">remapFile()</a>, <a class="el" href="a06167.html#l00280">NLMISC::removeAllUnusedChar()</a>, and <a class="el" href="a05708.html#l00242">NLMISC::CIFile::setCacheFileOnOpen()</a>. +<p> +<div class="fragment"><pre>00294 { +00295 NL_ALLOC_CONTEXT (MiPath); +00296 string fullName = <a class="code" href="a03072.html#NLMISC_1_1CPathe15">lookup</a>(file, <span class="keyword">false</span>, <span class="keyword">true</span>, <span class="keyword">true</span>); +00297 <a class="code" href="a02653.html">CIFile</a> f; +00298 f.<a class="code" href="a02653.html#NLMISC_1_1CIFilea20">setCacheFileOnOpen</a> (<span class="keyword">true</span>); +00299 +00300 <span class="keywordflow">if</span> (!f.<a class="code" href="a02653.html#NLMISC_1_1CIFilea12">open</a> (fullName)) +00301 <span class="keywordflow">return</span>; +00302 +00303 <span class="keywordtype">char</span> sTmp[514]; +00304 string str; +00305 +00306 <span class="keywordflow">while</span> (!f.<a class="code" href="a02653.html#NLMISC_1_1CIFilea4">eof</a>()) +00307 { +00308 f.<a class="code" href="a02653.html#NLMISC_1_1CIFilea7">getline</a>(sTmp, 512); +00309 str = sTmp; +00310 <span class="keywordflow">if</span> (str.find(<span class="charliteral">','</span>)) +00311 { +00312 <a class="code" href="a05378.html#a340">removeAllUnusedChar</a>(str); +00313 <span class="keywordflow">if</span> (!str.empty()) +00314 <a class="code" href="a03072.html#NLMISC_1_1CPathe20">remapFile</a>( str.substr(0,str.find(<span class="charliteral">','</span>)), str.substr(str.find(<span class="charliteral">','</span>)+1, str.size()) ); +00315 } +00316 } +00317 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe15" doxytag="NLMISC::CPath::lookup" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> string NLMISC::CPath::lookup </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>filename</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>throwException</em> = true, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>displayWarning</em> = true, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>lookupInLocalDirectory</em> = true</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Returns the long name (path + filename) for the specified file. The directory separator is always '/'. First, the <a class="el" href="a03072.html#NLMISC_1_1CPathe15">lookup()</a> lookups in standard directories (Alternative=false). If not found, it lookups in the Alternative directories. If not found the <a class="el" href="a03072.html#NLMISC_1_1CPathe15">lookup()</a> returns empty string "" (and generate an exception if throwException is true)<p> +The filename is not case sensitive so if the real filename is "FooBAR.Jpg" and you call lookup("fOOBar.jPg"), it'll return the real filename "FooBAR.Jpg"<p> +<dl compact><dt><b>Parameters:</b></dt><dd> + <table border="0" cellspacing="2" cellpadding="0"> + <tr><td valign=top><em>filename</em> </td><td>the file name you are seeking. (ex: "test.txt") </td></tr> + <tr><td valign=top><em>throwException</em> </td><td>used for backward compatibility, set to true to generate an <a class="el" href="a03800.html">EPathNotFound</a>. </td></tr> + <tr><td valign=top><em>displayWarning</em> </td><td>set to false if you don't want the function displays a warning if the file is not found </td></tr> + <tr><td valign=top><em>lookupInLocalDirectory</em> </td><td>if true, the <a class="el" href="a03072.html#NLMISC_1_1CPathe15">lookup()</a> will first try to open the file without path. </td></tr> + </table> +</dl> +<dl compact><dt><b>Returns:</b></dt><dd>empty string if file is not found or the full path + file name (ex: "c:/temp/test.txt");</dd></dl> + +<p> +Definition at line <a class="el" href="a06167.html#l00320">320</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +Referenced by <a class="el" href="a05452.html#l00095">NL3D::CAnimationSetUser::addAnimation()</a>, <a class="el" href="a05465.html#l00358">NLSOUND::CAudioMixerUser::init()</a>, <a class="el" href="a05926.html#l00145">loadForm()</a>, <a class="el" href="a06167.html#l00293">loadRemappedFiles()</a>, and <a class="el" href="a06336.html#l00114">NLPACS::CRetrieverBank::serial()</a>. +<p> +<div class="fragment"><pre>00321 { +00322 <span class="comment">// If the file already contains a @, it means that a lookup already proceed and returning a big file, do nothing</span> +00323 <span class="keywordflow">if</span> (<a class="code" href="a05377.html#a2">filename</a>.find (<span class="stringliteral">"</span><span class="stringliteral">@") != string::npos) + { + NL_DISPLAY_PATH("</span>PATH: CPath::lookup(%s): already found", <a class="code" href="a05377.html#a2">filename</a>.c_str()); +00324 <span class="keywordflow">return</span> <a class="code" href="a05377.html#a2">filename</a>; +00325 } +00326 +00327 <span class="comment">// Try to find in the map directories</span> +00328 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00329 string str = <a class="code" href="a05378.html#a273">strlwr</a>(filename); +00330 +00331 <span class="comment">// Remove end spaces</span> +00332 <span class="keywordflow">while</span> ((!str.empty()) && (str[str.size()-1] == <span class="charliteral">' '</span>)) +00333 { +00334 str.resize (str.size()-1); +00335 } +00336 +00337 map<string, string>::iterator itss = inst->_RemappedFiles.find(str); +00338 <span class="keywordflow">if</span> (itss != inst->_RemappedFiles.end()) +00339 str = itss->second; +00340 +00341 <span class="keywordflow">if</span> (inst->_MemoryCompressed) +00342 { +00343 CMCFileEntry *pMCFE = <a class="code" href="a03072.html#NLMISC_1_1CPathh2">MCfind</a>(str); +00344 <span class="comment">// If found in the map, returns it</span> +00345 <span class="keywordflow">if</span> (pMCFE != NULL) +00346 { +00347 string fname, path = inst->SSMpath.get(pMCFE->idPath); +00348 <span class="keywordflow">if</span> (pMCFE->Remapped) +00349 fname = CFile::getFilenameWithoutExtension(pMCFE->Name) + <span class="stringliteral">"."</span> + inst->SSMext.get(pMCFE->idExt); +00350 <span class="keywordflow">else</span> +00351 fname = pMCFE->Name; +00352 +00353 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::lookup(%s): found in the map directory: '%s'"</span>, fname.c_str(), path.c_str()); +00354 <span class="keywordflow">return</span> path + fname; +00355 } +00356 } +00357 <span class="keywordflow">else</span> <span class="comment">// NOT memory compressed</span> +00358 { +00359 map<string, CFileEntry>::iterator it = inst->_Files.find (str); +00360 <span class="comment">// If found in the map, returns it</span> +00361 <span class="keywordflow">if</span> (it != inst->_Files.end()) +00362 { +00363 string fname, path = inst->SSMpath.get((*it).second.idPath); +00364 <span class="keywordflow">if</span> (it->second.Remapped) +00365 fname = CFile::getFilenameWithoutExtension((*it).second.Name) + <span class="stringliteral">"."</span> + inst->SSMext.get((*it).second.idExt); +00366 <span class="keywordflow">else</span> +00367 fname = (*it).second.Name; +00368 +00369 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::lookup(%s): found in the map directory: '%s'"</span>, fname.c_str(), path.c_str()); +00370 <span class="keywordflow">return</span> path + fname; +00371 } +00372 } +00373 +00374 +00375 <span class="comment">// Try to find in the alternative directories</span> +00376 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < inst->_AlternativePaths.size(); i++) +00377 { +00378 string <a class="code" href="a04223.html#a626">s</a> = inst->_AlternativePaths[i] + <a class="code" href="a05377.html#a2">filename</a>; +00379 <span class="keywordflow">if</span> ( CFile::fileExists(s) ) +00380 { +00381 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::lookup(%s): found in the alternative directory: '%s'"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str(), <a class="code" href="a04223.html#a626">s</a>.c_str()); +00382 <span class="keywordflow">return</span> <a class="code" href="a04223.html#a626">s</a>; +00383 } +00384 +00385 <span class="comment">// try with the remapping</span> +00386 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> j = 0; j < inst->_Extensions.size(); j++) +00387 { +00388 <span class="keywordflow">if</span> (<a class="code" href="a05378.html#a273">strlwr</a>(CFile::getExtension (filename)) == inst->_Extensions[j].second) +00389 { +00390 string rs = inst->_AlternativePaths[i] + CFile::getFilenameWithoutExtension (filename) + <span class="stringliteral">"."</span> + inst->_Extensions[j].first; +00391 <span class="keywordflow">if</span> ( CFile::fileExists(rs) ) +00392 { +00393 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::lookup(%s): found in the alternative directory: '%s'"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str(), rs.c_str()); +00394 <span class="keywordflow">return</span> rs; +00395 } +00396 } +00397 } +00398 } +00399 +00400 <span class="comment">// Try to find in the current directory</span> +00401 <span class="keywordflow">if</span> ( lookupInLocalDirectory && CFile::fileExists(filename) ) +00402 { +00403 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::lookup(%s): found in the current directory: '%s'"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str(), <a class="code" href="a05377.html#a2">filename</a>.c_str()); +00404 <span class="keywordflow">return</span> <a class="code" href="a05377.html#a2">filename</a>; +00405 } +00406 +00407 <span class="comment">// Not found</span> +00408 <span class="keywordflow">if</span> (displayWarning) +00409 { +00410 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::lookup(%s): file not found"</span>, <a class="code" href="a05377.html#a2">filename</a>.c_str()); +00411 } +00412 +00413 <span class="keywordflow">if</span> (throwException) +00414 <span class="keywordflow">throw</span> EPathNotFound (filename); +00415 +00416 <span class="keywordflow">return</span> <span class="stringliteral">""</span>; +00417 } +00418 </pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe16" doxytag="NLMISC::CPath::makePathRelative" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPath::makePathRelative </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const char * </td> + <td class="mdname" nowrap> <em>basePath</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>std::string & </td> + <td class="mdname" nowrap> <em>relativePath</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Make a path relative to another if possible, else doesn't change it. <dl compact><dt><b>Parameters:</b></dt><dd> + <table border="0" cellspacing="2" cellpadding="0"> + <tr><td valign=top><em>basePath</em> </td><td>is the base path to be relative to. </td></tr> + <tr><td valign=top><em>relativePath</em> </td><td>is the path to make relative to basePath. return true if relativePath as been done relative to basePath, false is relativePath has not been changed.</td></tr> + </table> +</dl> + +<p> +Definition at line <a class="el" href="a06167.html#l01674">1674</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +<div class="fragment"><pre>01675 { +01676 <span class="comment">// Standard path with final slash</span> +01677 string tmp = <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a> (basePath, <span class="keyword">true</span>); +01678 string <a class="code" href="a04223.html#a652">src</a> = <a class="code" href="a03072.html#NLMISC_1_1CPathe24">standardizePath</a> (relativePath, <span class="keyword">true</span>); +01679 string prefix; +01680 +01681 <span class="keywordflow">while</span> (1) +01682 { +01683 <span class="comment">// Compare with relativePath</span> +01684 <span class="keywordflow">if</span> (strncmp (tmp.c_str (), <a class="code" href="a04223.html#a652">src</a>.c_str (), tmp.length ()) == 0) +01685 { +01686 <span class="comment">// Troncate</span> +01687 <a class="code" href="a04558.html#a15">uint</a> <a class="code" href="a04223.html#a587">size</a> = tmp.length (); +01688 +01689 <span class="comment">// Same path ?</span> +01690 <span class="keywordflow">if</span> (<a class="code" href="a04223.html#a587">size</a> == <a class="code" href="a04223.html#a652">src</a>.length ()) +01691 { +01692 relativePath = <span class="stringliteral">"."</span>; +01693 <span class="keywordflow">return</span> <span class="keyword">true</span>; +01694 } +01695 +01696 relativePath = prefix+relativePath.substr (size, relativePath.length () - <a class="code" href="a04223.html#a587">size</a>); +01697 <span class="keywordflow">return</span> <span class="keyword">true</span>; +01698 } +01699 +01700 <span class="comment">// Too small ?</span> +01701 <span class="keywordflow">if</span> (tmp.length ()<2) +01702 <span class="keywordflow">break</span>; +01703 +01704 <span class="comment">// Remove last directory</span> +01705 <a class="code" href="a04558.html#a15">uint</a> lastPos = tmp.rfind (<span class="charliteral">'/'</span>, tmp.length ()-2); +01706 <a class="code" href="a04558.html#a15">uint</a> previousPos = tmp.find (<span class="charliteral">'/'</span>); +01707 <span class="keywordflow">if</span> ((lastPos == previousPos) || (lastPos == string::npos)) +01708 <span class="keywordflow">break</span>; +01709 +01710 <span class="comment">// Troncate</span> +01711 tmp = tmp.substr (0, lastPos+1); +01712 +01713 <span class="comment">// New prefix</span> +01714 prefix += <span class="stringliteral">"../"</span>; +01715 } +01716 +01717 <span class="keywordflow">return</span> <span class="keyword">false</span>; +01718 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathh2" doxytag="NLMISC::CPath::MCfind" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03075.html">CPath::CMCFileEntry</a> * NLMISC::CPath::MCfind </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>filename</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static, private]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06167.html#l00162">162</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a06168.html#l00270">_MCFiles</a>, <a class="el" href="a06168.html#l00239">_MemoryCompressed</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, and <a class="el" href="a06168.html#l00277">NLMISC::CPath::CMCFileComp::specialCompare()</a>. +<p> +<div class="fragment"><pre>00163 { +00164 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00165 <a class="code" href="a04199.html#a6">nlassert</a>(inst->_MemoryCompressed); +00166 vector<CMCFileEntry>::iterator it; +00167 it = lower_bound(inst->_MCFiles.begin(), inst->_MCFiles.end(), <a class="code" href="a05377.html#a2">filename</a>.c_str(), CMCFileComp()); +00168 <span class="keywordflow">if</span> (it != inst->_MCFiles.end()) +00169 { +00170 CMCFileComp FileComp; +00171 <span class="keywordflow">if</span> (FileComp.specialCompare(*it, <a class="code" href="a05377.html#a2">filename</a>.c_str()) == 0) +00172 <span class="keywordflow">return</span> &(*it); +00173 } +00174 <span class="keywordflow">return</span> NULL; +00175 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe17" doxytag="NLMISC::CPath::memoryCompress" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::memoryCompress </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +For the moment after memoryCompress you cant addsearchpath anymore +<p> +Definition at line <a class="el" href="a06167.html#l01235">1235</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a06168.html#l00267">_AllFileNames</a>, <a class="el" href="a06168.html#l00270">_MCFiles</a>, <a class="el" href="a06469.html#l00167">NLMISC::CStaticStringMapper::get()</a>, <a class="el" href="a06168.html#l00250">NLMISC::CPath::CFileEntry::idExt</a>, <a class="el" href="a06168.html#l00249">NLMISC::CPath::CFileEntry::idPath</a>, <a class="el" href="a06168.html#l00248">NLMISC::CPath::CFileEntry::Name</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a06168.html#l00251">NLMISC::CPath::CFileEntry::Remapped</a>, and <a class="el" href="a06168.html#l00241">SSMpath</a>. +<p> +<div class="fragment"><pre>01236 { +01237 NL_ALLOC_CONTEXT (MiPath); +01238 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +01239 +01240 inst->SSMext.memoryCompress(); +01241 inst->SSMpath.memoryCompress(); +01242 <a class="code" href="a04558.html#a15">uint</a> nDbg = inst->_Files.size(); +01243 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: Number of file : %d"</span>, nDbg); +01244 nDbg = inst->SSMext.getCount(); +01245 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: Number of different extension : %d"</span>, nDbg); +01246 nDbg = inst->SSMpath.getCount(); +01247 <a class="code" href="a04199.html#a1">nlinfo</a> (<span class="stringliteral">"PATH: Number of different path : %d"</span>, nDbg); +01248 +01249 <span class="comment">// Convert from _Files to _MCFiles</span> +01250 <a class="code" href="a04558.html#a15">uint</a> nSize = 0, nNb = 0; +01251 map<string,CFileEntry>::iterator it = inst->_Files.begin(); +01252 <span class="keywordflow">while</span> (it != inst->_Files.end()) +01253 { +01254 string sTmp = inst->SSMpath.get(it->second.idPath); +01255 <span class="keywordflow">if</span> ((sTmp.find(<span class="charliteral">'@'</span>) != string::npos) && !it->second.Remapped) +01256 { +01257 <span class="comment">// This is a file included in a bigfile (so the name is in the bigfile manager)</span> +01258 } +01259 <span class="keywordflow">else</span> +01260 { +01261 nSize += it->second.Name.size() + 1; +01262 } +01263 nNb++; +01264 it++; +01265 } +01266 +01267 inst->_AllFileNames = <span class="keyword">new</span> <span class="keywordtype">char</span>[nSize]; +01268 memset(inst->_AllFileNames, 0, nSize); +01269 inst->_MCFiles.resize(nNb); +01270 +01271 it = inst->_Files.begin(); +01272 nSize = 0; +01273 nNb = 0; +01274 <span class="keywordflow">while</span> (it != inst->_Files.end()) +01275 { +01276 CFileEntry &rFE = it->second; +01277 string sTmp = inst->SSMpath.get(rFE.idPath); +01278 <span class="keywordflow">if</span> ((sTmp.find(<span class="charliteral">'@'</span>) != string::npos) && !rFE.Remapped) +01279 { +01280 <span class="comment">// This is a file included in a bigfile (so the name is in the bigfile manager)</span> +01281 sTmp = sTmp.substr(0, sTmp.size()-1); +01282 inst->_MCFiles[nNb].Name = <a class="code" href="a02261.html#NLMISC_1_1CBigFilee0">CBigFile::getInstance</a>().<a class="code" href="a02261.html#NLMISC_1_1CBigFilea2">getFileNamePtr</a>(rFE.Name, sTmp); +01283 <a class="code" href="a04199.html#a6">nlassert</a>(inst->_MCFiles[nNb].Name != NULL); +01284 } +01285 <span class="keywordflow">else</span> +01286 { +01287 strcpy(inst->_AllFileNames+nSize, rFE.Name.c_str()); +01288 inst->_MCFiles[nNb].Name = inst->_AllFileNames+nSize; +01289 nSize += rFE.Name.size() + 1; +01290 } +01291 +01292 inst->_MCFiles[nNb].idExt = rFE.idExt; +01293 inst->_MCFiles[nNb].idPath = rFE.idPath; +01294 inst->_MCFiles[nNb].Remapped = rFE.Remapped; +01295 +01296 nNb++; +01297 it++; +01298 } +01299 +01300 <a class="code" href="a05378.html#a381">contReset</a>(inst->_Files); +01301 inst->_MemoryCompressed = <span class="keyword">true</span>; +01302 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe18" doxytag="NLMISC::CPath::memoryUncompress" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::memoryUncompress </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06167.html#l01304">1304</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>01305 { +01306 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance (); +01307 inst->SSMext.memoryUncompress(); +01308 inst->SSMpath.memoryUncompress(); +01309 inst->_MemoryCompressed = <span class="keyword">false</span>; +01310 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe19" doxytag="NLMISC::CPath::remapExtension" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::remapExtension </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>ext1</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const std::string & </td> + <td class="mdname" nowrap> <em>ext2</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>substitute</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Add a remapping function to allow file extension substitution.<ul> +<li>eg remapExtension("dds", "tga", true) Where the boolean indicates whether the "dds" should replace a "tga" if one exists - again - a warning should be generated if the two are present.</li></ul> +<p> +ie: If you have a file called pic.dds and you call remapExtension("dds", "tga", true), if you call lookup("pic.tga"), it'll return "pic.dds" +<p> +Definition at line <a class="el" href="a06167.html#l00190">190</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a06168.html#l00302">_Extensions</a>, <a class="el" href="a06168.html#l00254">_Files</a>, <a class="el" href="a06168.html#l00239">_MemoryCompressed</a>, <a class="el" href="a05538.html#l02654">file</a>, <a class="el" href="a06167.html#l00177">findExtension()</a>, <a class="el" href="a06469.html#l00167">NLMISC::CStaticStringMapper::get()</a>, <a class="el" href="a06167.html#l01139">insertFileInMap()</a>, <a class="el" href="a06167.html#l00071">NL_DISPLAY_PATH</a>, <a class="el" href="a05622.html#l00290">nlassert</a>, <a class="el" href="a05622.html#l00135">nlwarning</a>, <a class="el" href="a05981.html#l00104">sint</a>, <a class="el" href="a06168.html#l00240">SSMext</a>, <a class="el" href="a06168.html#l00241">SSMpath</a>, <a class="el" href="a05586.html#l00536">NLMISC::strlwr()</a>, and <a class="el" href="a05981.html#l00100">uint32</a>. +<p> +<div class="fragment"><pre>00191 { +00192 NL_ALLOC_CONTEXT (MiPath); +00193 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00194 <a class="code" href="a04199.html#a6">nlassert</a>(!inst->_MemoryCompressed); +00195 +00196 string ext1lwr = <a class="code" href="a05378.html#a273">strlwr</a> (ext1); +00197 string ext2lwr = <a class="code" href="a05378.html#a273">strlwr</a> (ext2); +00198 +00199 <span class="keywordflow">if</span> (ext1lwr.empty() || ext2lwr.empty()) +00200 { +00201 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::remapExtension(%s, %s, %d): can't remap empty extension"</span>, ext1lwr.c_str(), ext2lwr.c_str(), substitute); +00202 } +00203 +00204 <span class="keywordflow">if</span> (ext1lwr == <span class="stringliteral">"bnp"</span> || ext2lwr == <span class="stringliteral">"bnp"</span>) +00205 { +00206 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::remapExtension(%s, %s, %d): you can't remap a big file"</span>, ext1lwr.c_str(), ext2lwr.c_str(), substitute); +00207 } +00208 +00209 <span class="keywordflow">if</span> (!substitute) +00210 { +00211 <span class="comment">// remove the mapping from the mapping list</span> +00212 <a class="code" href="a04558.html#a14">sint</a> n = inst->findExtension (ext1lwr, ext2lwr); +00213 <a class="code" href="a04199.html#a6">nlassert</a> (n != -1); +00214 inst->_Extensions.erase (inst->_Extensions.begin() + n); +00215 +00216 <span class="comment">// remove mapping in the map</span> +00217 map<string, CFileEntry>::iterator it = inst->_Files.begin(); +00218 map<string, CFileEntry>::iterator nit = it; +00219 <span class="keywordflow">while</span> (it != inst->_Files.end ()) +00220 { +00221 nit++; +00222 string ext = inst->SSMext.get((*it).second.idExt); +00223 <span class="keywordflow">if</span> ((*it).second.Remapped && ext == ext2lwr) +00224 { +00225 inst->_Files.erase (it); +00226 } +00227 it = nit; +00228 } +00229 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::remapExtension(%s, %s, %d): extension removed"</span>, ext1lwr.c_str(), ext2lwr.c_str(), substitute); +00230 } +00231 <span class="keywordflow">else</span> +00232 { +00233 <a class="code" href="a04558.html#a14">sint</a> n = inst->findExtension (ext1lwr, ext2lwr); +00234 <span class="keywordflow">if</span> (n != -1) +00235 { +00236 <a class="code" href="a04199.html#a2">nlwarning</a> (<span class="stringliteral">"PATH: CPath::remapExtension(%s, %s, %d): remapping already set"</span>, ext1lwr.c_str(), ext2lwr.c_str(), substitute); +00237 <span class="keywordflow">return</span>; +00238 } +00239 +00240 <span class="comment">// adding mapping into the mapping list</span> +00241 inst->_Extensions.push_back (make_pair (ext1lwr, ext2lwr)); +00242 +00243 <span class="comment">// adding mapping into the map</span> +00244 vector<string> newFiles; +00245 map<string, CFileEntry>::iterator it = inst->_Files.begin(); +00246 <span class="keywordflow">while</span> (it != inst->_Files.end ()) +00247 { +00248 string ext = inst->SSMext.get((*it).second.idExt); +00249 <span class="keywordflow">if</span> (!(*it).second.Remapped && ext == ext1lwr) +00250 { +00251 <span class="comment">// find if already exist</span> +00252 <a class="code" href="a04558.html#a11">uint32</a> pos = (*it).first.find_last_of (<span class="stringliteral">"."</span>); +00253 <span class="keywordflow">if</span> (pos != string::npos) +00254 { +00255 string <a class="code" href="a04115.html#a95">file</a> = (*it).first.substr (0, pos + 1); +00256 <a class="code" href="a04115.html#a95">file</a> += ext2lwr; +00257 +00258 <span class="comment">// TODO perhaps a problem because I insert in the current map that i parcours</span> +00259 string path = inst->SSMpath.get((*it).second.idPath); +00260 <a class="code" href="a03072.html#NLMISC_1_1CPathh1">insertFileInMap</a> (file, path+file, <span class="keyword">true</span>, ext1lwr); +00261 } +00262 } +00263 it++; +00264 } +00265 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::remapExtension(%s, %s, %d): extension added"</span>, ext1lwr.c_str(), ext2lwr.c_str(), substitute); +00266 } +00267 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe20" doxytag="NLMISC::CPath::remapFile" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::remapFile </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>file1</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>const std::string & </td> + <td class="mdname" nowrap> <em>file2</em></td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Add file remapping ie: If you have a file called pic.dds, and call remapFile("picture.dds", "pic.dds") calling lookup("picture.dds") will in fact call lookup("pic.dds") +<p> +Definition at line <a class="el" href="a06167.html#l00270">270</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a06168.html#l00233">_RemappedFiles</a>, and <a class="el" href="a05586.html#l00536">NLMISC::strlwr()</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00293">loadRemappedFiles()</a>. +<p> +<div class="fragment"><pre>00271 { +00272 NL_ALLOC_CONTEXT (MiPath); +00273 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00274 <span class="keywordflow">if</span> (file1.empty()) <span class="keywordflow">return</span>; +00275 <span class="keywordflow">if</span> (file2.empty()) <span class="keywordflow">return</span>; +00276 inst->_RemappedFiles[<a class="code" href="a05378.html#a273">strlwr</a>(file1)] = <a class="code" href="a05378.html#a273">strlwr</a>(file2); +00277 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe21" doxytag="NLMISC::CPath::removeAllAlternativeSearchPath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> void NLMISC::CPath::removeAllAlternativeSearchPath </td> + <td class="md" valign="top">( </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Remove all search path contains in the alternative directories +<p> +Definition at line <a class="el" href="a06167.html#l00799">799</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +<div class="fragment"><pre>00800 { +00801 <a class="code" href="a03072.html#NLMISC_1_1CPathd0">CPath</a> *inst = CPath::getInstance(); +00802 inst->_AlternativePaths.clear (); +00803 <a class="code" href="a04744.html#a0">NL_DISPLAY_PATH</a>(<span class="stringliteral">"PATH: CPath::RemoveAllAternativeSearchPath(): removed"</span>); +00804 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe22" doxytag="NLMISC::CPath::setCurrentPath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool NLMISC::CPath::setCurrentPath </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const char * </td> + <td class="mdname1" valign="top" nowrap> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Set the current path of the applicated. +<p> +Definition at line <a class="el" href="a06167.html#l00515">515</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +<div class="fragment"><pre>00516 { +00517 <span class="preprocessor">#ifdef NL_OS_WINDOWS</span> +00518 <span class="preprocessor"></span> <span class="keywordflow">return</span> _chdir(newDir) == 0; +00519 <span class="preprocessor">#else</span> +00520 <span class="preprocessor"></span> <span class="comment">// todo : check this compiles under linux. Thanks (Hulud)</span> +00521 <span class="keywordflow">return</span> chdir(newDir) == 0; +00522 <span class="preprocessor">#endif</span> +00523 <span class="preprocessor"></span>} +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe23" doxytag="NLMISC::CPath::standardizeDosPath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::string NLMISC::CPath::standardizeDosPath </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname1" valign="top" nowrap> <em>path</em> </td> + <td class="md" valign="top"> ) </td> + <td class="md" nowrap><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Remplace / with \ for fucking dos process. Use only this function if can't do another way. For exemple, if you do a system("copy data/toto data/tata"); it'll not work because dos doesn't understand /. But in the majority of case, / working (it works for fopen for example) +<p> +Definition at line <a class="el" href="a06167.html#l00482">482</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>. +<p> +<div class="fragment"><pre>00483 { +00484 string newPath; +00485 +00486 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < path.size(); i++) +00487 { +00488 <span class="keywordflow">if</span> (path[i] == <span class="charliteral">'/'</span>) +00489 newPath += <span class="charliteral">'\\'</span>; +00490 <span class="comment">// Yoyo: supress toLower. Not usefull!?!</span> +00491 <span class="comment">/*else if (isupper(path[i]))</span> +00492 <span class="comment"> newPath += tolower(path[i]);*/</span> +00493 <span class="keywordflow">else</span> +00494 newPath += path[i]; +00495 } +00496 +00497 <span class="keywordflow">if</span> (CFile::isExists(path) && CFile::isDirectory(path) && newPath[newPath.size()-1] != <span class="charliteral">'\\'</span>) +00498 newPath += <span class="charliteral">'\\'</span>; +00499 +00500 <span class="keywordflow">return</span> newPath; +00501 } +</pre></div> </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathe24" doxytag="NLMISC::CPath::standardizePath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> string NLMISC::CPath::standardizePath </td> + <td class="md" valign="top">( </td> + <td class="md" nowrap valign="top">const std::string & </td> + <td class="mdname" nowrap> <em>path</em>, </td> + </tr> + <tr> + <td class="md" nowrap align="right"></td> + <td></td> + <td class="md" nowrap>bool </td> + <td class="mdname" nowrap> <em>addFinalSlash</em> = true</td> + </tr> + <tr> + <td></td> + <td class="md">) </td> + <td class="md" colspan="2"><code> [static]</code></td> + </tr> + + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +Take a path and put it in the portable format and add a terminated / if needed ie: "C:\\Game/dir1" will become "C:/Game/dir1/" or "C:/Game/dir1" if addFinalSlash is false +<p> +Definition at line <a class="el" href="a06167.html#l00452">452</a> of file <a class="el" href="a06167.html">path.cpp</a>. +<p> +References <a class="el" href="a05981.html#l00105">uint</a>. +<p> +Referenced by <a class="el" href="a05597.html#l00297">NLMISC::CConfigFile::reparse()</a>. +<p> +<div class="fragment"><pre>00453 { +00454 string newPath; +00455 <span class="comment">// check empty path</span> +00456 <span class="keywordflow">if</span> (path.empty()) <span class="keywordflow">return</span> <span class="stringliteral">""</span>; +00457 +00458 <span class="comment">// don't transform the first \\ for windows network path</span> +00459 <span class="comment">// if (path.size() >= 2 && path[0] == '\\' && path[1] == '\\')</span> +00460 <span class="comment">// {</span> +00461 <span class="comment">// newPath += "\\\\";</span> +00462 <span class="comment">// i = 2;</span> +00463 <span class="comment">// }</span> +00464 +00465 <span class="keywordflow">for</span> (<a class="code" href="a04558.html#a15">uint</a> i = 0; i < path.size(); i++) +00466 { +00467 <span class="comment">// don't transform the first \\ for windows network path</span> +00468 <span class="keywordflow">if</span> (path[i] == <span class="charliteral">'\\'</span>) +00469 newPath += <span class="charliteral">'/'</span>; +00470 <span class="keywordflow">else</span> +00471 newPath += path[i]; +00472 } +00473 +00474 <span class="comment">// add terminal slash</span> +00475 <span class="keywordflow">if</span> (addFinalSlash && newPath[path.size()-1] != <span class="charliteral">'/'</span>) +00476 newPath += <span class="charliteral">'/'</span>; +00477 +00478 <span class="keywordflow">return</span> newPath; +00479 } +</pre></div> </td> + </tr> +</table> +<hr><h2>Field Documentation</h2> +<a class="anchor" name="NLMISC_1_1CPathr0" doxytag="NLMISC::CPath::_AllFileNames" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> char* <a class="el" href="a03072.html#NLMISC_1_1CPathr0">NLMISC::CPath::_AllFileNames</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00267">267</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +Referenced by <a class="el" href="a06167.html#l01235">memoryCompress()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathr1" doxytag="NLMISC::CPath::_AlternativePaths" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<std::string> <a class="el" href="a03072.html#NLMISC_1_1CPathr1">NLMISC::CPath::_AlternativePaths</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00229">229</a> of file <a class="el" href="a06168.html">path.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathr2" doxytag="NLMISC::CPath::_Extensions" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<std::pair<std::string, std::string> > <a class="el" href="a03072.html#NLMISC_1_1CPathr2">NLMISC::CPath::_Extensions</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> +first ext1, second ext2 (ext1 could remplace ext2) +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00302">302</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00177">findExtension()</a>, and <a class="el" href="a06167.html#l00190">remapExtension()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathr3" doxytag="NLMISC::CPath::_Files" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::map<std::string, <a class="el" href="a03073.html">CFileEntry</a>> <a class="el" href="a03072.html#NLMISC_1_1CPathr3">NLMISC::CPath::_Files</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00254">254</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00153">clearMap()</a>, <a class="el" href="a06167.html#l00087">getFileList()</a>, and <a class="el" href="a06167.html#l00190">remapExtension()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathv0" doxytag="NLMISC::CPath::_Instance" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03072.html">CPath</a> * <a class="el" href="a03072.html#NLMISC_1_1CPathv0">NLMISC::CPath::_Instance</a> = NULL<code> [static, private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06167.html#l00080">80</a> of file <a class="el" href="a06167.html">path.cpp</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathr4" doxytag="NLMISC::CPath::_MCFiles" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<<a class="el" href="a03075.html">CMCFileEntry</a>> <a class="el" href="a03072.html#NLMISC_1_1CPathr4">NLMISC::CPath::_MCFiles</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00270">270</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00087">getFileList()</a>, <a class="el" href="a06167.html#l00162">MCfind()</a>, and <a class="el" href="a06167.html#l01235">memoryCompress()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathr5" doxytag="NLMISC::CPath::_MemoryCompressed" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> bool <a class="el" href="a03072.html#NLMISC_1_1CPathr5">NLMISC::CPath::_MemoryCompressed</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00239">239</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00153">clearMap()</a>, <a class="el" href="a06168.html#l00223">CPath()</a>, <a class="el" href="a06167.html#l00087">getFileList()</a>, <a class="el" href="a06168.html#l00215">isMemoryCompressed()</a>, <a class="el" href="a06167.html#l00162">MCfind()</a>, and <a class="el" href="a06167.html#l00190">remapExtension()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathr6" doxytag="NLMISC::CPath::_RemappedFiles" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::map<std::string, std::string> <a class="el" href="a03072.html#NLMISC_1_1CPathr6">NLMISC::CPath::_RemappedFiles</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00233">233</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00270">remapFile()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathr7" doxytag="NLMISC::CPath::IgnoredFiles" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> std::vector<std::string> <a class="el" href="a03072.html#NLMISC_1_1CPathr7">NLMISC::CPath::IgnoredFiles</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00231">231</a> of file <a class="el" href="a06168.html">path.h</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathr8" doxytag="NLMISC::CPath::SSMext" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03441.html">CStaticStringMapper</a> <a class="el" href="a03072.html#NLMISC_1_1CPathr8">NLMISC::CPath::SSMext</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00240">240</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +Referenced by <a class="el" href="a06167.html#l00087">getFileList()</a>, and <a class="el" href="a06167.html#l00190">remapExtension()</a>. </td> + </tr> +</table> +<a class="anchor" name="NLMISC_1_1CPathr9" doxytag="NLMISC::CPath::SSMpath" ></a><p> +<table class="mdTable" width="100%" cellpadding="2" cellspacing="0"> + <tr> + <td class="mdRow"> + <table cellpadding="0" cellspacing="0" border="0"> + <tr> + <td class="md" nowrap valign="top"> <a class="el" href="a03441.html">CStaticStringMapper</a> <a class="el" href="a03072.html#NLMISC_1_1CPathr9">NLMISC::CPath::SSMpath</a><code> [private]</code> + </table> + </td> + </tr> +</table> +<table cellspacing=5 cellpadding=0 border=0> + <tr> + <td> + + </td> + <td> + +<p> + +<p> +Definition at line <a class="el" href="a06168.html#l00241">241</a> of file <a class="el" href="a06168.html">path.h</a>. +<p> +Referenced by <a class="el" href="a06167.html#l01235">memoryCompress()</a>, and <a class="el" href="a06167.html#l00190">remapExtension()</a>. </td> + </tr> +</table> +<hr>The documentation for this class was generated from the following files:<ul> +<li><a class="el" href="a06168.html">path.h</a><li><a class="el" href="a06167.html">path.cpp</a></ul> +<hr size="1"><address style="align: right;"><small>Generated on Tue Mar 16 13:27:22 2004 for NeL by +<a href="http://www.doxygen.org/index.html"> +<img src="doxygen.png" alt="doxygen" align="middle" border=0 > +</a>1.3.6 </small></address> +</body> +</html> |