forked from KiCad/kicad-source-mirror
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workaround for non-ASCII filenames in Windows
- Loading branch information
1 parent
9660522
commit 68bcdec
Showing
38 changed files
with
601 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This program source code file is part of KiCad, a free EDA CAD application. | ||
* | ||
* Copyright (C) 2015 Cirilo Bernardo <[email protected]> | ||
* Copyright (C) 2015-2017 Cirilo Bernardo <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
|
@@ -28,6 +28,7 @@ | |
#include <wx/log.h> | ||
#include "plugins/3dapi/ifsg_api.h" | ||
#include "plugins/3dapi/sg_version.h" | ||
#include "streamwrapper.h" | ||
#include "3d_cache/sg/sg_node.h" | ||
#include "3d_cache/sg/scenegraph.h" | ||
#include "3d_cache/sg/sg_appearance.h" | ||
|
@@ -77,24 +78,6 @@ static void formatMaterial( SMATERIAL& mat, SGAPPEARANCE const* app ) | |
} | ||
|
||
|
||
class VRML_LOCALE | ||
{ | ||
private: | ||
std::string lname; | ||
|
||
public: | ||
VRML_LOCALE() : lname( setlocale( LC_NUMERIC, NULL ) ) | ||
{ | ||
setlocale( LC_NUMERIC, "C" ); // switch the numerics locale to "C" | ||
} | ||
|
||
~VRML_LOCALE() | ||
{ | ||
setlocale( LC_NUMERIC, lname.c_str() ); // revert to the previous locale | ||
} | ||
}; | ||
|
||
|
||
bool S3D::WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode, | ||
bool reuse, bool renameNodes ) | ||
{ | ||
|
@@ -141,12 +124,9 @@ bool S3D::WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode, | |
return false; | ||
} | ||
|
||
VRML_LOCALE vrmlLocale; | ||
std::ofstream op; | ||
op.open( filename, std::ios_base::out | std::ios_base::trunc | ||
| std::ios_base::binary ); | ||
OPEN_OSTREAM( op, filename ); | ||
|
||
if( !op.is_open() ) | ||
if( op.fail() ) | ||
{ | ||
std::ostringstream ostr; | ||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; | ||
|
@@ -156,6 +136,7 @@ bool S3D::WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode, | |
return false; | ||
} | ||
|
||
op.imbue( std::locale( "C" ) ); | ||
op << "#VRML V2.0 utf8\n"; | ||
|
||
if( renameNodes ) | ||
|
@@ -168,11 +149,11 @@ bool S3D::WriteVRML( const char* filename, bool overwrite, SGNODE* aTopNode, | |
|
||
if( !op.fail() ) | ||
{ | ||
op.close(); | ||
CLOSE_STREAM( op ); | ||
return true; | ||
} | ||
|
||
op.close(); | ||
CLOSE_STREAM( op ); | ||
|
||
do { | ||
std::ostringstream ostr; | ||
|
@@ -302,11 +283,9 @@ bool S3D::WriteCache( const char* aFileName, bool overwrite, SGNODE* aNode, | |
} | ||
} | ||
|
||
std::ofstream output; | ||
output.open( aFileName, std::ios_base::out | std::ios_base::trunc | ||
| std::ios_base::binary ); | ||
OPEN_OSTREAM( output, aFileName ); | ||
|
||
if( !output.is_open() ) | ||
if( output.fail() ) | ||
{ | ||
std::ostringstream ostr; | ||
ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; | ||
|
@@ -324,7 +303,7 @@ bool S3D::WriteCache( const char* aFileName, bool overwrite, SGNODE* aNode, | |
output << "(INTERNAL:0.0.0.0)"; | ||
|
||
bool rval = aNode->WriteCache( output, NULL ); | ||
output.close(); | ||
CLOSE_STREAM( output ); | ||
|
||
if( !rval ) | ||
{ | ||
|
@@ -382,10 +361,9 @@ SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr, | |
return NULL; | ||
} | ||
|
||
std::ifstream file; | ||
file.open( aFileName, std::ios_base::in | std::ios_base::binary ); | ||
OPEN_ISTREAM( file, aFileName ); | ||
|
||
if( !file.is_open() ) | ||
if( file.fail() ) | ||
{ | ||
delete np; | ||
std::ostringstream ostr; | ||
|
@@ -417,7 +395,7 @@ SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr, | |
} while( 0 ); | ||
#endif | ||
|
||
file.close(); | ||
CLOSE_STREAM( file ); | ||
return NULL; | ||
} | ||
|
||
|
@@ -431,7 +409,7 @@ SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr, | |
|
||
if( name.compare( SG_VERSION_TAG ) ) | ||
{ | ||
file.close(); | ||
CLOSE_STREAM( file ); | ||
return NULL; | ||
} | ||
|
||
|
@@ -457,7 +435,7 @@ SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr, | |
} while( 0 ); | ||
#endif | ||
|
||
file.close(); | ||
CLOSE_STREAM( file ); | ||
return NULL; | ||
} | ||
|
||
|
@@ -472,14 +450,14 @@ SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr, | |
// check the plugin tag | ||
if( NULL != aTagCheck && NULL != aPluginMgr && !aTagCheck( name.c_str(), aPluginMgr ) ) | ||
{ | ||
file.close(); | ||
CLOSE_STREAM( file ); | ||
return NULL; | ||
} | ||
|
||
} while( 0 ); | ||
|
||
bool rval = np->ReadCache( file, NULL ); | ||
file.close(); | ||
CLOSE_STREAM( file ); | ||
|
||
if( !rval ) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This program source code file is part of KiCad, a free EDA CAD application. | ||
* | ||
* Copyright (C) 2015 Cirilo Bernardo <[email protected]> | ||
* Copyright (C) 2015-2017 Cirilo Bernardo <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
|
@@ -289,7 +289,7 @@ void SGAPPEARANCE::ReNameNodes( void ) | |
} | ||
|
||
|
||
bool SGAPPEARANCE::WriteVRML( std::ofstream& aFile, bool aReuseFlag ) | ||
bool SGAPPEARANCE::WriteVRML( std::ostream& aFile, bool aReuseFlag ) | ||
{ | ||
if( aReuseFlag ) | ||
{ | ||
|
@@ -366,7 +366,7 @@ bool SGAPPEARANCE::WriteVRML( std::ofstream& aFile, bool aReuseFlag ) | |
} | ||
|
||
|
||
bool SGAPPEARANCE::WriteCache( std::ofstream& aFile, SGNODE* parentNode ) | ||
bool SGAPPEARANCE::WriteCache( std::ostream& aFile, SGNODE* parentNode ) | ||
{ | ||
if( NULL == parentNode ) | ||
{ | ||
|
@@ -436,7 +436,7 @@ bool SGAPPEARANCE::WriteCache( std::ofstream& aFile, SGNODE* parentNode ) | |
} | ||
|
||
|
||
bool SGAPPEARANCE::ReadCache( std::ifstream& aFile, SGNODE* parentNode ) | ||
bool SGAPPEARANCE::ReadCache( std::istream& aFile, SGNODE* parentNode ) | ||
{ | ||
S3D::ReadColor( aFile, ambient ); | ||
aFile.read( (char*)&shininess, sizeof(shininess) ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This program source code file is part of KiCad, a free EDA CAD application. | ||
* | ||
* Copyright (C) 2015 Cirilo Bernardo <[email protected]> | ||
* Copyright (C) 2015-2017 Cirilo Bernardo <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
|
@@ -71,10 +71,10 @@ class SGAPPEARANCE : public SGNODE | |
bool AddChildNode( SGNODE* aNode ) override; | ||
|
||
void ReNameNodes( void ) override; | ||
bool WriteVRML( std::ofstream& aFile, bool aReuseFlag ) override; | ||
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override; | ||
|
||
bool WriteCache( std::ofstream& aFile, SGNODE* parentNode ) override; | ||
bool ReadCache( std::ifstream& aFile, SGNODE* parentNode ) override; | ||
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override; | ||
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override; | ||
}; | ||
|
||
#endif // SG_APPEARANCE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This program source code file is part of KiCad, a free EDA CAD application. | ||
* | ||
* Copyright (C) 2015 Cirilo Bernardo <[email protected]> | ||
* Copyright (C) 2015-2017 Cirilo Bernardo <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
|
@@ -207,7 +207,7 @@ void SGCOLORS::ReNameNodes( void ) | |
} | ||
|
||
|
||
bool SGCOLORS::WriteVRML( std::ofstream& aFile, bool aReuseFlag ) | ||
bool SGCOLORS::WriteVRML( std::ostream& aFile, bool aReuseFlag ) | ||
{ | ||
if( colors.empty() ) | ||
return false; | ||
|
@@ -265,7 +265,7 @@ bool SGCOLORS::WriteVRML( std::ofstream& aFile, bool aReuseFlag ) | |
} | ||
|
||
|
||
bool SGCOLORS::WriteCache( std::ofstream& aFile, SGNODE* parentNode ) | ||
bool SGCOLORS::WriteCache( std::ostream& aFile, SGNODE* parentNode ) | ||
{ | ||
if( NULL == parentNode ) | ||
{ | ||
|
@@ -334,7 +334,7 @@ bool SGCOLORS::WriteCache( std::ofstream& aFile, SGNODE* parentNode ) | |
} | ||
|
||
|
||
bool SGCOLORS::ReadCache( std::ifstream& aFile, SGNODE* parentNode ) | ||
bool SGCOLORS::ReadCache( std::istream& aFile, SGNODE* parentNode ) | ||
{ | ||
if( !colors.empty() ) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This program source code file is part of KiCad, a free EDA CAD application. | ||
* | ||
* Copyright (C) 2015 Cirilo Bernardo <[email protected]> | ||
* Copyright (C) 2015-2017 Cirilo Bernardo <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
|
@@ -56,10 +56,10 @@ class SGCOLORS : public SGNODE | |
void AddColor( const SGCOLOR& aColor ); | ||
|
||
void ReNameNodes( void ) override; | ||
bool WriteVRML( std::ofstream& aFile, bool aReuseFlag ) override; | ||
bool WriteVRML( std::ostream& aFile, bool aReuseFlag ) override; | ||
|
||
bool WriteCache( std::ofstream& aFile, SGNODE* parentNode ) override; | ||
bool ReadCache( std::ifstream& aFile, SGNODE* parentNode ) override; | ||
bool WriteCache( std::ostream& aFile, SGNODE* parentNode ) override; | ||
bool ReadCache( std::istream& aFile, SGNODE* parentNode ) override; | ||
}; | ||
|
||
#endif // SG_COLORS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* This program source code file is part of KiCad, a free EDA CAD application. | ||
* | ||
* Copyright (C) 2015 Cirilo Bernardo <[email protected]> | ||
* Copyright (C) 2015-2017 Cirilo Bernardo <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
|
@@ -210,7 +210,7 @@ void SGCOORDS::ReNameNodes( void ) | |
} | ||
|
||
|
||
bool SGCOORDS::WriteVRML( std::ofstream& aFile, bool aReuseFlag ) | ||
bool SGCOORDS::WriteVRML( std::ostream& aFile, bool aReuseFlag ) | ||
{ | ||
if( coords.empty() ) | ||
return false; | ||
|
@@ -272,7 +272,7 @@ bool SGCOORDS::WriteVRML( std::ofstream& aFile, bool aReuseFlag ) | |
} | ||
|
||
|
||
bool SGCOORDS::WriteCache( std::ofstream& aFile, SGNODE* parentNode ) | ||
bool SGCOORDS::WriteCache( std::ostream& aFile, SGNODE* parentNode ) | ||
{ | ||
if( NULL == parentNode ) | ||
{ | ||
|
@@ -341,7 +341,7 @@ bool SGCOORDS::WriteCache( std::ofstream& aFile, SGNODE* parentNode ) | |
} | ||
|
||
|
||
bool SGCOORDS::ReadCache( std::ifstream& aFile, SGNODE* parentNode ) | ||
bool SGCOORDS::ReadCache( std::istream& aFile, SGNODE* parentNode ) | ||
{ | ||
if( !coords.empty() ) | ||
{ | ||
|
Oops, something went wrong.