enrobage.hh File Reference

#include <stdio.h>
#include <string.h>
#include <string>
#include <fstream>
#include <iostream>
Include dependency graph for enrobage.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void copyFirstHalf (FILE *file, FILE *dst)
void copySecondHalf (FILE *file, FILE *dst)
void copyZeroHalf (FILE *file, FILE *dst)
void copyFile (FILE *file, FILE *dst)
void streamCopyUntil (istream &src, ostream &dst, const string &until)
 Copy src to dst until specific line.
void streamCopyUntilEnd (istream &src, ostream &dst)
 Copy src to dst until end.
void streamCopy (istream &src, ostream &dst)
 Copy src to dst.
ifstream * open_arch_stream (const char *filename)
 Try to open an architecture file searching in various directories.
FILE * fopensearch (const char *filename, string &fullpath)
 Try to open the file <filename> searching in various directories.
bool check_file (const char *filename)
 Check if a file exists.
const char * filebasename (const char *name)

Function Documentation

bool check_file ( const char *  filename  ) 

Check if a file exists.

Returns:
true if the file exist, false otherwise

Definition at line 132 of file enrobage.cpp.

Referenced by process_cmdline().

00133 {
00134     FILE* f = fopen(filename, "r");
00135     
00136     if (f == NULL) {
00137         fprintf(stderr, "faust: "); perror(filename);
00138     } else {
00139         fclose(f);
00140     }
00141     return f != NULL;
00142 }

Here is the caller graph for this function:

void copyFile ( FILE *  file,
FILE *  dst 
)
void copyFirstHalf ( FILE *  file,
FILE *  dst 
)
void copySecondHalf ( FILE *  file,
FILE *  dst 
)
void copyZeroHalf ( FILE *  file,
FILE *  dst 
)
const char* filebasename ( const char *  name  ) 

Definition at line 329 of file enrobage.cpp.

References IS_DIR_SEPARATOR.

Referenced by copyFaustSources(), and printfaustlisting().

00330 {
00331 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
00332     /* Skip over the disk name in MSDOS pathnames. */
00333     if (isalpha(name[0]) && name[1] == ':') 
00334         name += 2;
00335 #endif
00336 
00337     const char* base;
00338     for (base = name; *name; name++)
00339     {
00340         if (IS_DIR_SEPARATOR (*name))
00341         {
00342             base = name + 1;
00343         }
00344     }
00345     return base;
00346 }

Here is the caller graph for this function:

FILE* fopensearch ( const char *  filename,
string &  fullpath 
)

Try to open the file <filename> searching in various directories.

If succesful place its full pathname in the string <fullpath>

Definition at line 266 of file enrobage.cpp.

References buildFullPathname(), fopenat(), gFaustDirectory, gFaustSuperDirectory, gFaustSuperSuperDirectory, and gMasterDirectory.

Referenced by SourceReader::parse().

00267 {   
00268     FILE* f;
00269 
00270 
00271     if ((f = fopen(filename, "r"))) { 
00272         buildFullPathname(fullpath, filename); 
00273         return f;
00274     }
00275     if ((f = fopenat(fullpath, gMasterDirectory, filename))) { 
00276         return f;
00277     }
00278     if ((f = fopenat(fullpath, gFaustDirectory, "architecture", filename))) { 
00279         return f;
00280     }
00281     if ((f = fopenat(fullpath, gFaustSuperDirectory, "architecture", filename))) { 
00282         return f;
00283     }
00284     if ((f = fopenat(fullpath, gFaustSuperSuperDirectory, "architecture", filename))) { 
00285         return f;
00286     }
00287 #ifdef INSTALL_PREFIX
00288     if ((f = fopenat(fullpath, INSTALL_PREFIX "/lib/faust", filename))) { 
00289         return f;
00290     }
00291 #endif
00292     if ((f = fopenat(fullpath, "/usr/local/lib/faust", filename))) { 
00293         return f;
00294     }
00295     if ((f = fopenat(fullpath, "/usr/lib/faust", filename))) { 
00296         return f;
00297     }
00298     return 0;
00299 }

Here is the call graph for this function:

Here is the caller graph for this function:

ifstream* open_arch_stream ( const char *  filename  ) 

Try to open an architecture file searching in various directories.

Definition at line 69 of file enrobage.cpp.

References FAUST_PATH_MAX, gFaustDirectory, gFaustSuperDirectory, and gFaustSuperSuperDirectory.

Referenced by main(), and openArchFile().

00070 {
00071     char    buffer[FAUST_PATH_MAX];
00072     char*   old = getcwd (buffer, FAUST_PATH_MAX);
00073     int     err;
00074 
00075     {
00076         ifstream* f = new ifstream();
00077         f->open(filename, ifstream::in); if (f->is_open()) return f; else delete f;
00078     }
00079     if ( (chdir(gFaustDirectory.c_str())==0) && (chdir("architecture")==0) ) {
00080         //cout << "enrobage.cpp : 'architecture' directory found in gFaustDirectory" << endl;
00081         ifstream* f = new ifstream();
00082         f->open(filename, ifstream::in);
00083         if (f->good()) return f; else delete f;
00084     }
00085     err = chdir(old);
00086     if ((chdir(gFaustSuperDirectory.c_str())==0) && (chdir("architecture")==0) ) {
00087         //cout << "enrobage.cpp : 'architecture' directory found in gFaustSuperDirectory" << endl;
00088         ifstream* f = new ifstream();
00089         f->open(filename, ifstream::in);
00090         if (f->good()) return f; else delete f;
00091     }
00092     err = chdir(old);
00093     if ((chdir(gFaustSuperSuperDirectory.c_str())==0) && (chdir("architecture")==0) ) {
00094         //cout << "enrobage.cpp : 'architecture' directory found in gFaustSuperSuperDirectory" << endl;
00095         ifstream* f = new ifstream();
00096         f->open(filename, ifstream::in);
00097         if (f->good()) return f; else delete f;
00098     }
00099 #ifdef INSTALL_PREFIX
00100     err = chdir(old);
00101     if (chdir(INSTALL_PREFIX "/lib/faust")==0) {
00102         ifstream* f = new ifstream();
00103         f->open(filename); 
00104         if (f->good()) return f; else delete f;
00105     }
00106 #endif
00107     err = chdir(old);
00108     if (chdir("/usr/local/lib/faust")==0) {
00109         ifstream* f = new ifstream();
00110         f->open(filename); 
00111         if (f->good()) return f; else delete f;
00112     }
00113     err = chdir(old);
00114     if (chdir("/usr/lib/faust")==0) {
00115         ifstream* f = new ifstream();
00116         f->open(filename); 
00117         if (f->good()) return f; else delete f;
00118     }
00119     
00120     return 0;
00121 }

Here is the caller graph for this function:

void streamCopy ( istream &  src,
ostream &  dst 
)

Copy src to dst.

Definition at line 50 of file enrobage.cpp.

Referenced by main().

00051 { 
00052     string  s;
00053     while ( getline(src,s)) dst << s << endl;
00054 }

Here is the caller graph for this function:

void streamCopyUntil ( istream &  src,
ostream &  dst,
const string &  until 
)

Copy src to dst until specific line.

Definition at line 41 of file enrobage.cpp.

Referenced by main().

00042 { 
00043     string  s;
00044     while ( getline(src,s) && (s != until) ) dst << s << endl;
00045 }

Here is the caller graph for this function:

void streamCopyUntilEnd ( istream &  src,
ostream &  dst 
)

Copy src to dst until end.

Definition at line 59 of file enrobage.cpp.

Referenced by main().

00060 { 
00061     string  s;
00062     while ( getline(src,s) ) dst << s << endl;
00063 }

Here is the caller graph for this function:

Generated on Thu Jul 15 16:15:38 2010 for FAUST compiler by  doxygen 1.6.3