Fix bug: Footprint add 3D shape recognizes only files with lower case ext on Windows

Fixes: lp:1659027
https://bugs.launchpad.net/kicad/+bug/1659027
This commit is contained in:
Cirilo Bernardo 2017-02-22 10:22:33 +01:00 committed by jean-pierre charras
parent 68c2639e7d
commit 2b2b73ee4b
3 changed files with 16 additions and 6 deletions

View File

@ -390,7 +390,11 @@ bool S3D_CACHE::getSHA1( const wxString& aFileName, unsigned char* aSHA1Sum )
return false;
}
#ifdef WIN32
FILE* fp = _wfopen( aFileName.wc_str(), L"rb" );
#else
FILE* fp = fopen( aFileName.ToUTF8(), "rb" );
#endif
if( NULL == fp )
return false;

View File

@ -467,6 +467,12 @@ SCENEGRAPH* S3D_PLUGIN_MANAGER::Load3DModel( const wxString& aFileName, std::str
wxFileName raw( aFileName );
wxString ext = raw.GetExt();
#ifdef WIN32
// note: plugins only have a lowercase filter within Windows; including an uppercase
// filter will result in duplicate file entries and should be avoided.
ext.LowerCase();
#endif
std::pair < std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::iterator,
std::multimap< const wxString, KICAD_PLUGIN_LDR_3D* >::iterator > items;

View File

@ -28,10 +28,11 @@
#include <cstring>
#include <map>
#include <vector>
#include <wx/string.h>
#include <wx/wfstream.h>
#if ( defined( DEBUG_OCE ) && DEBUG_OCE > 3 )
#include <wx/filename.h>
#include <wx/string.h>
#endif
#include <TDocStd_Document.hxx>
@ -268,16 +269,15 @@ enum FormatType
FormatType fileType( const char* aFileName )
{
std::ifstream ifile;
ifile.open( aFileName );
wxString fname( wxString::FromUTF8Unchecked( aFileName ) );
wxFileInputStream ifile( fname );
if( !ifile.is_open() )
if( !ifile.IsOk() )
return FMT_NONE;
char iline[82];
memset( iline, 0, 82 );
ifile.getline( iline, 82 );
ifile.close();
ifile.Read( iline, 82 );
iline[81] = 0; // ensure NULL termination when string is too long
// check for STEP in Part 21 format