Loading common/gestfich.cpp +554 −504 Original line number Original line Diff line number Diff line Loading @@ -86,16 +86,16 @@ wxString MakeReducedFileName( const wxString & fullfilename, /***************************************************************************/ /***************************************************************************/ /* Calcule le nom "reduit" d'un fichier d'apres les chaines /* Calcule le nom "reduit" d'un fichier d'apres les chaines fullfilename = nom complet * fullfilename = nom complet default_path = prefixe (chemin) par defaut * default_path = prefixe (chemin) par defaut default_ext = extension par defaut * default_ext = extension par defaut * retourne le nom reduit, c'est a dire: * retourne le nom reduit, c'est a dire: sans le chemin si le chemin est default_path * sans le chemin si le chemin est default_path avec ./ si si le chemin est le chemin courant * avec ./ si si le chemin est le chemin courant sans l'extension si l'extension est default_ext * sans l'extension si l'extension est default_ext * Renvoie un chemin en notation unix ('/' en separateur de repertoire) * Renvoie un chemin en notation unix ('/' en separateur de repertoire) */ */ { { wxString reduced_filename = fullfilename; wxString reduced_filename = fullfilename; Loading @@ -106,7 +106,8 @@ wxString Cwd, ext, path; path = wxPathOnly( reduced_filename ) + UNIX_STRING_DIR_SEP; path = wxPathOnly( reduced_filename ) + UNIX_STRING_DIR_SEP; reduced_filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); reduced_filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); if ( Cwd.Last() != '/' ) Cwd += UNIX_STRING_DIR_SEP; if( Cwd.Last() != '/' ) Cwd += UNIX_STRING_DIR_SEP; path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); #ifdef __WINDOWS__ #ifdef __WINDOWS__ Loading Loading @@ -140,26 +141,24 @@ wxString Cwd, ext, path; if( !ext.IsEmpty() && reduced_filename.Contains( ext ) ) if( !ext.IsEmpty() && reduced_filename.Contains( ext ) ) reduced_filename.Truncate( reduced_filename.Length() - ext.Length() ); reduced_filename.Truncate( reduced_filename.Length() - ext.Length() ); return(reduced_filename); return reduced_filename; } } /***************************************************************************/ /***************************************************************************/ wxString MakeFileName( const wxString& dir, wxString MakeFileName( const wxString& dir, const wxString& shortname, const wxString& ext ) const wxString& shortname, const wxString& ext ) /***************************************************************************/ /***************************************************************************/ /* Calcule le nom complet d'un fichier d'apres les chaines /* Calcule le nom complet d'un fichier d'apres les chaines dir = prefixe (chemin) (peut etre "") * dir = prefixe (chemin) (peut etre "") shortname = nom avec ou sans chemin ou extension * shortname = nom avec ou sans chemin ou extension ext = extension (peut etre "") * ext = extension (peut etre "") * si shortname possede deja un chemin ou une extension, elles * si shortname possede deja un chemin ou une extension, elles ne seront pas modifiees * ne seront pas modifiees * retourne la chaine calculee * retourne la chaine calculee */ */ { { wxString fullfilename; wxString fullfilename; Loading @@ -178,7 +177,8 @@ int ii; fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); /* Placement de l'extension s'il n'y en a pas deja une */ /* Placement de l'extension s'il n'y en a pas deja une */ if( ext.IsEmpty() ) return(fullfilename); if( ext.IsEmpty() ) return fullfilename; /* Recherche d'une eventuelle extension */ /* Recherche d'une eventuelle extension */ ii = fullfilename.Length(); /* Pointe la fin du texte */ ii = fullfilename.Length(); /* Pointe la fin du texte */ Loading @@ -194,43 +194,49 @@ int ii; break; break; } } return(fullfilename); return fullfilename; } } /*************************************************************************/ /*************************************************************************/ void ChangeFileNameExt( wxString& FullFileName, const wxString& NewExt ) void ChangeFileNameExt( wxString& FullFileName, const wxString& NewExt ) /**************************************************************************/ /**************************************************************************/ /* Change l'extension du "filename FullFileName" en NewExt. /* Change l'extension du "filename FullFileName" en NewExt. */ */ { { wxString FileName; wxString FileName; FileName = FullFileName.BeforeLast( '.' ); FileName = FullFileName.BeforeLast( '.' ); if ( !FileName.IsEmpty() ) FileName += NewExt; if( !FileName.IsEmpty() ) else FileName = FullFileName + NewExt; FileName += NewExt; else FileName = FullFileName + NewExt; if( FileName.StartsWith( wxT( "\"" ) ) && ( FileName.Last() != '"' ) ) if( FileName.StartsWith( wxT( "\"" ) ) && ( FileName.Last() != '"' ) ) FileName += wxT( "\"" ); FileName += wxT( "\"" ); FullFileName = FileName; FullFileName = FileName; } } /*******************************************/ /*******************************************/ void AddDelimiterString( wxString& string ) void AddDelimiterString( wxString& string ) /*******************************************/ /*******************************************/ /* ajoute un " en debut et fin de string s'il n'y en a pas deja. /* ajoute un " en debut et fin de string s'il n'y en a pas deja. */ */ { { wxString text; wxString text; if ( ! string.StartsWith( wxT("\"")) ) text = wxT("\""); if( !string.StartsWith( wxT( "\"" ) ) ) text = wxT( "\"" ); text += string; text += string; if( (text.Last() != '"' ) || (text.length() <= 1) ) text += wxT("\""); if( (text.Last() != '"' ) || (text.length() <= 1) ) text += wxT( "\"" ); string = text; string = text; } } /*************************************/ /*************************************/ /* Fonction de selection de Repertoires */ /* Fonction de selection de Repertoires */ /*************************************/ /*************************************/ Loading Loading @@ -262,6 +268,7 @@ bool selected = FALSE; return selected; return selected; } } /******************************/ /******************************/ /* Selection file dialog box: */ /* Selection file dialog box: */ /******************************/ /******************************/ Loading @@ -283,7 +290,8 @@ wxString defaultpath = Path; defaultname.Replace( wxT( "/" ), STRING_DIR_SEP ); defaultname.Replace( wxT( "/" ), STRING_DIR_SEP ); defaultpath.Replace( wxT( "/" ), STRING_DIR_SEP ); defaultpath.Replace( wxT( "/" ), STRING_DIR_SEP ); if ( defaultpath.IsEmpty() ) defaultpath = wxGetCwd(); if( defaultpath.IsEmpty() ) defaultpath = wxGetCwd(); wxSetWorkingDirectory( defaultpath ); wxSetWorkingDirectory( defaultpath ); Loading @@ -296,31 +304,34 @@ wxString defaultpath = Path; Frame, Frame, Pos.x, Pos.y ); Pos.x, Pos.y ); if ( keep_working_directory ) wxSetWorkingDirectory(curr_cwd); if( keep_working_directory ) wxSetWorkingDirectory( curr_cwd ); return fullfilename; return fullfilename; } } /********************************************************/ /********************************************************/ wxString FindKicadHelpPath( void ) wxString FindKicadHelpPath( void ) /********************************************************/ /********************************************************/ /* Find absolute path for kicad/help (or kicad/help/<language>) */ /* Find absolute path for kicad/help (or kicad/help/<language>) */ /* Find path kicad/help/xx/ ou kicad/help/: from BinDir else from environment variable KICAD else from one of s_HelpPathList typically c:\kicad\help or /usr/local/kicad/help or /usr/share/doc/kicad (must have kicad in path name) xx = iso639-1 language id (2 letters (generic) or 4 letters): fr = french (or fr_FR) en = English (or en_GB or en_US ...) de = deutch es = spanish pt = portuguese (or pt_BR ...) default = en (if not found = fr) /* Find path kicad/help/xx/ ou kicad/help/: * from BinDir * else from environment variable KICAD * else from one of s_HelpPathList * typically c:\kicad\help or /usr/local/kicad/help or /usr/share/doc/kicad * (must have kicad in path name) * * xx = iso639-1 language id (2 letters (generic) or 4 letters): * fr = french (or fr_FR) * en = English (or en_GB or en_US ...) * de = deutch * es = spanish * pt = portuguese (or pt_BR ...) * * default = en (if not found = fr) * */ */ { { wxString FullPath, LangFullPath, tmp; wxString FullPath, LangFullPath, tmp; Loading @@ -329,7 +340,8 @@ bool PathFound = FALSE; /* find kicad/help/ */ /* find kicad/help/ */ tmp = EDA_Appl->m_BinDir; tmp = EDA_Appl->m_BinDir; if ( tmp.Last() == '/' ) tmp.RemoveLast(); if( tmp.Last() == '/' ) tmp.RemoveLast(); FullPath = tmp.BeforeLast( '/' ); // Idem cd .. FullPath = tmp.BeforeLast( '/' ); // Idem cd .. FullPath += wxT( "/help/" ); FullPath += wxT( "/help/" ); LocaleString = EDA_Appl->m_Locale->GetCanonicalName(); LocaleString = EDA_Appl->m_Locale->GetCanonicalName(); Loading @@ -340,25 +352,29 @@ bool PathFound = FALSE; #endif #endif if( path_tmp.Contains( wxT( "kicad" ) ) ) if( path_tmp.Contains( wxT( "kicad" ) ) ) { { if ( wxDirExists(FullPath) ) PathFound = TRUE; if( wxDirExists( FullPath ) ) PathFound = TRUE; } } /* find kicad/help/ from environment variable KICAD */ /* find kicad/help/ from environment variable KICAD */ if( !PathFound && EDA_Appl->m_Env_Defined ) if( !PathFound && EDA_Appl->m_Env_Defined ) { { FullPath = EDA_Appl->m_KicadEnv + wxT( "/help/" ); FullPath = EDA_Appl->m_KicadEnv + wxT( "/help/" ); if ( wxDirExists(FullPath) ) PathFound = TRUE; if( wxDirExists( FullPath ) ) PathFound = TRUE; } } /* find kicad/help/ from default path list: /* find kicad/help/ from default path list: /usr/local/kicad/help or c:/kicad/help * /usr/local/kicad/help or c:/kicad/help (see s_HelpPathList) */ * (see s_HelpPathList) */ int ii = 0; int ii = 0; while( !PathFound ) while( !PathFound ) { { FullPath = s_HelpPathList[ii++]; FullPath = s_HelpPathList[ii++]; if ( FullPath == wxT("end_list") ) break; if( FullPath == wxT( "end_list" ) ) if ( wxDirExists(FullPath) ) PathFound = TRUE; break; if( wxDirExists( FullPath ) ) PathFound = TRUE; } } Loading @@ -366,70 +382,82 @@ bool PathFound = FALSE; { { LangFullPath = FullPath + LocaleString + UNIX_STRING_DIR_SEP; LangFullPath = FullPath + LocaleString + UNIX_STRING_DIR_SEP; if ( wxDirExists(LangFullPath) ) return LangFullPath; if( wxDirExists( LangFullPath ) ) return LangFullPath; LangFullPath = FullPath + LocaleString.Left( 2 ) + UNIX_STRING_DIR_SEP; LangFullPath = FullPath + LocaleString.Left( 2 ) + UNIX_STRING_DIR_SEP; if ( wxDirExists(LangFullPath) ) return LangFullPath; if( wxDirExists( LangFullPath ) ) return LangFullPath; LangFullPath = FullPath + wxT( "en/" ); LangFullPath = FullPath + wxT( "en/" ); if ( wxDirExists(LangFullPath) ) return LangFullPath; if( wxDirExists( LangFullPath ) ) return LangFullPath; else else { { LangFullPath = FullPath + wxT( "fr/" ); LangFullPath = FullPath + wxT( "fr/" ); if ( wxDirExists(LangFullPath) ) return LangFullPath; if( wxDirExists( LangFullPath ) ) return LangFullPath; } } return FullPath; return FullPath; } } return wxEmptyString; return wxEmptyString; } } /********************************************************/ /********************************************************/ wxString FindKicadFile( const wxString& shortname ) wxString FindKicadFile( const wxString& shortname ) /********************************************************/ /********************************************************/ /* Search the executable file shortname in kicad binary path /* Search the executable file shortname in kicad binary path and return full file name if found or shortname * and return full file name if found or shortname kicad binary path is * kicad binary path is kicad/winexe or kicad/linux * kicad/winexe or kicad/linux * kicad binary path is found from: * kicad binary path is found from: BinDir * BinDir or environment variable KICAD * or environment variable KICAD or (default) c:\kicad ou /usr/local/kicad * or (default) c:\kicad ou /usr/local/kicad or default binary path * or default binary path */ */ { { wxString FullFileName; wxString FullFileName; /* test de la presence du fichier shortname dans le repertoire de /* test de la presence du fichier shortname dans le repertoire de des binaires de kicad */ * des binaires de kicad */ FullFileName = EDA_Appl->m_BinDir + shortname; FullFileName = EDA_Appl->m_BinDir + shortname; if ( wxFileExists(FullFileName) ) return FullFileName; if( wxFileExists( FullFileName ) ) return FullFileName; /* test de la presence du fichier shortname dans le repertoire /* test de la presence du fichier shortname dans le repertoire defini par la variable d'environnement KICAD */ * defini par la variable d'environnement KICAD */ if( EDA_Appl->m_Env_Defined ) if( EDA_Appl->m_Env_Defined ) { { FullFileName = EDA_Appl->m_KicadEnv + shortname; FullFileName = EDA_Appl->m_KicadEnv + shortname; if ( wxFileExists(FullFileName) ) return FullFileName; if( wxFileExists( FullFileName ) ) return FullFileName; } } /* find binary file from default path list: /* find binary file from default path list: /usr/local/kicad/linux or c:/kicad/winexe * /usr/local/kicad/linux or c:/kicad/winexe (see s_KicadDataPathList) */ * (see s_KicadDataPathList) */ int ii = 0; int ii = 0; while( 1 ) while( 1 ) { { if ( s_KicadBinaryPathList[ii] == wxT("end_list") ) break; if( s_KicadBinaryPathList[ii] == wxT( "end_list" ) ) break; FullFileName = s_KicadBinaryPathList[ii++] + shortname; FullFileName = s_KicadBinaryPathList[ii++] + shortname; if ( wxFileExists(FullFileName) ) return FullFileName; if( wxFileExists( FullFileName ) ) return FullFileName; } } return shortname; return shortname; } } /***********************************************************************************/ /***********************************************************************************/ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param ) int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param ) /***********************************************************************************/ /***********************************************************************************/ /* Call the executable file "ExecFile", with params "param" /* Call the executable file "ExecFile", with params "param" */ */ { { Loading @@ -437,9 +465,10 @@ wxString FullFileName; #ifdef __WXMAC__ #ifdef __WXMAC__ // Mac part // Mac part wxGetEnv( "HOME", &FullFileName ); wxGetEnv( "HOME", &FullFileName ); FullFileName += wxString("/bin/") + newExecFile; FullFileName += wxString( "/bin/" ) + ExecFile; if( !wxFileExists( FullFileName ) ) if( !wxFileExists( FullFileName ) ) { { FullFileName = FindKicadFile( ExecFile ); FullFileName = FindKicadFile( ExecFile ); Loading @@ -451,7 +480,8 @@ wxString FullFileName; if( wxFileExists( FullFileName ) ) if( wxFileExists( FullFileName ) ) { { if( !param.IsEmpty() ) FullFileName += wxT(" ") + param; if( !param.IsEmpty() ) FullFileName += wxT( " " ) + param; wxExecute( FullFileName ); wxExecute( FullFileName ); return 0; return 0; } } Loading @@ -466,16 +496,17 @@ wxString FullFileName; /****************************************************/ /****************************************************/ void SetRealLibraryPath( const wxString& shortlibname ) void SetRealLibraryPath( const wxString& shortlibname ) /****************************************************/ /****************************************************/ /* met a jour le chemin des librairies g_RealLibDirBuffer (global) /* met a jour le chemin des librairies g_RealLibDirBuffer (global) a partir de UserLibDirBuffer (global): * a partir de UserLibDirBuffer (global): Si UserLibDirBuffer non vide g_RealLibDirBuffer = g_UserLibDirBuffer. * Si UserLibDirBuffer non vide g_RealLibDirBuffer = g_UserLibDirBuffer. Sinon si variable d'environnement KICAD definie (KICAD = chemin pour kicad), * Sinon si variable d'environnement KICAD definie (KICAD = chemin pour kicad), g_UserLibDirBuffer = <KICAD>/shortlibname; * g_UserLibDirBuffer = <KICAD>/shortlibname; Sinon g_UserLibDirBuffer = <Chemin des binaires>../shortlibname/ * Sinon g_UserLibDirBuffer = <Chemin des binaires>../shortlibname/ Sinon g_UserLibDirBuffer = /usr/share/kicad/shortlibname/ * Sinon g_UserLibDirBuffer = /usr/share/kicad/shortlibname/ * Remarque: * Remarque: Les \ sont remplacs par / (a la mode Unix) * Les \ sont remplacs par / (a la mode Unix) */ */ { { bool PathFound = FALSE; bool PathFound = FALSE; Loading @@ -485,7 +516,6 @@ bool PathFound = FALSE; g_RealLibDirBuffer = g_UserLibDirBuffer; g_RealLibDirBuffer = g_UserLibDirBuffer; PathFound = TRUE; PathFound = TRUE; } } else else { { g_RealLibDirBuffer = ReturnKicadDatasPath(); g_RealLibDirBuffer = ReturnKicadDatasPath(); Loading @@ -494,25 +524,29 @@ bool PathFound = FALSE; PathFound = TRUE; PathFound = TRUE; } } g_RealLibDirBuffer += shortlibname; g_RealLibDirBuffer += shortlibname; if ( wxDirExists(g_RealLibDirBuffer) ) PathFound = TRUE; if( wxDirExists( g_RealLibDirBuffer ) ) PathFound = TRUE; } } g_RealLibDirBuffer.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); g_RealLibDirBuffer.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); if ( g_RealLibDirBuffer.Last() != '/' ) g_RealLibDirBuffer += UNIX_STRING_DIR_SEP; if( g_RealLibDirBuffer.Last() != '/' ) g_RealLibDirBuffer += UNIX_STRING_DIR_SEP; } } /***********************************/ /***********************************/ wxString ReturnKicadDatasPath( void ) wxString ReturnKicadDatasPath( void ) /***********************************/ /***********************************/ /* Retourne le chemin des donnees communes de kicad. Si variable d'environnement KICAD definie (KICAD = chemin pour kicad), retourne <KICAD>/; Sinon retourne <Chemin des binaires>/ (si "kicad" est dans le nom du chemin) Sinon retourne /usr/share/kicad/ Remarque: /* Retourne le chemin des donnees communes de kicad. Les \ sont remplacs par / (a la mode Unix) * Si variable d'environnement KICAD definie (KICAD = chemin pour kicad), * retourne <KICAD>/; * Sinon retourne <Chemin des binaires>/ (si "kicad" est dans le nom du chemin) * Sinon retourne /usr/share/kicad/ * * Remarque: * Les \ sont remplacs par / (a la mode Unix) */ */ { { bool PathFound = FALSE; bool PathFound = FALSE; Loading @@ -524,7 +558,8 @@ wxString data_path; PathFound = TRUE; PathFound = TRUE; } } else // Chemin cherche par le chemin des executables else // Chemin cherche par le chemin des executables { // le chemin est bindir../ { // le chemin est bindir../ wxString tmp = EDA_Appl->m_BinDir; wxString tmp = EDA_Appl->m_BinDir; #ifdef __WINDOWS__ #ifdef __WINDOWS__ tmp.MakeLower(); tmp.MakeLower(); Loading @@ -534,31 +569,36 @@ wxString data_path; #ifdef __WINDOWS__ #ifdef __WINDOWS__ tmp = EDA_Appl->m_BinDir; tmp = EDA_Appl->m_BinDir; #endif #endif if ( tmp.Last() == '/' ) tmp.RemoveLast(); if( tmp.Last() == '/' ) tmp.RemoveLast(); data_path = tmp.BeforeLast( '/' ); // id cd ../ data_path = tmp.BeforeLast( '/' ); // id cd ../ data_path += UNIX_STRING_DIR_SEP; data_path += UNIX_STRING_DIR_SEP; if ( wxDirExists(data_path) ) PathFound = TRUE; if( wxDirExists( data_path ) ) PathFound = TRUE; } } } } /* find kicad from default path list: /* find kicad from default path list: /usr/local/kicad/ or c:/kicad/ * /usr/local/kicad/ or c:/kicad/ (see s_KicadDataPathList) */ * (see s_KicadDataPathList) */ int ii = 0; int ii = 0; while( !PathFound ) while( !PathFound ) { { if ( s_KicadDataPathList[ii] == wxT("end_list") ) break; if( s_KicadDataPathList[ii] == wxT( "end_list" ) ) break; data_path = s_KicadDataPathList[ii++]; data_path = s_KicadDataPathList[ii++]; if ( wxDirExists(data_path) ) PathFound = TRUE; if( wxDirExists( data_path ) ) PathFound = TRUE; } } if( PathFound ) if( PathFound ) { { data_path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); data_path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); if ( data_path.Last() != '/' ) data_path += UNIX_STRING_DIR_SEP; if( data_path.Last() != '/' ) data_path += UNIX_STRING_DIR_SEP; } } else else data_path.Empty(); data_path.Empty(); return data_path; return data_path; } } Loading @@ -567,6 +607,7 @@ wxString data_path; /***************************/ /***************************/ wxString GetEditorName( void ) wxString GetEditorName( void ) /***************************/ /***************************/ /* Return the prefered editor name /* Return the prefered editor name */ */ { { Loading @@ -580,6 +621,7 @@ wxString GetEditorName(void) { { DisplayInfo( NULL, _( "No default editor found, you must choose it" ) ); DisplayInfo( NULL, _( "No default editor found, you must choose it" ) ); wxString mask( wxT( "*" ) ); wxString mask( wxT( "*" ) ); #ifdef __WINDOWS__ #ifdef __WINDOWS__ mask += wxT( ".exe" ); mask += wxT( ".exe" ); #endif #endif Loading @@ -602,6 +644,7 @@ wxString GetEditorName(void) return g_EditorName; return g_EditorName; } } void OpenPDF( const wxString& file ) void OpenPDF( const wxString& file ) { { wxString command; wxString command; Loading @@ -620,8 +663,10 @@ void OpenPDF( const wxString & file ) wxFileType* filetype = NULL; wxFileType* filetype = NULL; wxFileType::MessageParameters params( filename, type ); wxFileType::MessageParameters params( filename, type ); filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( wxT( ".pdf" ) ); filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( wxT( ".pdf" ) ); if (filetype ) success = filetype->GetOpenCommand( &command, params); if( filetype ) success = filetype->GetOpenCommand( &command, params ); delete filetype; delete filetype; if( !success ) if( !success ) Loading @@ -638,7 +683,8 @@ void OpenPDF( const wxString & file ) }; }; for( int i = 0; ; i++ ) for( int i = 0; ; i++ ) { { if (tries[i].IsEmpty()) break; if( tries[i].IsEmpty() ) break; if( wxFileExists( tries[i] ) ) if( wxFileExists( tries[i] ) ) { { command = tries[i] + wxT( " " ) + filename; command = tries[i] + wxT( " " ) + filename; Loading @@ -647,7 +693,8 @@ void OpenPDF( const wxString & file ) } } } } if (!command.IsEmpty()) wxExecute(command); if( !command.IsEmpty() ) wxExecute( command ); } } Loading @@ -658,14 +705,17 @@ void OpenFile( const wxString & file ) wxFileName CurrentFileName( filename ); wxFileName CurrentFileName( filename ); wxString ext, type; wxString ext, type; ext = CurrentFileName.GetExt(); ext = CurrentFileName.GetExt(); wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext ); wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext ); bool success = false; bool success = false; wxFileType::MessageParameters params( filename, type ); wxFileType::MessageParameters params( filename, type ); if (filetype) success = filetype->GetOpenCommand( &command, params); if( filetype ) success = filetype->GetOpenCommand( &command, params ); delete filetype; delete filetype; if (success && !command.IsEmpty()) wxExecute(command); if( success && !command.IsEmpty() ) wxExecute( command ); } } Loading
common/gestfich.cpp +554 −504 Original line number Original line Diff line number Diff line Loading @@ -86,16 +86,16 @@ wxString MakeReducedFileName( const wxString & fullfilename, /***************************************************************************/ /***************************************************************************/ /* Calcule le nom "reduit" d'un fichier d'apres les chaines /* Calcule le nom "reduit" d'un fichier d'apres les chaines fullfilename = nom complet * fullfilename = nom complet default_path = prefixe (chemin) par defaut * default_path = prefixe (chemin) par defaut default_ext = extension par defaut * default_ext = extension par defaut * retourne le nom reduit, c'est a dire: * retourne le nom reduit, c'est a dire: sans le chemin si le chemin est default_path * sans le chemin si le chemin est default_path avec ./ si si le chemin est le chemin courant * avec ./ si si le chemin est le chemin courant sans l'extension si l'extension est default_ext * sans l'extension si l'extension est default_ext * Renvoie un chemin en notation unix ('/' en separateur de repertoire) * Renvoie un chemin en notation unix ('/' en separateur de repertoire) */ */ { { wxString reduced_filename = fullfilename; wxString reduced_filename = fullfilename; Loading @@ -106,7 +106,8 @@ wxString Cwd, ext, path; path = wxPathOnly( reduced_filename ) + UNIX_STRING_DIR_SEP; path = wxPathOnly( reduced_filename ) + UNIX_STRING_DIR_SEP; reduced_filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); reduced_filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); Cwd.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); if ( Cwd.Last() != '/' ) Cwd += UNIX_STRING_DIR_SEP; if( Cwd.Last() != '/' ) Cwd += UNIX_STRING_DIR_SEP; path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); #ifdef __WINDOWS__ #ifdef __WINDOWS__ Loading Loading @@ -140,26 +141,24 @@ wxString Cwd, ext, path; if( !ext.IsEmpty() && reduced_filename.Contains( ext ) ) if( !ext.IsEmpty() && reduced_filename.Contains( ext ) ) reduced_filename.Truncate( reduced_filename.Length() - ext.Length() ); reduced_filename.Truncate( reduced_filename.Length() - ext.Length() ); return(reduced_filename); return reduced_filename; } } /***************************************************************************/ /***************************************************************************/ wxString MakeFileName( const wxString& dir, wxString MakeFileName( const wxString& dir, const wxString& shortname, const wxString& ext ) const wxString& shortname, const wxString& ext ) /***************************************************************************/ /***************************************************************************/ /* Calcule le nom complet d'un fichier d'apres les chaines /* Calcule le nom complet d'un fichier d'apres les chaines dir = prefixe (chemin) (peut etre "") * dir = prefixe (chemin) (peut etre "") shortname = nom avec ou sans chemin ou extension * shortname = nom avec ou sans chemin ou extension ext = extension (peut etre "") * ext = extension (peut etre "") * si shortname possede deja un chemin ou une extension, elles * si shortname possede deja un chemin ou une extension, elles ne seront pas modifiees * ne seront pas modifiees * retourne la chaine calculee * retourne la chaine calculee */ */ { { wxString fullfilename; wxString fullfilename; Loading @@ -178,7 +177,8 @@ int ii; fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); /* Placement de l'extension s'il n'y en a pas deja une */ /* Placement de l'extension s'il n'y en a pas deja une */ if( ext.IsEmpty() ) return(fullfilename); if( ext.IsEmpty() ) return fullfilename; /* Recherche d'une eventuelle extension */ /* Recherche d'une eventuelle extension */ ii = fullfilename.Length(); /* Pointe la fin du texte */ ii = fullfilename.Length(); /* Pointe la fin du texte */ Loading @@ -194,43 +194,49 @@ int ii; break; break; } } return(fullfilename); return fullfilename; } } /*************************************************************************/ /*************************************************************************/ void ChangeFileNameExt( wxString& FullFileName, const wxString& NewExt ) void ChangeFileNameExt( wxString& FullFileName, const wxString& NewExt ) /**************************************************************************/ /**************************************************************************/ /* Change l'extension du "filename FullFileName" en NewExt. /* Change l'extension du "filename FullFileName" en NewExt. */ */ { { wxString FileName; wxString FileName; FileName = FullFileName.BeforeLast( '.' ); FileName = FullFileName.BeforeLast( '.' ); if ( !FileName.IsEmpty() ) FileName += NewExt; if( !FileName.IsEmpty() ) else FileName = FullFileName + NewExt; FileName += NewExt; else FileName = FullFileName + NewExt; if( FileName.StartsWith( wxT( "\"" ) ) && ( FileName.Last() != '"' ) ) if( FileName.StartsWith( wxT( "\"" ) ) && ( FileName.Last() != '"' ) ) FileName += wxT( "\"" ); FileName += wxT( "\"" ); FullFileName = FileName; FullFileName = FileName; } } /*******************************************/ /*******************************************/ void AddDelimiterString( wxString& string ) void AddDelimiterString( wxString& string ) /*******************************************/ /*******************************************/ /* ajoute un " en debut et fin de string s'il n'y en a pas deja. /* ajoute un " en debut et fin de string s'il n'y en a pas deja. */ */ { { wxString text; wxString text; if ( ! string.StartsWith( wxT("\"")) ) text = wxT("\""); if( !string.StartsWith( wxT( "\"" ) ) ) text = wxT( "\"" ); text += string; text += string; if( (text.Last() != '"' ) || (text.length() <= 1) ) text += wxT("\""); if( (text.Last() != '"' ) || (text.length() <= 1) ) text += wxT( "\"" ); string = text; string = text; } } /*************************************/ /*************************************/ /* Fonction de selection de Repertoires */ /* Fonction de selection de Repertoires */ /*************************************/ /*************************************/ Loading Loading @@ -262,6 +268,7 @@ bool selected = FALSE; return selected; return selected; } } /******************************/ /******************************/ /* Selection file dialog box: */ /* Selection file dialog box: */ /******************************/ /******************************/ Loading @@ -283,7 +290,8 @@ wxString defaultpath = Path; defaultname.Replace( wxT( "/" ), STRING_DIR_SEP ); defaultname.Replace( wxT( "/" ), STRING_DIR_SEP ); defaultpath.Replace( wxT( "/" ), STRING_DIR_SEP ); defaultpath.Replace( wxT( "/" ), STRING_DIR_SEP ); if ( defaultpath.IsEmpty() ) defaultpath = wxGetCwd(); if( defaultpath.IsEmpty() ) defaultpath = wxGetCwd(); wxSetWorkingDirectory( defaultpath ); wxSetWorkingDirectory( defaultpath ); Loading @@ -296,31 +304,34 @@ wxString defaultpath = Path; Frame, Frame, Pos.x, Pos.y ); Pos.x, Pos.y ); if ( keep_working_directory ) wxSetWorkingDirectory(curr_cwd); if( keep_working_directory ) wxSetWorkingDirectory( curr_cwd ); return fullfilename; return fullfilename; } } /********************************************************/ /********************************************************/ wxString FindKicadHelpPath( void ) wxString FindKicadHelpPath( void ) /********************************************************/ /********************************************************/ /* Find absolute path for kicad/help (or kicad/help/<language>) */ /* Find absolute path for kicad/help (or kicad/help/<language>) */ /* Find path kicad/help/xx/ ou kicad/help/: from BinDir else from environment variable KICAD else from one of s_HelpPathList typically c:\kicad\help or /usr/local/kicad/help or /usr/share/doc/kicad (must have kicad in path name) xx = iso639-1 language id (2 letters (generic) or 4 letters): fr = french (or fr_FR) en = English (or en_GB or en_US ...) de = deutch es = spanish pt = portuguese (or pt_BR ...) default = en (if not found = fr) /* Find path kicad/help/xx/ ou kicad/help/: * from BinDir * else from environment variable KICAD * else from one of s_HelpPathList * typically c:\kicad\help or /usr/local/kicad/help or /usr/share/doc/kicad * (must have kicad in path name) * * xx = iso639-1 language id (2 letters (generic) or 4 letters): * fr = french (or fr_FR) * en = English (or en_GB or en_US ...) * de = deutch * es = spanish * pt = portuguese (or pt_BR ...) * * default = en (if not found = fr) * */ */ { { wxString FullPath, LangFullPath, tmp; wxString FullPath, LangFullPath, tmp; Loading @@ -329,7 +340,8 @@ bool PathFound = FALSE; /* find kicad/help/ */ /* find kicad/help/ */ tmp = EDA_Appl->m_BinDir; tmp = EDA_Appl->m_BinDir; if ( tmp.Last() == '/' ) tmp.RemoveLast(); if( tmp.Last() == '/' ) tmp.RemoveLast(); FullPath = tmp.BeforeLast( '/' ); // Idem cd .. FullPath = tmp.BeforeLast( '/' ); // Idem cd .. FullPath += wxT( "/help/" ); FullPath += wxT( "/help/" ); LocaleString = EDA_Appl->m_Locale->GetCanonicalName(); LocaleString = EDA_Appl->m_Locale->GetCanonicalName(); Loading @@ -340,25 +352,29 @@ bool PathFound = FALSE; #endif #endif if( path_tmp.Contains( wxT( "kicad" ) ) ) if( path_tmp.Contains( wxT( "kicad" ) ) ) { { if ( wxDirExists(FullPath) ) PathFound = TRUE; if( wxDirExists( FullPath ) ) PathFound = TRUE; } } /* find kicad/help/ from environment variable KICAD */ /* find kicad/help/ from environment variable KICAD */ if( !PathFound && EDA_Appl->m_Env_Defined ) if( !PathFound && EDA_Appl->m_Env_Defined ) { { FullPath = EDA_Appl->m_KicadEnv + wxT( "/help/" ); FullPath = EDA_Appl->m_KicadEnv + wxT( "/help/" ); if ( wxDirExists(FullPath) ) PathFound = TRUE; if( wxDirExists( FullPath ) ) PathFound = TRUE; } } /* find kicad/help/ from default path list: /* find kicad/help/ from default path list: /usr/local/kicad/help or c:/kicad/help * /usr/local/kicad/help or c:/kicad/help (see s_HelpPathList) */ * (see s_HelpPathList) */ int ii = 0; int ii = 0; while( !PathFound ) while( !PathFound ) { { FullPath = s_HelpPathList[ii++]; FullPath = s_HelpPathList[ii++]; if ( FullPath == wxT("end_list") ) break; if( FullPath == wxT( "end_list" ) ) if ( wxDirExists(FullPath) ) PathFound = TRUE; break; if( wxDirExists( FullPath ) ) PathFound = TRUE; } } Loading @@ -366,70 +382,82 @@ bool PathFound = FALSE; { { LangFullPath = FullPath + LocaleString + UNIX_STRING_DIR_SEP; LangFullPath = FullPath + LocaleString + UNIX_STRING_DIR_SEP; if ( wxDirExists(LangFullPath) ) return LangFullPath; if( wxDirExists( LangFullPath ) ) return LangFullPath; LangFullPath = FullPath + LocaleString.Left( 2 ) + UNIX_STRING_DIR_SEP; LangFullPath = FullPath + LocaleString.Left( 2 ) + UNIX_STRING_DIR_SEP; if ( wxDirExists(LangFullPath) ) return LangFullPath; if( wxDirExists( LangFullPath ) ) return LangFullPath; LangFullPath = FullPath + wxT( "en/" ); LangFullPath = FullPath + wxT( "en/" ); if ( wxDirExists(LangFullPath) ) return LangFullPath; if( wxDirExists( LangFullPath ) ) return LangFullPath; else else { { LangFullPath = FullPath + wxT( "fr/" ); LangFullPath = FullPath + wxT( "fr/" ); if ( wxDirExists(LangFullPath) ) return LangFullPath; if( wxDirExists( LangFullPath ) ) return LangFullPath; } } return FullPath; return FullPath; } } return wxEmptyString; return wxEmptyString; } } /********************************************************/ /********************************************************/ wxString FindKicadFile( const wxString& shortname ) wxString FindKicadFile( const wxString& shortname ) /********************************************************/ /********************************************************/ /* Search the executable file shortname in kicad binary path /* Search the executable file shortname in kicad binary path and return full file name if found or shortname * and return full file name if found or shortname kicad binary path is * kicad binary path is kicad/winexe or kicad/linux * kicad/winexe or kicad/linux * kicad binary path is found from: * kicad binary path is found from: BinDir * BinDir or environment variable KICAD * or environment variable KICAD or (default) c:\kicad ou /usr/local/kicad * or (default) c:\kicad ou /usr/local/kicad or default binary path * or default binary path */ */ { { wxString FullFileName; wxString FullFileName; /* test de la presence du fichier shortname dans le repertoire de /* test de la presence du fichier shortname dans le repertoire de des binaires de kicad */ * des binaires de kicad */ FullFileName = EDA_Appl->m_BinDir + shortname; FullFileName = EDA_Appl->m_BinDir + shortname; if ( wxFileExists(FullFileName) ) return FullFileName; if( wxFileExists( FullFileName ) ) return FullFileName; /* test de la presence du fichier shortname dans le repertoire /* test de la presence du fichier shortname dans le repertoire defini par la variable d'environnement KICAD */ * defini par la variable d'environnement KICAD */ if( EDA_Appl->m_Env_Defined ) if( EDA_Appl->m_Env_Defined ) { { FullFileName = EDA_Appl->m_KicadEnv + shortname; FullFileName = EDA_Appl->m_KicadEnv + shortname; if ( wxFileExists(FullFileName) ) return FullFileName; if( wxFileExists( FullFileName ) ) return FullFileName; } } /* find binary file from default path list: /* find binary file from default path list: /usr/local/kicad/linux or c:/kicad/winexe * /usr/local/kicad/linux or c:/kicad/winexe (see s_KicadDataPathList) */ * (see s_KicadDataPathList) */ int ii = 0; int ii = 0; while( 1 ) while( 1 ) { { if ( s_KicadBinaryPathList[ii] == wxT("end_list") ) break; if( s_KicadBinaryPathList[ii] == wxT( "end_list" ) ) break; FullFileName = s_KicadBinaryPathList[ii++] + shortname; FullFileName = s_KicadBinaryPathList[ii++] + shortname; if ( wxFileExists(FullFileName) ) return FullFileName; if( wxFileExists( FullFileName ) ) return FullFileName; } } return shortname; return shortname; } } /***********************************************************************************/ /***********************************************************************************/ int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param ) int ExecuteFile( wxWindow* frame, const wxString& ExecFile, const wxString& param ) /***********************************************************************************/ /***********************************************************************************/ /* Call the executable file "ExecFile", with params "param" /* Call the executable file "ExecFile", with params "param" */ */ { { Loading @@ -437,9 +465,10 @@ wxString FullFileName; #ifdef __WXMAC__ #ifdef __WXMAC__ // Mac part // Mac part wxGetEnv( "HOME", &FullFileName ); wxGetEnv( "HOME", &FullFileName ); FullFileName += wxString("/bin/") + newExecFile; FullFileName += wxString( "/bin/" ) + ExecFile; if( !wxFileExists( FullFileName ) ) if( !wxFileExists( FullFileName ) ) { { FullFileName = FindKicadFile( ExecFile ); FullFileName = FindKicadFile( ExecFile ); Loading @@ -451,7 +480,8 @@ wxString FullFileName; if( wxFileExists( FullFileName ) ) if( wxFileExists( FullFileName ) ) { { if( !param.IsEmpty() ) FullFileName += wxT(" ") + param; if( !param.IsEmpty() ) FullFileName += wxT( " " ) + param; wxExecute( FullFileName ); wxExecute( FullFileName ); return 0; return 0; } } Loading @@ -466,16 +496,17 @@ wxString FullFileName; /****************************************************/ /****************************************************/ void SetRealLibraryPath( const wxString& shortlibname ) void SetRealLibraryPath( const wxString& shortlibname ) /****************************************************/ /****************************************************/ /* met a jour le chemin des librairies g_RealLibDirBuffer (global) /* met a jour le chemin des librairies g_RealLibDirBuffer (global) a partir de UserLibDirBuffer (global): * a partir de UserLibDirBuffer (global): Si UserLibDirBuffer non vide g_RealLibDirBuffer = g_UserLibDirBuffer. * Si UserLibDirBuffer non vide g_RealLibDirBuffer = g_UserLibDirBuffer. Sinon si variable d'environnement KICAD definie (KICAD = chemin pour kicad), * Sinon si variable d'environnement KICAD definie (KICAD = chemin pour kicad), g_UserLibDirBuffer = <KICAD>/shortlibname; * g_UserLibDirBuffer = <KICAD>/shortlibname; Sinon g_UserLibDirBuffer = <Chemin des binaires>../shortlibname/ * Sinon g_UserLibDirBuffer = <Chemin des binaires>../shortlibname/ Sinon g_UserLibDirBuffer = /usr/share/kicad/shortlibname/ * Sinon g_UserLibDirBuffer = /usr/share/kicad/shortlibname/ * Remarque: * Remarque: Les \ sont remplacs par / (a la mode Unix) * Les \ sont remplacs par / (a la mode Unix) */ */ { { bool PathFound = FALSE; bool PathFound = FALSE; Loading @@ -485,7 +516,6 @@ bool PathFound = FALSE; g_RealLibDirBuffer = g_UserLibDirBuffer; g_RealLibDirBuffer = g_UserLibDirBuffer; PathFound = TRUE; PathFound = TRUE; } } else else { { g_RealLibDirBuffer = ReturnKicadDatasPath(); g_RealLibDirBuffer = ReturnKicadDatasPath(); Loading @@ -494,25 +524,29 @@ bool PathFound = FALSE; PathFound = TRUE; PathFound = TRUE; } } g_RealLibDirBuffer += shortlibname; g_RealLibDirBuffer += shortlibname; if ( wxDirExists(g_RealLibDirBuffer) ) PathFound = TRUE; if( wxDirExists( g_RealLibDirBuffer ) ) PathFound = TRUE; } } g_RealLibDirBuffer.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); g_RealLibDirBuffer.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); if ( g_RealLibDirBuffer.Last() != '/' ) g_RealLibDirBuffer += UNIX_STRING_DIR_SEP; if( g_RealLibDirBuffer.Last() != '/' ) g_RealLibDirBuffer += UNIX_STRING_DIR_SEP; } } /***********************************/ /***********************************/ wxString ReturnKicadDatasPath( void ) wxString ReturnKicadDatasPath( void ) /***********************************/ /***********************************/ /* Retourne le chemin des donnees communes de kicad. Si variable d'environnement KICAD definie (KICAD = chemin pour kicad), retourne <KICAD>/; Sinon retourne <Chemin des binaires>/ (si "kicad" est dans le nom du chemin) Sinon retourne /usr/share/kicad/ Remarque: /* Retourne le chemin des donnees communes de kicad. Les \ sont remplacs par / (a la mode Unix) * Si variable d'environnement KICAD definie (KICAD = chemin pour kicad), * retourne <KICAD>/; * Sinon retourne <Chemin des binaires>/ (si "kicad" est dans le nom du chemin) * Sinon retourne /usr/share/kicad/ * * Remarque: * Les \ sont remplacs par / (a la mode Unix) */ */ { { bool PathFound = FALSE; bool PathFound = FALSE; Loading @@ -524,7 +558,8 @@ wxString data_path; PathFound = TRUE; PathFound = TRUE; } } else // Chemin cherche par le chemin des executables else // Chemin cherche par le chemin des executables { // le chemin est bindir../ { // le chemin est bindir../ wxString tmp = EDA_Appl->m_BinDir; wxString tmp = EDA_Appl->m_BinDir; #ifdef __WINDOWS__ #ifdef __WINDOWS__ tmp.MakeLower(); tmp.MakeLower(); Loading @@ -534,31 +569,36 @@ wxString data_path; #ifdef __WINDOWS__ #ifdef __WINDOWS__ tmp = EDA_Appl->m_BinDir; tmp = EDA_Appl->m_BinDir; #endif #endif if ( tmp.Last() == '/' ) tmp.RemoveLast(); if( tmp.Last() == '/' ) tmp.RemoveLast(); data_path = tmp.BeforeLast( '/' ); // id cd ../ data_path = tmp.BeforeLast( '/' ); // id cd ../ data_path += UNIX_STRING_DIR_SEP; data_path += UNIX_STRING_DIR_SEP; if ( wxDirExists(data_path) ) PathFound = TRUE; if( wxDirExists( data_path ) ) PathFound = TRUE; } } } } /* find kicad from default path list: /* find kicad from default path list: /usr/local/kicad/ or c:/kicad/ * /usr/local/kicad/ or c:/kicad/ (see s_KicadDataPathList) */ * (see s_KicadDataPathList) */ int ii = 0; int ii = 0; while( !PathFound ) while( !PathFound ) { { if ( s_KicadDataPathList[ii] == wxT("end_list") ) break; if( s_KicadDataPathList[ii] == wxT( "end_list" ) ) break; data_path = s_KicadDataPathList[ii++]; data_path = s_KicadDataPathList[ii++]; if ( wxDirExists(data_path) ) PathFound = TRUE; if( wxDirExists( data_path ) ) PathFound = TRUE; } } if( PathFound ) if( PathFound ) { { data_path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); data_path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); if ( data_path.Last() != '/' ) data_path += UNIX_STRING_DIR_SEP; if( data_path.Last() != '/' ) data_path += UNIX_STRING_DIR_SEP; } } else else data_path.Empty(); data_path.Empty(); return data_path; return data_path; } } Loading @@ -567,6 +607,7 @@ wxString data_path; /***************************/ /***************************/ wxString GetEditorName( void ) wxString GetEditorName( void ) /***************************/ /***************************/ /* Return the prefered editor name /* Return the prefered editor name */ */ { { Loading @@ -580,6 +621,7 @@ wxString GetEditorName(void) { { DisplayInfo( NULL, _( "No default editor found, you must choose it" ) ); DisplayInfo( NULL, _( "No default editor found, you must choose it" ) ); wxString mask( wxT( "*" ) ); wxString mask( wxT( "*" ) ); #ifdef __WINDOWS__ #ifdef __WINDOWS__ mask += wxT( ".exe" ); mask += wxT( ".exe" ); #endif #endif Loading @@ -602,6 +644,7 @@ wxString GetEditorName(void) return g_EditorName; return g_EditorName; } } void OpenPDF( const wxString& file ) void OpenPDF( const wxString& file ) { { wxString command; wxString command; Loading @@ -620,8 +663,10 @@ void OpenPDF( const wxString & file ) wxFileType* filetype = NULL; wxFileType* filetype = NULL; wxFileType::MessageParameters params( filename, type ); wxFileType::MessageParameters params( filename, type ); filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( wxT( ".pdf" ) ); filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( wxT( ".pdf" ) ); if (filetype ) success = filetype->GetOpenCommand( &command, params); if( filetype ) success = filetype->GetOpenCommand( &command, params ); delete filetype; delete filetype; if( !success ) if( !success ) Loading @@ -638,7 +683,8 @@ void OpenPDF( const wxString & file ) }; }; for( int i = 0; ; i++ ) for( int i = 0; ; i++ ) { { if (tries[i].IsEmpty()) break; if( tries[i].IsEmpty() ) break; if( wxFileExists( tries[i] ) ) if( wxFileExists( tries[i] ) ) { { command = tries[i] + wxT( " " ) + filename; command = tries[i] + wxT( " " ) + filename; Loading @@ -647,7 +693,8 @@ void OpenPDF( const wxString & file ) } } } } if (!command.IsEmpty()) wxExecute(command); if( !command.IsEmpty() ) wxExecute( command ); } } Loading @@ -658,14 +705,17 @@ void OpenFile( const wxString & file ) wxFileName CurrentFileName( filename ); wxFileName CurrentFileName( filename ); wxString ext, type; wxString ext, type; ext = CurrentFileName.GetExt(); ext = CurrentFileName.GetExt(); wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext ); wxFileType* filetype = wxTheMimeTypesManager->GetFileTypeFromExtension( ext ); bool success = false; bool success = false; wxFileType::MessageParameters params( filename, type ); wxFileType::MessageParameters params( filename, type ); if (filetype) success = filetype->GetOpenCommand( &command, params); if( filetype ) success = filetype->GetOpenCommand( &command, params ); delete filetype; delete filetype; if (success && !command.IsEmpty()) wxExecute(command); if( success && !command.IsEmpty() ) wxExecute( command ); } }