Commit 36e55865 authored by kintel's avatar kintel

Fixed path handling under Mac OS X

parent 1d40e5a0
...@@ -199,20 +199,29 @@ void WinEDA_App::InitOnLineHelp() ...@@ -199,20 +199,29 @@ void WinEDA_App::InitOnLineHelp()
/*******************************/ /*******************************/
bool WinEDA_App::SetBinDir() bool WinEDA_App::SetBinDir()
/*******************************/ /*******************************/
// Find the path to the executable and store it in WinEDA_App::m_BinDir
/*
* Analyse la ligne de commande pour retrouver le chemin de l'executable
* Sauve en WinEDA_App::m_BinDir le repertoire de l'executable
*/
{ {
/* Calcul du chemin ou se trouve l'executable */
#ifdef __UNIX__
/* Sous LINUX ptarg[0] ne donne pas le chemin complet de l'executable, #ifdef __APPLE__
* il faut le retrouver par la commande "which <filename> si aucun // Derive path from location of the app bundle
* chemin n'est donne */ CFBundleRef mainBundle = CFBundleGetMainBundle();
if (mainBundle == NULL) return false;
CFURLRef urlref = CFBundleCopyBundleURL(mainBundle);
if (urlref == NULL) return false;
CFStringRef str = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle);
if (str == NULL) return false;
char *native_str = NULL;
int len = CFStringGetMaximumSizeForEncoding(CFStringGetLength(str),
kCFStringEncodingUTF8) + 1;
native_str = new char[len];
CFStringGetCString(str, native_str, len, kCFStringEncodingUTF8);
m_BinDir = CONV_FROM_UTF8(native_str);
delete[] native_str;
#elif defined(__UNIX__)
// Under Linux, if argv[0] doesn't the complete path to the executable,
// it's necessary to obtain it using "which <filename>".
FILE* ftmp; FILE* ftmp;
#define TMP_FILE "/tmp/kicad.tmp" #define TMP_FILE "/tmp/kicad.tmp"
...@@ -223,7 +232,7 @@ bool WinEDA_App::SetBinDir() ...@@ -223,7 +232,7 @@ bool WinEDA_App::SetBinDir()
FileName[0] = 0; FileName[0] = 0;
str_arg0 = argv[0]; str_arg0 = argv[0];
if( strchr( (const char*) argv[0], '/' ) == NULL ) /* pas de chemin */ if( strchr( (const char*) argv[0], '/' ) == NULL ) // no path
{ {
sprintf( FileName, "which %s > %s", CONV_TO_UTF8( str_arg0 ), TMP_FILE ); sprintf( FileName, "which %s > %s", CONV_TO_UTF8( str_arg0 ), TMP_FILE );
ii = system( FileName ); ii = system( FileName );
......
...@@ -464,19 +464,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para ...@@ -464,19 +464,7 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& para
wxString FullFileName; wxString FullFileName;
#ifdef __WXMAC__
// Mac part
wxGetEnv( "HOME", &FullFileName );
FullFileName += wxString( "/bin/" ) + ExecFile;
if( !wxFileExists( FullFileName ) )
{
FullFileName = FindKicadFile( ExecFile ); FullFileName = FindKicadFile( ExecFile );
}
#else
FullFileName = FindKicadFile( ExecFile );
#endif
if( wxFileExists( FullFileName ) ) if( wxFileExists( FullFileName ) )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment