kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #28462
PATCH: fix kicad2step non-ASCII filename problem in MinGW
This patch fixes the non-ASCII filename problem in
Windows+MinGW.
When this patch is applied, and OCE is built under
MinGW with the patch I previously supplied, all
3D model viewing and STEP export appear to work
mostly as expected. There is one remaining
issue to resolve which is correctly passing the
UTF8 filename from pcbnew to kicad2step and
ensuring that the appropriate output file is created.
At the moment I'm not sure if the problem is in
kicad2step or my hack of OCE, but I'm looking
into it.
- Cirilo
From ad6caa2edbec0eaf6c22df4b6c22b1ebf22de329 Mon Sep 17 00:00:00 2001
From: Cirilo Bernardo <cirilo.bernardo@xxxxxxxxx>
Date: Sun, 5 Mar 2017 15:22:31 +1100
Subject: [PATCH] Fix kicad2step non-ASCII filename characters issue in
Windows+MinGW
---
utils/kicad2step/CMakeLists.txt | 13 ++++++++++---
utils/kicad2step/pcb/kicadmodule.cpp | 3 ++-
utils/kicad2step/pcb/oce_utils.cpp | 10 +++++-----
3 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/utils/kicad2step/CMakeLists.txt b/utils/kicad2step/CMakeLists.txt
index bdfff3390..a60153f42 100644
--- a/utils/kicad2step/CMakeLists.txt
+++ b/utils/kicad2step/CMakeLists.txt
@@ -1,13 +1,14 @@
include_directories( BEFORE
- pcb
- ${CMAKE_CURRENT_SOURCE_DIR}
+ pcb
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/include
)
include_directories( SYSTEM
${OCE_INCLUDE_DIRS}
)
-add_executable( kicad2step
+set( K2S_FILES
kicad2step.cpp
pcb/3d_resolver.cpp
pcb/base.cpp
@@ -21,6 +22,12 @@ add_executable( kicad2step
sexpr/sexpr_parser.cpp
)
+if( MINGW )
+ list( APPEND K2S_FILES ${CMAKE_SOURCE_DIR}/common/streamwrapper.cpp )
+endif( MINGW )
+
+add_executable( kicad2step ${K2S_FILES} )
+
target_link_libraries( kicad2step ${wxWidgets_LIBRARIES} ${LIBS_OCE} )
if( APPLE )
diff --git a/utils/kicad2step/pcb/kicadmodule.cpp b/utils/kicad2step/pcb/kicadmodule.cpp
index 532b02c9c..03ffff415 100644
--- a/utils/kicad2step/pcb/kicadmodule.cpp
+++ b/utils/kicad2step/pcb/kicadmodule.cpp
@@ -360,7 +360,8 @@ bool KICADMODULE::ComposePCB( class PCBMODEL* aPCB, S3D_RESOLVER* resolver,
for( auto i : m_models )
{
- std::string fname( resolver->ResolvePath( i->m_modelname.c_str() ).ToUTF8() );
+ std::string fname( resolver->ResolvePath(
+ wxString::FromUTF8Unchecked( i->m_modelname.c_str() ) ).ToUTF8() );
if( aPCB->AddComponent( fname, m_refdes, LAYER_BOTTOM == m_side ? true : false,
newpos, m_rotation, i->m_offset, i->m_rotation ) )
diff --git a/utils/kicad2step/pcb/oce_utils.cpp b/utils/kicad2step/pcb/oce_utils.cpp
index 8fa45cb04..cce6d1fd2 100644
--- a/utils/kicad2step/pcb/oce_utils.cpp
+++ b/utils/kicad2step/pcb/oce_utils.cpp
@@ -31,6 +31,7 @@
#include "oce_utils.h"
#include "kicadpad.h"
+#include "streamwrapper.h"
#include <IGESCAFControl_Reader.hxx>
#include <IGESCAFControl_Writer.hxx>
@@ -153,7 +154,7 @@ enum FormatType
FormatType fileType( const char* aFileName )
{
- wxFileName lfile( aFileName );
+ wxFileName lfile( wxString::FromUTF8Unchecked( aFileName ) );
if( !lfile.FileExists() )
{
@@ -172,16 +173,15 @@ FormatType fileType( const char* aFileName )
else if( ext == "emn" || ext == "EMN" )
return FMT_EMN; // PCB assembly
- std::ifstream ifile;
- ifile.open( aFileName );
+ OPEN_ISTREAM( ifile, aFileName );
- if( !ifile.is_open() )
+ if( ifile.fail() )
return FMT_NONE;
char iline[82];
memset( iline, 0, 82 );
ifile.getline( iline, 82 );
- ifile.close();
+ CLOSE_STREAM( ifile );
iline[81] = 0; // ensure NULL termination when string is too long
// check for STEP in Part 21 format
--
2.11.0
Follow ups