Loading pcbnew/github/github_plugin.cpp +18 −13 Original line number Original line Diff line number Diff line Loading @@ -63,10 +63,13 @@ #include <macros.h> #include <macros.h> #include <fp_lib_table.h> // ExpandSubstitutions() #include <fp_lib_table.h> // ExpandSubstitutions() using namespace std; static const char* PRETTY_DIR = "allow_pretty_writing_to_this_dir"; static const char* PRETTY_DIR = "allow_pretty_writing_to_this_dir"; typedef boost::ptr_map<std::string, wxZipEntry> MODULE_MAP; typedef boost::ptr_map<string, wxZipEntry> MODULE_MAP; typedef MODULE_MAP::iterator MODULE_ITER; typedef MODULE_MAP::iterator MODULE_ITER; typedef MODULE_MAP::const_iterator MODULE_CITER; typedef MODULE_MAP::const_iterator MODULE_CITER; Loading Loading @@ -163,7 +166,7 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, } } } } std::string fp_name = TO_UTF8( aFootprintName ); string fp_name = TO_UTF8( aFootprintName ); MODULE_CITER it = m_gh_cache->find( fp_name ); MODULE_CITER it = m_gh_cache->find( fp_name ); Loading Loading @@ -230,7 +233,7 @@ void GITHUB_PLUGIN::FootprintSave( const wxString& aLibraryPath, // IsFootprintLibWritable() to determine if calling FootprintSave() is // IsFootprintLibWritable() to determine if calling FootprintSave() is // even legal, so I spend no time on internationalization here: // even legal, so I spend no time on internationalization here: std::string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg ); Loading Loading @@ -272,7 +275,7 @@ void GITHUB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxStrin // IsFootprintLibWritable() to determine if calling FootprintSave() is // IsFootprintLibWritable() to determine if calling FootprintSave() is // even legal, so I spend no time on internationalization here: // even legal, so I spend no time on internationalization here: std::string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg ); Loading Loading @@ -353,7 +356,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP if( aProperties ) if( aProperties ) { { std::string pretty_dir; string pretty_dir; if( aProperties->Value( PRETTY_DIR, &pretty_dir ) ) if( aProperties->Value( PRETTY_DIR, &pretty_dir ) ) { { Loading Loading @@ -406,7 +409,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP if( fn.GetExt() == kicad_mod ) if( fn.GetExt() == kicad_mod ) { { std::string fp_name = TO_UTF8( fn.GetName() ); // omit extension & path string fp_name = TO_UTF8( fn.GetName() ); // omit extension & path m_gh_cache->insert( fp_name, entry ); m_gh_cache->insert( fp_name, entry ); } } Loading @@ -417,7 +420,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP } } bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, std::string* aZipURL ) bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL ) { { // e.g. "https://github.com/liftoff-sr/pretty_footprints" // e.g. "https://github.com/liftoff-sr/pretty_footprints" //D(printf("aRepoURL:%s\n", TO_UTF8( aRepoURL ) );) //D(printf("aRepoURL:%s\n", TO_UTF8( aRepoURL ) );) Loading Loading @@ -457,7 +460,7 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, std::string* aZipU void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) { { std::string zip_url; string zip_url; if( !repoURL_zipURL( aRepoURL, &zip_url ) ) if( !repoURL_zipURL( aRepoURL, &zip_url ) ) { { Loading @@ -475,7 +478,7 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) try try { { std::ostringstream os; ostringstream os; h.open( zip_url ); // only one file, therefore do it synchronously. h.open( zip_url ); // only one file, therefore do it synchronously. os << &h; os << &h; Loading @@ -492,8 +495,10 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) // https "GET" has faild, report this to API caller. // https "GET" has faild, report this to API caller. wxString fmt( _( "Cannot GET zip: '%s'\nfor lib-path: '%s'.\nWhat: '%s'" ) ); wxString fmt( _( "Cannot GET zip: '%s'\nfor lib-path: '%s'.\nWhat: '%s'" ) ); std::string msg = StrPrintf( TO_UTF8( fmt ), zip_url.c_str(), string msg = StrPrintf( TO_UTF8( fmt ), TO_UTF8( aRepoURL ), e.what() ); zip_url.c_str(), TO_UTF8( aRepoURL ), e.what() ); THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg ); } } Loading Loading
pcbnew/github/github_plugin.cpp +18 −13 Original line number Original line Diff line number Diff line Loading @@ -63,10 +63,13 @@ #include <macros.h> #include <macros.h> #include <fp_lib_table.h> // ExpandSubstitutions() #include <fp_lib_table.h> // ExpandSubstitutions() using namespace std; static const char* PRETTY_DIR = "allow_pretty_writing_to_this_dir"; static const char* PRETTY_DIR = "allow_pretty_writing_to_this_dir"; typedef boost::ptr_map<std::string, wxZipEntry> MODULE_MAP; typedef boost::ptr_map<string, wxZipEntry> MODULE_MAP; typedef MODULE_MAP::iterator MODULE_ITER; typedef MODULE_MAP::iterator MODULE_ITER; typedef MODULE_MAP::const_iterator MODULE_CITER; typedef MODULE_MAP::const_iterator MODULE_CITER; Loading Loading @@ -163,7 +166,7 @@ MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath, } } } } std::string fp_name = TO_UTF8( aFootprintName ); string fp_name = TO_UTF8( aFootprintName ); MODULE_CITER it = m_gh_cache->find( fp_name ); MODULE_CITER it = m_gh_cache->find( fp_name ); Loading Loading @@ -230,7 +233,7 @@ void GITHUB_PLUGIN::FootprintSave( const wxString& aLibraryPath, // IsFootprintLibWritable() to determine if calling FootprintSave() is // IsFootprintLibWritable() to determine if calling FootprintSave() is // even legal, so I spend no time on internationalization here: // even legal, so I spend no time on internationalization here: std::string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg ); Loading Loading @@ -272,7 +275,7 @@ void GITHUB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxStrin // IsFootprintLibWritable() to determine if calling FootprintSave() is // IsFootprintLibWritable() to determine if calling FootprintSave() is // even legal, so I spend no time on internationalization here: // even legal, so I spend no time on internationalization here: std::string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", string msg = StrPrintf( "Github library\n'%s'\nis only writable if you set option '%s' in Library Tables dialog.", (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); (const char*) TO_UTF8( aLibraryPath ), PRETTY_DIR ); THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg ); Loading Loading @@ -353,7 +356,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP if( aProperties ) if( aProperties ) { { std::string pretty_dir; string pretty_dir; if( aProperties->Value( PRETTY_DIR, &pretty_dir ) ) if( aProperties->Value( PRETTY_DIR, &pretty_dir ) ) { { Loading Loading @@ -406,7 +409,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP if( fn.GetExt() == kicad_mod ) if( fn.GetExt() == kicad_mod ) { { std::string fp_name = TO_UTF8( fn.GetName() ); // omit extension & path string fp_name = TO_UTF8( fn.GetName() ); // omit extension & path m_gh_cache->insert( fp_name, entry ); m_gh_cache->insert( fp_name, entry ); } } Loading @@ -417,7 +420,7 @@ void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aP } } bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, std::string* aZipURL ) bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, string* aZipURL ) { { // e.g. "https://github.com/liftoff-sr/pretty_footprints" // e.g. "https://github.com/liftoff-sr/pretty_footprints" //D(printf("aRepoURL:%s\n", TO_UTF8( aRepoURL ) );) //D(printf("aRepoURL:%s\n", TO_UTF8( aRepoURL ) );) Loading Loading @@ -457,7 +460,7 @@ bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, std::string* aZipU void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) { { std::string zip_url; string zip_url; if( !repoURL_zipURL( aRepoURL, &zip_url ) ) if( !repoURL_zipURL( aRepoURL, &zip_url ) ) { { Loading @@ -475,7 +478,7 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) try try { { std::ostringstream os; ostringstream os; h.open( zip_url ); // only one file, therefore do it synchronously. h.open( zip_url ); // only one file, therefore do it synchronously. os << &h; os << &h; Loading @@ -492,8 +495,10 @@ void GITHUB_PLUGIN::remote_get_zip( const wxString& aRepoURL ) throw( IO_ERROR ) // https "GET" has faild, report this to API caller. // https "GET" has faild, report this to API caller. wxString fmt( _( "Cannot GET zip: '%s'\nfor lib-path: '%s'.\nWhat: '%s'" ) ); wxString fmt( _( "Cannot GET zip: '%s'\nfor lib-path: '%s'.\nWhat: '%s'" ) ); std::string msg = StrPrintf( TO_UTF8( fmt ), zip_url.c_str(), string msg = StrPrintf( TO_UTF8( fmt ), TO_UTF8( aRepoURL ), e.what() ); zip_url.c_str(), TO_UTF8( aRepoURL ), e.what() ); THROW_IO_ERROR( msg ); THROW_IO_ERROR( msg ); } } Loading