33#include "../base/Variant.h"
49#include <mach-o/dyld.h>
50#include <CoreFoundation/CFBundle.h>
51#elif defined(PEBL_WIN32)
66#if defined( PEBL_LINUX)
77 std::list<string>::iterator i=files.begin();
79 while(i != files.end())
92#define OP OP2(EXECNAME)
98 string peblname =
"pebl2";
107 PError::SignalWarning(
"Warning: BinReloc failed to initialize.\n Will fallback to current directory.\n");
111 std::cerr <<
"Executable file located at: [" <<
br_find_exe(
"") <<
"].\n";
115 if (exe_dir !=
NULL) {
117 basedir = string(exe_dir) + string(
"/../");
118 std::cerr <<
"Executable directory: [" << exe_dir <<
"]\n";
119 std::cerr <<
"Base resources found at: [" << basedir <<
"]\n";
124 std::cerr <<
"Using current directory as base.\n";
151#elif defined (PEBL_EMSCRIPTEN)
161 std::list<string>::iterator i=files.begin();
163 while(i != files.end())
176 string basedir =
"/usr/local/share/pebl2/";
204#elif defined PEBL_OSX
213 CFBundleRef mainBundle = CFBundleGetMainBundle();
214 CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
216 if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
220 CFRelease(resourcesURL);
222 std::string basedir = (std::string)path +
"/";
233 std::list<string>::iterator i=files.begin();
235 while(i != files.end())
285 TCHAR szPath[MAX_PATH];
287 if( !GetModuleFileName(
NULL, szPath, MAX_PATH ) )
313 std::list<string>::iterator i=files.begin();
314 while(i != files.end())
364 mPathList.push_back(pathname);
375 unsigned long int lengthp;
376 unsigned long int lengthfilename;
378 std::list<string>::const_iterator p = mPathList.begin();
380 while(p != mPathList.end())
382 lengthp = (*p).size();
383 lengthfilename = filename.size();
385 tmp = (*p) + filename;
390 if(stat(tmp.c_str(), &st)==0)
414 char separator =
'/';
415#elif defined PEBL_WIN32
416 char separator =
'\\';
418 char separator =
'\\';
419#elif defined PEBL_EMSCRIPTEN
420 char separator =
'/';
426 if(pathname[pathname.size()-1] == separator)
437 out <<
"--------------------------------------\n";
438 out <<
"Path List:\n";
439 std::list<string>::const_iterator p = mPathList.begin();
440 while(p != mPathList.end())
446 out <<
"--------------------------------------\n";
452 return path.
Print(out);
int br_init(BrInitError *error)
char * br_find_exe_dir(const char *default_dir)
char * br_find_exe(const char *default_exe)
ostream & operator<<(ostream &out, const PEBLPath &path)
const string MergePathAndFile(const string &path, const string &file)
std::string FindFile(const string &filename)
void AddToPathList(const string &s)
std::ostream & Print(std::ostream &out) const
void Initialize(std::list< std::string >)
bool IsDirectory(const string &pathname)
const std::string StripFile(const std::string &file)
void SignalWarning(const std::string &message)
void SignalFatalError(const std::string &message)