<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>FAUST compiler: enrobage.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.6.3 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>enrobage.cpp</h1><a href="enrobage_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/************************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> ************************************************************************</span> <a name="l00003"></a>00003 <span class="comment"> FAUST compiler</span> <a name="l00004"></a>00004 <span class="comment"> Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale</span> <a name="l00005"></a>00005 <span class="comment"> ---------------------------------------------------------------------</span> <a name="l00006"></a>00006 <span class="comment"> This program is free software; you can redistribute it and/or modify</span> <a name="l00007"></a>00007 <span class="comment"> it under the terms of the GNU General Public License as published by</span> <a name="l00008"></a>00008 <span class="comment"> the Free Software Foundation; either version 2 of the License, or</span> <a name="l00009"></a>00009 <span class="comment"> (at your option) any later version.</span> <a name="l00010"></a>00010 <span class="comment"></span> <a name="l00011"></a>00011 <span class="comment"> This program is distributed in the hope that it will be useful,</span> <a name="l00012"></a>00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00013"></a>00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> <a name="l00014"></a>00014 <span class="comment"> GNU General Public License for more details.</span> <a name="l00015"></a>00015 <span class="comment"></span> <a name="l00016"></a>00016 <span class="comment"> You should have received a copy of the GNU General Public License</span> <a name="l00017"></a>00017 <span class="comment"> along with this program; if not, write to the Free Software</span> <a name="l00018"></a>00018 <span class="comment"> Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</span> <a name="l00019"></a>00019 <span class="comment"> ************************************************************************</span> <a name="l00020"></a>00020 <span class="comment"> ************************************************************************/</span> <a name="l00021"></a>00021 <a name="l00022"></a>00022 <a name="l00023"></a>00023 <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="enrobage_8hh.html">enrobage.hh</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include <string></span> <a name="l00026"></a>00026 <span class="preprocessor">#include <limits.h></span> <a name="l00027"></a>00027 <span class="preprocessor">#include <stdlib.h></span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="compatibility_8hh.html">compatibility.hh</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include <climits></span> <a name="l00030"></a>00030 <a name="l00031"></a>00031 <span class="keyword">extern</span> <span class="keywordtype">string</span> <a class="code" href="doc_8cpp.html#a09fc40a224a32f929decbac5a21140ef">gFaustSuperSuperDirectory</a>; <a name="l00032"></a>00032 <span class="keyword">extern</span> <span class="keywordtype">string</span> <a class="code" href="doc_8cpp.html#a2529dab7cac84bd8f69c14ee8a3cbfe2">gFaustSuperDirectory</a>; <a name="l00033"></a>00033 <span class="keyword">extern</span> <span class="keywordtype">string</span> <a class="code" href="doc_8cpp.html#a320fc936026f318a3fc46f47ef379713">gFaustDirectory</a>; <a name="l00034"></a>00034 <span class="keyword">extern</span> <span class="keywordtype">string</span> <a class="code" href="main_8cpp.html#aea493812dd4a239a7c0d354d5a07e191">gMasterDirectory</a>; <a name="l00035"></a>00035 <span class="comment">//----------------------------------------------------------------</span> <a name="l00036"></a>00036 <a name="l00037"></a>00037 <a name="l00041"></a><a class="code" href="enrobage_8hh.html#a5f5bd14f70f4edf37e76608dab1a6bd2">00041</a> <span class="keywordtype">void</span> <a class="code" href="enrobage_8cpp.html#a5f5bd14f70f4edf37e76608dab1a6bd2" title="Copy src to dst until specific line.">streamCopyUntil</a>(istream& src, ostream& dst, <span class="keyword">const</span> <span class="keywordtype">string</span>& until) <a name="l00042"></a>00042 { <a name="l00043"></a>00043 <span class="keywordtype">string</span> s; <a name="l00044"></a>00044 <span class="keywordflow">while</span> ( getline(src,s) && (s != until) ) dst << s << endl; <a name="l00045"></a>00045 } <a name="l00046"></a>00046 <a name="l00050"></a><a class="code" href="enrobage_8hh.html#aeea853d479ea9c4fbf204795c0334e9d">00050</a> <span class="keywordtype">void</span> <a class="code" href="enrobage_8cpp.html#aeea853d479ea9c4fbf204795c0334e9d" title="Copy src to dst.">streamCopy</a>(istream& src, ostream& dst) <a name="l00051"></a>00051 { <a name="l00052"></a>00052 <span class="keywordtype">string</span> s; <a name="l00053"></a>00053 <span class="keywordflow">while</span> ( getline(src,s)) dst << s << endl; <a name="l00054"></a>00054 } <a name="l00055"></a>00055 <a name="l00059"></a><a class="code" href="enrobage_8hh.html#af1ac810ee8c704632447ef8650c8dc20">00059</a> <span class="keywordtype">void</span> <a class="code" href="enrobage_8cpp.html#af1ac810ee8c704632447ef8650c8dc20" title="Copy src to dst until end.">streamCopyUntilEnd</a>(istream& src, ostream& dst) <a name="l00060"></a>00060 { <a name="l00061"></a>00061 <span class="keywordtype">string</span> s; <a name="l00062"></a>00062 <span class="keywordflow">while</span> ( getline(src,s) ) dst << s << endl; <a name="l00063"></a>00063 } <a name="l00064"></a>00064 <a name="l00065"></a>00065 <a name="l00069"></a><a class="code" href="enrobage_8hh.html#a901a730cc8136f70a2073da23fafa61e">00069</a> ifstream* <a class="code" href="enrobage_8cpp.html#a901a730cc8136f70a2073da23fafa61e" title="Try to open an architecture file searching in various directories.">open_arch_stream</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename) <a name="l00070"></a>00070 { <a name="l00071"></a>00071 <span class="keywordtype">char</span> buffer[<a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>]; <a name="l00072"></a>00072 <span class="keywordtype">char</span>* old = getcwd (buffer, <a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>); <a name="l00073"></a>00073 <span class="keywordtype">int</span> err; <a name="l00074"></a>00074 <a name="l00075"></a>00075 { <a name="l00076"></a>00076 ifstream* f = <span class="keyword">new</span> ifstream(); <a name="l00077"></a>00077 f->open(filename, ifstream::in); <span class="keywordflow">if</span> (f->is_open()) <span class="keywordflow">return</span> f; <span class="keywordflow">else</span> <span class="keyword">delete</span> f; <a name="l00078"></a>00078 } <a name="l00079"></a>00079 <span class="keywordflow">if</span> ( (chdir(<a class="code" href="doc_8cpp.html#a320fc936026f318a3fc46f47ef379713">gFaustDirectory</a>.c_str())==0) && (chdir(<span class="stringliteral">"architecture"</span>)==0) ) { <a name="l00080"></a>00080 <span class="comment">//cout << "enrobage.cpp : 'architecture' directory found in gFaustDirectory" << endl;</span> <a name="l00081"></a>00081 ifstream* f = <span class="keyword">new</span> ifstream(); <a name="l00082"></a>00082 f->open(filename, ifstream::in); <a name="l00083"></a>00083 <span class="keywordflow">if</span> (f->good()) <span class="keywordflow">return</span> f; <span class="keywordflow">else</span> <span class="keyword">delete</span> f; <a name="l00084"></a>00084 } <a name="l00085"></a>00085 err = chdir(old); <a name="l00086"></a>00086 <span class="keywordflow">if</span> ((chdir(<a class="code" href="doc_8cpp.html#a2529dab7cac84bd8f69c14ee8a3cbfe2">gFaustSuperDirectory</a>.c_str())==0) && (chdir(<span class="stringliteral">"architecture"</span>)==0) ) { <a name="l00087"></a>00087 <span class="comment">//cout << "enrobage.cpp : 'architecture' directory found in gFaustSuperDirectory" << endl;</span> <a name="l00088"></a>00088 ifstream* f = <span class="keyword">new</span> ifstream(); <a name="l00089"></a>00089 f->open(filename, ifstream::in); <a name="l00090"></a>00090 <span class="keywordflow">if</span> (f->good()) <span class="keywordflow">return</span> f; <span class="keywordflow">else</span> <span class="keyword">delete</span> f; <a name="l00091"></a>00091 } <a name="l00092"></a>00092 err = chdir(old); <a name="l00093"></a>00093 <span class="keywordflow">if</span> ((chdir(<a class="code" href="doc_8cpp.html#a09fc40a224a32f929decbac5a21140ef">gFaustSuperSuperDirectory</a>.c_str())==0) && (chdir(<span class="stringliteral">"architecture"</span>)==0) ) { <a name="l00094"></a>00094 <span class="comment">//cout << "enrobage.cpp : 'architecture' directory found in gFaustSuperSuperDirectory" << endl;</span> <a name="l00095"></a>00095 ifstream* f = <span class="keyword">new</span> ifstream(); <a name="l00096"></a>00096 f->open(filename, ifstream::in); <a name="l00097"></a>00097 <span class="keywordflow">if</span> (f->good()) <span class="keywordflow">return</span> f; <span class="keywordflow">else</span> <span class="keyword">delete</span> f; <a name="l00098"></a>00098 } <a name="l00099"></a>00099 err = chdir(old); <a name="l00100"></a>00100 <span class="keywordflow">if</span> (chdir(<span class="stringliteral">"/usr/local/lib/faust"</span>)==0) { <a name="l00101"></a>00101 ifstream* f = <span class="keyword">new</span> ifstream(); <a name="l00102"></a>00102 f->open(filename); <a name="l00103"></a>00103 <span class="keywordflow">if</span> (f->good()) <span class="keywordflow">return</span> f; <span class="keywordflow">else</span> <span class="keyword">delete</span> f; <a name="l00104"></a>00104 } <a name="l00105"></a>00105 err = chdir(old); <a name="l00106"></a>00106 <span class="keywordflow">if</span> (chdir(<span class="stringliteral">"/usr/lib/faust"</span>)==0) { <a name="l00107"></a>00107 ifstream* f = <span class="keyword">new</span> ifstream(); <a name="l00108"></a>00108 f->open(filename); <a name="l00109"></a>00109 <span class="keywordflow">if</span> (f->good()) <span class="keywordflow">return</span> f; <span class="keywordflow">else</span> <span class="keyword">delete</span> f; <a name="l00110"></a>00110 } <a name="l00111"></a>00111 <a name="l00112"></a>00112 <span class="keywordflow">return</span> 0; <a name="l00113"></a>00113 } <a name="l00114"></a>00114 <a name="l00115"></a>00115 <a name="l00116"></a>00116 <a name="l00117"></a>00117 <span class="comment">/*---------------------------------------------*/</span> <a name="l00118"></a>00118 <a name="l00124"></a><a class="code" href="enrobage_8hh.html#af611c72db7e5426b9cab1268d3f5869b">00124</a> <span class="keywordtype">bool</span> <a class="code" href="enrobage_8cpp.html#af611c72db7e5426b9cab1268d3f5869b" title="Check if a file exists.">check_file</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename) <a name="l00125"></a>00125 { <a name="l00126"></a>00126 FILE* f = fopen(filename, <span class="stringliteral">"r"</span>); <a name="l00127"></a>00127 <a name="l00128"></a>00128 <span class="keywordflow">if</span> (f == NULL) { <a name="l00129"></a>00129 fprintf(stderr, <span class="stringliteral">"faust: "</span>); perror(filename); <a name="l00130"></a>00130 } <span class="keywordflow">else</span> { <a name="l00131"></a>00131 fclose(f); <a name="l00132"></a>00132 } <a name="l00133"></a>00133 <span class="keywordflow">return</span> f != NULL; <a name="l00134"></a>00134 } <a name="l00135"></a>00135 <a name="l00136"></a>00136 <a name="l00141"></a><a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c">00141</a> <span class="keyword">static</span> FILE* <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(<span class="keywordtype">string</span>& fullpath, <span class="keyword">const</span> <span class="keywordtype">char</span>* dir, <span class="keyword">const</span> <span class="keywordtype">char</span>* filename) <a name="l00142"></a>00142 { <a name="l00143"></a>00143 <span class="keywordtype">int</span> err; <a name="l00144"></a>00144 <span class="keywordtype">char</span> olddirbuffer[<a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>]; <a name="l00145"></a>00145 <span class="keywordtype">char</span> newdirbuffer[<a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>]; <a name="l00146"></a>00146 <a name="l00147"></a>00147 <span class="keywordtype">char</span>* olddir = getcwd (olddirbuffer, <a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>); <a name="l00148"></a>00148 <a name="l00149"></a>00149 <span class="keywordflow">if</span> (chdir(dir) == 0) { <a name="l00150"></a>00150 FILE* f = fopen(filename, <span class="stringliteral">"r"</span>); <a name="l00151"></a>00151 fullpath = getcwd (newdirbuffer, <a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>); <a name="l00152"></a>00152 fullpath += <span class="charliteral">'/'</span>; <a name="l00153"></a>00153 fullpath += filename; <a name="l00154"></a>00154 err = chdir(olddir); <a name="l00155"></a>00155 <span class="keywordflow">return</span> f; <a name="l00156"></a>00156 } <a name="l00157"></a>00157 err = chdir(olddir); <a name="l00158"></a>00158 <span class="keywordflow">return</span> 0; <a name="l00159"></a>00159 } <a name="l00160"></a>00160 <a name="l00165"></a><a class="code" href="enrobage_8cpp.html#aeebc646fd9ddc669dfe5e19dc7138c79">00165</a> <span class="keyword">static</span> FILE* <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(<span class="keywordtype">string</span>& fullpath, <span class="keyword">const</span> <span class="keywordtype">string</span>& dir, <span class="keyword">const</span> <span class="keywordtype">char</span>* filename) <a name="l00166"></a>00166 { <a name="l00167"></a>00167 <span class="keywordflow">return</span> <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, dir.c_str(), filename); <a name="l00168"></a>00168 } <a name="l00169"></a>00169 <a name="l00174"></a><a class="code" href="enrobage_8cpp.html#aac1a11a7d4462beb928a88b0d69b9ad4">00174</a> <span class="keyword">static</span> FILE* <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(<span class="keywordtype">string</span>& fullpath, <span class="keyword">const</span> <span class="keywordtype">string</span>& dir, <span class="keyword">const</span> <span class="keywordtype">char</span>* path, <span class="keyword">const</span> <span class="keywordtype">char</span>* filename) <a name="l00175"></a>00175 { <a name="l00176"></a>00176 <span class="keywordtype">int</span> err; <a name="l00177"></a>00177 <span class="keywordtype">char</span> olddirbuffer[<a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>]; <a name="l00178"></a>00178 <span class="keywordtype">char</span> newdirbuffer[<a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>]; <a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="keywordtype">char</span>* olddir = getcwd (olddirbuffer, <a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>); <a name="l00181"></a>00181 <span class="keywordflow">if</span> (chdir(dir.c_str()) == 0) { <a name="l00182"></a>00182 <span class="keywordflow">if</span> (chdir(path) == 0) { <a name="l00183"></a>00183 FILE* f = fopen(filename, <span class="stringliteral">"r"</span>); <a name="l00184"></a>00184 fullpath = getcwd (newdirbuffer, <a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>); <a name="l00185"></a>00185 fullpath += <span class="charliteral">'/'</span>; <a name="l00186"></a>00186 fullpath += filename; <a name="l00187"></a>00187 err = chdir(olddir); <a name="l00188"></a>00188 <span class="keywordflow">return</span> f; <a name="l00189"></a>00189 } <a name="l00190"></a>00190 } <a name="l00191"></a>00191 err = chdir(olddir); <a name="l00192"></a>00192 <span class="keywordflow">return</span> 0; <a name="l00193"></a>00193 } <a name="l00194"></a>00194 <a name="l00195"></a>00195 <a name="l00196"></a>00196 <a name="l00200"></a><a class="code" href="enrobage_8cpp.html#a907e10f036fa997665a2da940ea7452b">00200</a> <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="enrobage_8cpp.html#a907e10f036fa997665a2da940ea7452b" title="Test absolute pathname.">isAbsolutePathname</a>(<span class="keyword">const</span> <span class="keywordtype">string</span>& filename) <a name="l00201"></a>00201 { <a name="l00202"></a>00202 <span class="comment">//test windows absolute pathname "x:xxxxxx"</span> <a name="l00203"></a>00203 <span class="keywordflow">if</span> (filename.size()>1 && filename[1] == <span class="charliteral">':'</span>) <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00204"></a>00204 <a name="l00205"></a>00205 <span class="comment">// test unix absolute pathname "/xxxxxx"</span> <a name="l00206"></a>00206 <span class="keywordflow">if</span> (filename.size()>0 && filename[0] == <span class="charliteral">'/'</span>) <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00207"></a>00207 <a name="l00208"></a>00208 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00209"></a>00209 } <a name="l00210"></a>00210 <a name="l00211"></a>00211 <a name="l00216"></a><a class="code" href="enrobage_8cpp.html#ab6796e82ccd882d69cc1fbb28f537d01">00216</a> <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="enrobage_8cpp.html#ab6796e82ccd882d69cc1fbb28f537d01" title="Build a full pathname of &lt;filename&gt;.">buildFullPathname</a>(<span class="keywordtype">string</span>& fullpath, <span class="keyword">const</span> <span class="keywordtype">char</span>* filename) <a name="l00217"></a>00217 { <a name="l00218"></a>00218 <span class="keywordtype">char</span> old[<a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>]; <a name="l00219"></a>00219 <a name="l00220"></a>00220 <span class="keywordflow">if</span> (<a class="code" href="enrobage_8cpp.html#a907e10f036fa997665a2da940ea7452b" title="Test absolute pathname.">isAbsolutePathname</a>(filename)) { <a name="l00221"></a>00221 fullpath = filename; <a name="l00222"></a>00222 } <span class="keywordflow">else</span> { <a name="l00223"></a>00223 fullpath = getcwd (old, <a class="code" href="compatibility_8hh.html#a3bf18fd70de2efe183049cb028875fe2">FAUST_PATH_MAX</a>); <a name="l00224"></a>00224 fullpath += <span class="charliteral">'/'</span>; <a name="l00225"></a>00225 fullpath += filename; <a name="l00226"></a>00226 } <a name="l00227"></a>00227 } <a name="l00228"></a>00228 <a name="l00234"></a>00234 <span class="preprocessor">#ifdef WIN32</span> <a name="l00235"></a>00235 <span class="preprocessor"></span>FILE* <a class="code" href="enrobage_8cpp.html#a1c21ab6ec8fa85af26fc2a335e294d50" title="Try to open the file &lt;filename&gt; searching in various directories.">fopensearch</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename, <span class="keywordtype">string</span>& fullpath) <a name="l00236"></a>00236 { <a name="l00237"></a>00237 FILE* f; <a name="l00238"></a>00238 <a name="l00239"></a>00239 <span class="keywordflow">if</span> ((f = fopen(filename, <span class="stringliteral">"r"</span>))) { <a name="l00240"></a>00240 <a class="code" href="enrobage_8cpp.html#ab6796e82ccd882d69cc1fbb28f537d01" title="Build a full pathname of &lt;filename&gt;.">buildFullPathname</a>(fullpath, filename); <a name="l00241"></a>00241 <span class="keywordflow">return</span> f; <a name="l00242"></a>00242 } <a name="l00243"></a>00243 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <a class="code" href="main_8cpp.html#aea493812dd4a239a7c0d354d5a07e191">gMasterDirectory</a>, filename))) { <a name="l00244"></a>00244 <span class="keywordflow">return</span> f; <a name="l00245"></a>00245 } <a name="l00246"></a>00246 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <a class="code" href="doc_8cpp.html#a320fc936026f318a3fc46f47ef379713">gFaustDirectory</a>, <span class="stringliteral">"architecture"</span>, filename))) { <a name="l00247"></a>00247 <span class="keywordflow">return</span> f; <a name="l00248"></a>00248 } <a name="l00249"></a>00249 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <a class="code" href="doc_8cpp.html#a2529dab7cac84bd8f69c14ee8a3cbfe2">gFaustSuperDirectory</a>, <span class="stringliteral">"architecture"</span>, filename))) { <a name="l00250"></a>00250 <span class="keywordflow">return</span> f; <a name="l00251"></a>00251 } <a name="l00252"></a>00252 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <a class="code" href="doc_8cpp.html#a09fc40a224a32f929decbac5a21140ef">gFaustSuperSuperDirectory</a>, <span class="stringliteral">"architecture"</span>, filename))) { <a name="l00253"></a>00253 <span class="keywordflow">return</span> f; <a name="l00254"></a>00254 } <a name="l00255"></a>00255 <span class="keywordflow">return</span> 0; <a name="l00256"></a>00256 } <a name="l00257"></a>00257 <span class="preprocessor">#else</span> <a name="l00258"></a><a class="code" href="enrobage_8hh.html#a1c21ab6ec8fa85af26fc2a335e294d50">00258</a> <span class="preprocessor"></span>FILE* <a class="code" href="enrobage_8cpp.html#a1c21ab6ec8fa85af26fc2a335e294d50" title="Try to open the file &lt;filename&gt; searching in various directories.">fopensearch</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* filename, <span class="keywordtype">string</span>& fullpath) <a name="l00259"></a>00259 { <a name="l00260"></a>00260 FILE* f; <a name="l00261"></a>00261 <a name="l00262"></a>00262 <a name="l00263"></a>00263 <span class="keywordflow">if</span> ((f = fopen(filename, <span class="stringliteral">"r"</span>))) { <a name="l00264"></a>00264 <a class="code" href="enrobage_8cpp.html#ab6796e82ccd882d69cc1fbb28f537d01" title="Build a full pathname of &lt;filename&gt;.">buildFullPathname</a>(fullpath, filename); <a name="l00265"></a>00265 <span class="keywordflow">return</span> f; <a name="l00266"></a>00266 } <a name="l00267"></a>00267 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <a class="code" href="main_8cpp.html#aea493812dd4a239a7c0d354d5a07e191">gMasterDirectory</a>, filename))) { <a name="l00268"></a>00268 <span class="keywordflow">return</span> f; <a name="l00269"></a>00269 } <a name="l00270"></a>00270 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <a class="code" href="doc_8cpp.html#a320fc936026f318a3fc46f47ef379713">gFaustDirectory</a>, <span class="stringliteral">"architecture"</span>, filename))) { <a name="l00271"></a>00271 <span class="keywordflow">return</span> f; <a name="l00272"></a>00272 } <a name="l00273"></a>00273 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <a class="code" href="doc_8cpp.html#a2529dab7cac84bd8f69c14ee8a3cbfe2">gFaustSuperDirectory</a>, <span class="stringliteral">"architecture"</span>, filename))) { <a name="l00274"></a>00274 <span class="keywordflow">return</span> f; <a name="l00275"></a>00275 } <a name="l00276"></a>00276 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <a class="code" href="doc_8cpp.html#a09fc40a224a32f929decbac5a21140ef">gFaustSuperSuperDirectory</a>, <span class="stringliteral">"architecture"</span>, filename))) { <a name="l00277"></a>00277 <span class="keywordflow">return</span> f; <a name="l00278"></a>00278 } <a name="l00279"></a>00279 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <span class="stringliteral">"/usr/local/lib/faust"</span>, filename))) { <a name="l00280"></a>00280 <span class="keywordflow">return</span> f; <a name="l00281"></a>00281 } <a name="l00282"></a>00282 <span class="keywordflow">if</span> ((f = <a class="code" href="enrobage_8cpp.html#a41d4dcc54245881ea5690627e56c7f4c" title="Try to open the file &#39;&lt;dir&gt;/&lt;filename&gt;&#39;.">fopenat</a>(fullpath, <span class="stringliteral">"/usr/lib/faust"</span>, filename))) { <a name="l00283"></a>00283 <span class="keywordflow">return</span> f; <a name="l00284"></a>00284 } <a name="l00285"></a>00285 <span class="keywordflow">return</span> 0; <a name="l00286"></a>00286 } <a name="l00287"></a>00287 <span class="preprocessor">#endif</span> <a name="l00288"></a>00288 <span class="preprocessor"></span> <a name="l00289"></a>00289 <a name="l00297"></a>00297 <span class="preprocessor">#ifndef DIR_SEPARATOR</span> <a name="l00298"></a><a class="code" href="enrobage_8cpp.html#a0920890c442b665b0c6609fa796e9047">00298</a> <span class="preprocessor"></span><span class="preprocessor">#define DIR_SEPARATOR '/'</span> <a name="l00299"></a>00299 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00300"></a>00300 <span class="preprocessor"></span> <a name="l00301"></a>00301 <span class="preprocessor">#ifdef WIN32</span> <a name="l00302"></a>00302 <span class="preprocessor"></span><span class="preprocessor">#define HAVE_DOS_BASED_FILE_SYSTEM</span> <a name="l00303"></a>00303 <span class="preprocessor"></span><span class="preprocessor">#ifndef DIR_SEPARATOR_2 </span> <a name="l00304"></a>00304 <span class="preprocessor"></span><span class="preprocessor">#define DIR_SEPARATOR_2 '\\'</span> <a name="l00305"></a>00305 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00306"></a>00306 <span class="preprocessor"></span><span class="preprocessor">#endif</span> <a name="l00307"></a>00307 <span class="preprocessor"></span> <a name="l00308"></a>00308 <span class="comment">/* Define IS_DIR_SEPARATOR. */</span> <a name="l00309"></a>00309 <span class="preprocessor">#ifndef DIR_SEPARATOR_2</span> <a name="l00310"></a><a class="code" href="enrobage_8cpp.html#a9062ad017719f7653eb498d61ed41d55">00310</a> <span class="preprocessor"></span><span class="preprocessor"># define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)</span> <a name="l00311"></a>00311 <span class="preprocessor"></span><span class="preprocessor">#else </span><span class="comment">/* DIR_SEPARATOR_2 */</span> <a name="l00312"></a>00312 <span class="preprocessor"># define IS_DIR_SEPARATOR(ch) \</span> <a name="l00313"></a>00313 <span class="preprocessor">(((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))</span> <a name="l00314"></a>00314 <span class="preprocessor"></span><span class="preprocessor">#endif </span><span class="comment">/* DIR_SEPARATOR_2 */</span> <a name="l00315"></a>00315 <a name="l00316"></a><a class="code" href="enrobage_8hh.html#a73496d20a5f06ebb81a3ce1cc6d39877">00316</a> <span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="enrobage_8cpp.html#a73496d20a5f06ebb81a3ce1cc6d39877">filebasename</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* <a class="code" href="symbol_8hh.html#a8243134fbbd9d924ebbb3f833922e310" title="Returns the name of a symbol.">name</a>) <a name="l00317"></a>00317 { <a name="l00318"></a>00318 <span class="preprocessor">#if defined (HAVE_DOS_BASED_FILE_SYSTEM)</span> <a name="l00319"></a>00319 <span class="preprocessor"></span> <span class="comment">/* Skip over the disk name in MSDOS pathnames. */</span> <a name="l00320"></a>00320 <span class="keywordflow">if</span> (isalpha(name[0]) && name[1] == <span class="charliteral">':'</span>) <a name="l00321"></a>00321 name += 2; <a name="l00322"></a>00322 <span class="preprocessor">#endif</span> <a name="l00323"></a>00323 <span class="preprocessor"></span> <a name="l00324"></a>00324 <span class="keyword">const</span> <span class="keywordtype">char</span>* base; <a name="l00325"></a>00325 <span class="keywordflow">for</span> (base = name; *name; name++) <a name="l00326"></a>00326 { <a name="l00327"></a>00327 <span class="keywordflow">if</span> (<a class="code" href="enrobage_8cpp.html#a9062ad017719f7653eb498d61ed41d55">IS_DIR_SEPARATOR</a> (*name)) <a name="l00328"></a>00328 { <a name="l00329"></a>00329 base = name + 1; <a name="l00330"></a>00330 } <a name="l00331"></a>00331 } <a name="l00332"></a>00332 <span class="keywordflow">return</span> base; <a name="l00333"></a>00333 } <a name="l00334"></a>00334 </pre></div></div> <hr class="footer"/><address style="text-align: right;"><small>Generated on Wed Apr 28 23:59:58 2010 for FAUST compiler by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.3 </small></address> </body> </html>