From 947085567f2bde7c03b6529ee9822fdf7e20e664 Mon Sep 17 00:00:00 2001 From: pdn Date: Wed, 22 Oct 2014 12:17:10 +0400 Subject: [PATCH] 0025367: IGES and BRep persistence - support unicode file names on Windows OSD_OpenFile.hxx header is created for using in file open operations with Unicode names. Fix for STEP files reading. Adding test cases for issue 25367 Update test case for issue 25364 Update test cases due to improvements --- src/BRepTools/BRepTools.cxx | 9 +- src/FSD/FSD_BinaryFile.cxx | 20 +-- src/IFSelect/IFSelect_SessionFile.cxx | 6 +- src/IFSelect/IFSelect_SessionPilot.cxx | 3 +- src/IGESControl/IGESControl_Writer.cxx | 4 +- src/IGESFile/igesread.c | 4 +- src/IGESSelect/IGESSelect_WorkLibrary.cxx | 3 +- src/Image/Image_AlienPixMap.cxx | 8 +- src/Message/Message_MsgFile.cxx | 9 +- src/OSD/FILES | 2 + src/OSD/OSD_OpenFile.cxx | 125 ++++++++++++++++++ src/OSD/OSD_OpenFile.hxx | 80 +++++++++++ src/RWStl/RWStl.cxx | 8 +- src/StdResource/XCAF | 2 +- src/StepFile/StepFile_Read.cxx | 5 - src/StepFile/stepread.c | 10 +- src/StepSelect/StepSelect_WorkLibrary.cxx | 3 +- src/TObj/TObj_Model.cxx | 5 +- src/Voxel/Voxel_Reader.cxx | 15 ++- src/Voxel/Voxel_Writer.cxx | 13 +- src/VrmlAPI/VrmlAPI_Writer.cxx | 3 +- .../XmlLDrivers_DocumentStorageDriver.cxx | 6 +- tests/bugs/fclasses/bug25367_brep | 33 +++++ tests/bugs/fclasses/bug25367_igs | 37 ++++++ tests/bugs/mesh/bug25364 | 5 + tests/bugs/moddata_2/bug22993 | 1 - tests/bugs/step/bug133_2 | 2 - 27 files changed, 341 insertions(+), 80 deletions(-) create mode 100644 src/OSD/OSD_OpenFile.cxx create mode 100644 src/OSD/OSD_OpenFile.hxx create mode 100644 tests/bugs/fclasses/bug25367_brep create mode 100644 tests/bugs/fclasses/bug25367_igs diff --git a/src/BRepTools/BRepTools.cxx b/src/BRepTools/BRepTools.cxx index 58e56b1936..ec467ee538 100644 --- a/src/BRepTools/BRepTools.cxx +++ b/src/BRepTools/BRepTools.cxx @@ -50,6 +50,7 @@ #include #include #include +#include #include @@ -611,8 +612,7 @@ Standard_Boolean BRepTools::Write(const TopoDS_Shape& Sh, const Handle(Message_ProgressIndicator)& PR) { ofstream os; - // if (!fic.open(File,output)) return Standard_False; - os.open(File, ios::out); + OSD_OpenStream(os, File, ios::out); if (!os.rdbuf()->is_open()) return Standard_False; Standard_Boolean isGood = (os.good() && !os.eof()); @@ -650,8 +650,9 @@ Standard_Boolean BRepTools::Read(TopoDS_Shape& Sh, { filebuf fic; istream in(&fic); - if (!fic.open(File, ios::in)) return Standard_False; - + OSD_OpenFileBuf(fic,File,ios::in); + if(!fic.is_open()) return Standard_False; + BRepTools_ShapeSet SS(B); SS.SetProgress(PR); SS.Read(in); diff --git a/src/FSD/FSD_BinaryFile.cxx b/src/FSD/FSD_BinaryFile.cxx index c04a9b549b..bb90cd171f 100644 --- a/src/FSD/FSD_BinaryFile.cxx +++ b/src/FSD/FSD_BinaryFile.cxx @@ -14,6 +14,7 @@ #include #include +#include const Standard_CString MAGICNUMBER = "BINFILE"; @@ -81,28 +82,15 @@ Storage_Error FSD_BinaryFile::Open(const TCollection_AsciiString& aName,const St SetName(aName); if (OpenMode() == Storage_VSNone) { -#ifdef _WIN32 - TCollection_ExtendedString aWName(aName); if (aMode == Storage_VSRead) { - myStream = _wfopen((const wchar_t*)aWName.ToExtString(),L"rb"); + myStream = OSD_OpenFile(aName.ToCString(),"rb"); } else if (aMode == Storage_VSWrite) { - myStream = _wfopen((const wchar_t*)aWName.ToExtString(),L"wb"); + myStream = OSD_OpenFile(aName.ToCString(),"wb"); } else if (aMode == Storage_VSReadWrite) { - myStream = _wfopen((const wchar_t*)aWName.ToExtString(),L"w+b"); + myStream = OSD_OpenFile(aName.ToCString(),"w+b"); } -#else - if (aMode == Storage_VSRead) { - myStream = fopen(aName.ToCString(),"rb"); - } - else if (aMode == Storage_VSWrite) { - myStream = fopen(aName.ToCString(),"wb"); - } - else if (aMode == Storage_VSReadWrite) { - myStream = fopen(aName.ToCString(),"w+b"); - } -#endif if (myStream == 0L) { result = Storage_VSOpenError; diff --git a/src/IFSelect/IFSelect_SessionFile.cxx b/src/IFSelect/IFSelect_SessionFile.cxx index 56d8926fc0..0c954e2ce7 100644 --- a/src/IFSelect/IFSelect_SessionFile.cxx +++ b/src/IFSelect/IFSelect_SessionFile.cxx @@ -33,6 +33,8 @@ #include #include +#include + static int deja = 0; @@ -91,7 +93,7 @@ static int deja = 0; Standard_Boolean IFSelect_SessionFile::WriteFile (const Standard_CString filename) { - FILE* lefic = fopen(filename,"w"); + FILE* lefic = OSD_OpenFile(filename,"w"); Standard_Integer nbl = thelist.Length(); for (Standard_Integer i = 1; i <= nbl; i ++) fprintf (lefic,"%s\n",thelist.Value(i).ToCString()); @@ -104,7 +106,7 @@ static int deja = 0; (const Standard_CString filename) { char ligne[201]; - FILE* lefic = fopen(filename,"r"); + FILE* lefic = OSD_OpenFile(filename,"r"); if (!lefic) return Standard_False; ClearLines(); // read mode : lire les lignes diff --git a/src/IFSelect/IFSelect_SessionPilot.cxx b/src/IFSelect/IFSelect_SessionPilot.cxx index 09bd9f1f21..ef8daf0508 100644 --- a/src/IFSelect/IFSelect_SessionPilot.cxx +++ b/src/IFSelect/IFSelect_SessionPilot.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -225,7 +226,7 @@ static TCollection_AsciiString nulword; { FILE* fic; int lefic = 0; if (file != NULL && file[0] != '\0') { - fic = fopen (file,"r"); + fic = OSD_OpenFile (file,"r"); if (fic) lefic = 1; else { cout<<" ... Script File "< #include #include +#include IGESControl_Writer::IGESControl_Writer () : theTP (new Transfer_FinderProcess(10000)) , @@ -267,7 +268,8 @@ Standard_Boolean IGESControl_Writer::Write Standard_Boolean IGESControl_Writer::Write (const Standard_CString file, const Standard_Boolean fnes) { - ofstream fout(file,ios::out); + ofstream fout; + OSD_OpenStream(fout,file,ios::out); if (!fout) return Standard_False; #ifdef OCCT_DEBUG cout<<" Ecriture fichier ("<< (fnes ? "fnes" : "IGES") <<"): "< #include "igesread.h" +#include /* void IGESFile_Check21 (int mode,char * code, int num, char * str); @@ -61,7 +62,8 @@ int igesread (char* nomfic, int lesect[6], int modefnes) int Dstat = 0; int Pstat = 0; char c_separ = ','; char c_fin = ';'; iges_initfile(); lefic = stdin; i0 = numsec = 0; numl = 0; - if (nomfic[1] != '\0') lefic = fopen(nomfic,"r"); + if (nomfic[0] != '\0') + lefic = OSD_OpenFile(nomfic,"r"); if (lefic == NULL) return -1; /* fichier pas pu etre ouvert */ for (i = 1; i < 6; i++) lesect[i] = 0; for (j = 0; j < 100; j++) ligne[j] = 0; diff --git a/src/IGESSelect/IGESSelect_WorkLibrary.cxx b/src/IGESSelect/IGESSelect_WorkLibrary.cxx index a025dd62f6..b7f0aa4902 100644 --- a/src/IGESSelect/IGESSelect_WorkLibrary.cxx +++ b/src/IGESSelect/IGESSelect_WorkLibrary.cxx @@ -39,6 +39,7 @@ #include #include +#include #include static int deja = 0; @@ -97,7 +98,7 @@ static Handle(IGESData_FileProtocol) IGESProto; if (igesmod.IsNull() || prot.IsNull()) return Standard_False; ofstream fout; - fout.rdbuf()->open(ctx.FileName(),ios::out ); + OSD_OpenStream(fout,ctx.FileName(),ios::out ); if (!fout) { ctx.CCheck(0)->AddFail("IGES File could not be created"); sout<<" - IGES File could not be created : " << ctx.FileName() << endl; return 0; diff --git a/src/Image/Image_AlienPixMap.cxx b/src/Image/Image_AlienPixMap.cxx index 6a97c643b1..a264254dd1 100644 --- a/src/Image/Image_AlienPixMap.cxx +++ b/src/Image/Image_AlienPixMap.cxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -322,12 +323,7 @@ bool Image_AlienPixMap::savePPM (const TCollection_AsciiString& theFileName) con } // Open file -#ifdef _WIN32 - const TCollection_ExtendedString aFileNameW (theFileName.ToCString(), Standard_True); - FILE* aFile = _wfopen ((const wchar_t* )aFileNameW.ToExtString(), L"wb"); -#else - FILE* aFile = fopen (theFileName.ToCString(), "wb"); -#endif + FILE* aFile = OSD_OpenFile (theFileName.ToCString(), "wb"); if (aFile == NULL) { return false; diff --git a/src/Message/Message_MsgFile.cxx b/src/Message/Message_MsgFile.cxx index 1dbf2f871e..735182c7dd 100644 --- a/src/Message/Message_MsgFile.cxx +++ b/src/Message/Message_MsgFile.cxx @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -214,13 +215,7 @@ Standard_Boolean Message_MsgFile::LoadFile (const Standard_CString theFileName) if (theFileName == NULL || * theFileName == '\0') return Standard_False; // Open the file -#ifdef _WIN32 - // file name is treated as UTF-8 string - TCollection_ExtendedString aFileNameW(theFileName, Standard_True); - FILE *anMsgFile = _wfopen ((const wchar_t*)aFileNameW.ToExtString(), L"rb"); -#else - FILE *anMsgFile = fopen (theFileName, "rb"); -#endif + FILE *anMsgFile = OSD_OpenFile(theFileName,"rb"); if (!anMsgFile) return Standard_False; // Read the file into memory diff --git a/src/OSD/FILES b/src/OSD/FILES index 57865f5ac1..eadc93711e 100755 --- a/src/OSD/FILES +++ b/src/OSD/FILES @@ -17,3 +17,5 @@ OSD_MAllocHook.cxx OSD_MAllocHook.hxx OSD_MemInfo.hxx OSD_MemInfo.cxx +OSD_OpenFile.hxx +OSD_OpenFile.cxx diff --git a/src/OSD/OSD_OpenFile.cxx b/src/OSD/OSD_OpenFile.cxx new file mode 100644 index 0000000000..c2e37cd703 --- /dev/null +++ b/src/OSD/OSD_OpenFile.cxx @@ -0,0 +1,125 @@ +// Copyright (c) 2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include +#include + +// ============================================== +// function : OSD_OpenFile +// purpose : Opens file +// ============================================== +FILE* OSD_OpenFile(const char* theName, + const char* theMode) +{ + FILE* aFile = 0; +#ifdef _WIN32 + // file name is treated as UTF-8 string and converted to UTF-16 one + const TCollection_ExtendedString aFileNameW (theName, Standard_True); + const TCollection_ExtendedString aFileModeW (theMode, Standard_True); + aFile = ::_wfopen ((const wchar_t* )aFileNameW.ToExtString(), + (const wchar_t* )aFileModeW.ToExtString()); +#else + aFile = ::fopen (theName, theMode); +#endif + return aFile; +} + +// ============================================== +// function : OSD_OpenFile +// purpose : Opens file +// ============================================== +FILE* OSD_OpenFile(const TCollection_ExtendedString& theName, + const char* theMode) +{ + FILE* aFile = 0; +#ifdef _WIN32 + const TCollection_ExtendedString aFileModeW (theMode, Standard_True); + aFile = ::_wfopen ((const wchar_t* )theName.ToExtString(), + (const wchar_t* )aFileModeW.ToExtString()); +#else + // conversion in UTF-8 for linux + NCollection_Utf8String aString((const Standard_Utf16Char*)theName.ToExtString()); + aFile = ::fopen (aString.ToCString(),theMode); +#endif + return aFile; +} + +// ============================================== +// function : OSD_OpenFileBuf +// purpose : Opens file buffer +// ============================================== +void OSD_OpenFileBuf(std::filebuf& theBuff, + const char* theName, + const std::ios_base::openmode theMode) +{ +#ifdef _WIN32 + // file name is treated as UTF-8 string and converted to UTF-16 one + const TCollection_ExtendedString aFileNameW (theName, Standard_True); + theBuff.open ((const wchar_t* )aFileNameW.ToExtString(), theMode); +#else + theBuff.open (theName, theMode); +#endif +} + +// ============================================== +// function : OSD_OpenFileBuf +// purpose : Opens file buffer +// ============================================== +void OSD_OpenFileBuf(std::filebuf& theBuff, + const TCollection_ExtendedString& theName, + const std::ios_base::openmode theMode) +{ +#ifdef _WIN32 + theBuff.open ((const wchar_t* )theName.ToExtString(), theMode); +#else + // conversion in UTF-8 for linux + NCollection_Utf8String aString((const Standard_Utf16Char*)theName.ToExtString()); + theBuff.open (aString.ToCString(),theMode); +#endif +} + +// ============================================== +// function : OSD_OpenStream +// purpose : Opens file stream +// ============================================== +void OSD_OpenStream(std::ofstream& theStream, + const char* theName, + const std::ios_base::openmode theMode) +{ +#ifdef _WIN32 + // file name is treated as UTF-8 string and converted to UTF-16 one + const TCollection_ExtendedString aFileNameW (theName, Standard_True); + theStream.open ((const wchar_t* )aFileNameW.ToExtString(), theMode); +#else + theStream.open (theName, theMode); +#endif +} + +// ============================================== +// function : OSD_OpenStream +// purpose : Opens file stream +// ============================================== +void OSD_OpenStream(std::ofstream& theStream, + const TCollection_ExtendedString& theName, + const std::ios_base::openmode theMode) +{ +#ifdef _WIN32 + theStream.open ((const wchar_t* )theName.ToExtString(), theMode); +#else + // conversion in UTF-8 for linux + NCollection_Utf8String aString((const Standard_Utf16Char*)theName.ToExtString()); + theStream.open (aString.ToCString(),theMode); +#endif +} + diff --git a/src/OSD/OSD_OpenFile.hxx b/src/OSD/OSD_OpenFile.hxx new file mode 100644 index 0000000000..5c4a70aafd --- /dev/null +++ b/src/OSD/OSD_OpenFile.hxx @@ -0,0 +1,80 @@ +// Copyright (c) 2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +//! Auxiulary file to provide Unicode compatibility for file open functionality +//! Names of files are encoded as UTF-16 strings + +#ifndef _OSD_OpenFile_HeaderFile +#define _OSD_OpenFile_HeaderFile + +#include + +#if defined(__cplusplus) + +#include +#include + +//! Function opens the file stream. +//! @param theStream stream to open +//! @param theName name of file encoded in UTF-8 +//! @param theMode opening mode +__Standard_API void OSD_OpenStream (std::ofstream& theStream, + const char* theName, + const std::ios_base::openmode theMode); + +//! Function opens the file stream. +//! @param theStream stream to open +//! @param theName name of file encoded in UTF-16 +//! @param theMode opening mode +__Standard_API void OSD_OpenStream (std::ofstream& theStream, + const TCollection_ExtendedString& theName, + const std::ios_base::openmode theMode); + +//! Function opens the file buffer. +//! @param theBuff file buffer to open +//! @param theName name of file encoded in UTF-8 +//! @param theMode opening mode +__Standard_API void OSD_OpenFileBuf (std::filebuf& theBuff, + const char* theName, + const std::ios_base::openmode theMode); + +//! Function opens the file buffer. +//! @param theBuff file buffer to open +//! @param theName name of file encoded in UTF-16 +//! @param theMode opening mode +__Standard_API void OSD_OpenFileBuf (std::filebuf& theBuff, + const TCollection_ExtendedString& theName, + const std::ios_base::openmode theMode); + + +//! Function opens the file. +//! @param theName name of file encoded in UTF-16 +//! @param theMode opening mode +//! @return file handle of opened file +__Standard_API FILE* OSD_OpenFile (const TCollection_ExtendedString& theName, + const char* theMode); + +extern "C" { +#endif // __cplusplus + +//! Function opens the file. +//! @param theName name of file encoded in UTF-8 +//! @param theMode opening mode +//! @return file handle of opened file +__Standard_API FILE* OSD_OpenFile (const char* theName, const char* theMode); + +#if defined(__cplusplus) +} +#endif // __cplusplus + +#endif // _OSD_OpenFile_HeaderFile diff --git a/src/RWStl/RWStl.cxx b/src/RWStl/RWStl.cxx index 42f0676fd7..55eb902bf8 100644 --- a/src/RWStl/RWStl.cxx +++ b/src/RWStl/RWStl.cxx @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -447,14 +448,13 @@ Handle(StlMesh_Mesh) RWStl::ReadAscii (const OSD_Path& thePath, thePath.SystemName (filename); // Open the file - FILE* file = fopen(filename.ToCString(),"r"); + FILE* file = OSD_OpenFile(filename.ToCString(),"r"); fseek(file,0L,SEEK_END); long filesize = ftell(file); - fclose(file); - file = fopen(filename.ToCString(),"r"); + rewind(file); // count the number of lines for (ipos = 0; ipos < filesize; ++ipos) { @@ -466,8 +466,6 @@ Handle(StlMesh_Mesh) RWStl::ReadAscii (const OSD_Path& thePath, nbTris = (nbLines / ASCII_LINES_PER_FACET); // go back to the beginning of the file -// fclose(file); -// file = fopen(filename.ToCString(),"r"); rewind(file); // skip header diff --git a/src/StdResource/XCAF b/src/StdResource/XCAF index 1a8e4c8fc2..0d3c979e2c 100755 --- a/src/StdResource/XCAF +++ b/src/StdResource/XCAF @@ -22,7 +22,7 @@ BinXCAF.RetrievalPlugin: a78ff497-a779-11d5-aab4-0050044b1af1 ! XmlOcaf format ! XmlOcaf.Description: Xml Document Version 1.0 -XmlOcaf.FileExtension: xml +XmlOcaf.FileExtension: xml XmlOcaf.StoragePlugin: 03a56820-8269-11d5-aab2-0050044b1af1 XmlOcaf.RetrievalPlugin: 03a56822-8269-11d5-aab2-0050044b1af1 ! diff --git a/src/StepFile/StepFile_Read.cxx b/src/StepFile/StepFile_Read.cxx index deb4972796..409e827275 100644 --- a/src/StepFile/StepFile_Read.cxx +++ b/src/StepFile/StepFile_Read.cxx @@ -122,12 +122,7 @@ Standard_Integer StepFile_Read checkread->Clear(); recfile_modeprint ( (modepr > 0 ? modepr-1 : 0) ); -#ifdef _WIN32 - TCollection_ExtendedString aFileNameW(ficnom, Standard_True); - FILE* newin = stepread_setinput((char*)aFileNameW.ToExtString()); -#else FILE* newin = stepread_setinput(ficnom); -#endif if (!newin) return -1; #ifdef CHRONOMESURE Standard_Integer n ; diff --git a/src/StepFile/stepread.c b/src/StepFile/stepread.c index d038391a75..aeff1e9181 100644 --- a/src/StepFile/stepread.c +++ b/src/StepFile/stepread.c @@ -24,6 +24,7 @@ #include #include #include "recfile.ph" +#include /* StepFile_Error.c @@ -84,13 +85,8 @@ FILE* stepread_setinput (char* nomfic) { FILE* newin ; if (strlen(nomfic) == 0) return stepin ; -#ifdef _WIN32 - // file name is treated as UTF-8 string - // nomfic is prepared UTF-8 string - newin = _wfopen((const wchar_t*)nomfic, L"r") ; -#else - newin = fopen(nomfic,"r") ; -#endif + newin = OSD_OpenFile(nomfic,"r"); + if (newin == NULL) { return NULL ; } else { diff --git a/src/StepSelect/StepSelect_WorkLibrary.cxx b/src/StepSelect/StepSelect_WorkLibrary.cxx index dac61f51ca..5ff57af964 100644 --- a/src/StepSelect/StepSelect_WorkLibrary.cxx +++ b/src/StepSelect/StepSelect_WorkLibrary.cxx @@ -38,6 +38,7 @@ #include #include #include +#include StepSelect_WorkLibrary::StepSelect_WorkLibrary (const Standard_Boolean copymode) @@ -84,7 +85,7 @@ Standard_Boolean StepSelect_WorkLibrary::WriteFile if (stepmodel.IsNull() || stepro.IsNull()) return Standard_False; ofstream fout; - fout.open(ctx.FileName(),ios::out|ios::trunc); + OSD_OpenStream(fout,ctx.FileName(),ios::out|ios::trunc); if (!fout || !fout.rdbuf()->is_open()) { ctx.CCheck(0)->AddFail("Step File could not be created"); diff --git a/src/TObj/TObj_Model.cxx b/src/TObj/TObj_Model.cxx index d1aac05c2e..918582d8bf 100644 --- a/src/TObj/TObj_Model.cxx +++ b/src/TObj/TObj_Model.cxx @@ -41,6 +41,7 @@ #include #include #include +#include #ifdef WNT #include @@ -273,7 +274,7 @@ Standard_Boolean TObj_Model::SaveAs (const char* theFile) } */ // checking write access permission - FILE *aF = fopen (theFile, "w"); + FILE *aF = OSD_OpenFile (theFile, "w"); if (aF == NULL) { Messenger()->Send (Message_Msg("TObj_M_NoWriteAccess") << (Standard_CString)theFile, Message_Alarm); @@ -763,7 +764,7 @@ Standard_Boolean TObj_Model::checkDocumentEmpty (const char* theFile) if ( !osdfile.Exists() ) return Standard_True; - FILE* f = fopen( theFile, "r" ); + FILE* f = OSD_OpenFile( theFile, "r" ); if ( f ) { Standard_Boolean isZeroLengh = Standard_False; diff --git a/src/Voxel/Voxel_Reader.cxx b/src/Voxel/Voxel_Reader.cxx index 9282fcd062..06380fa4b6 100644 --- a/src/Voxel/Voxel_Reader.cxx +++ b/src/Voxel/Voxel_Reader.cxx @@ -21,6 +21,7 @@ #include #include +#include Voxel_Reader::Voxel_Reader():myBoolVoxels(0),myColorVoxels(0),myFloatVoxels(0) { @@ -30,7 +31,7 @@ Voxel_Reader::Voxel_Reader():myBoolVoxels(0),myColorVoxels(0),myFloatVoxels(0) Standard_Boolean Voxel_Reader::Read(const TCollection_ExtendedString& file) { // Open file in ASCII mode to read header - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "r"); + FILE* f = OSD_OpenFile(file, "r"); if (!f) return Standard_False; @@ -140,7 +141,7 @@ static Standard_Boolean has_slice(const Standard_CString line) Standard_Boolean Voxel_Reader::ReadBoolAsciiVoxels(const TCollection_ExtendedString& file) { // Open file for reading - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "r"); + FILE* f = OSD_OpenFile(file, "r"); if (!f) return Standard_False; Standard_Character line[65], sx[33], sy[33], sz[33]; @@ -217,7 +218,7 @@ Standard_Boolean Voxel_Reader::ReadBoolAsciiVoxels(const TCollection_ExtendedStr Standard_Boolean Voxel_Reader::ReadColorAsciiVoxels(const TCollection_ExtendedString& file) { // Open file for reading - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "r"); + FILE* f = OSD_OpenFile(file, "r"); if (!f) return Standard_False; Standard_Character line[65], sx[33], sy[33], sz[33]; @@ -294,7 +295,7 @@ Standard_Boolean Voxel_Reader::ReadColorAsciiVoxels(const TCollection_ExtendedSt Standard_Boolean Voxel_Reader::ReadFloatAsciiVoxels(const TCollection_ExtendedString& file) { // Open file for reading - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "r"); + FILE* f = OSD_OpenFile(file, "r"); if (!f) return Standard_False; Standard_Character line[65], sx[33], sy[33], sz[33]; @@ -373,7 +374,7 @@ Standard_Boolean Voxel_Reader::ReadFloatAsciiVoxels(const TCollection_ExtendedSt Standard_Boolean Voxel_Reader::ReadBoolBinaryVoxels(const TCollection_ExtendedString& file) { // Open file for reading - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "rb"); + FILE* f = OSD_OpenFile(file, "r"); if (!f) return Standard_False; @@ -428,7 +429,7 @@ Standard_Boolean Voxel_Reader::ReadBoolBinaryVoxels(const TCollection_ExtendedSt Standard_Boolean Voxel_Reader::ReadColorBinaryVoxels(const TCollection_ExtendedString& file) { // Open file for reading - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "rb"); + FILE* f = OSD_OpenFile(file, "r"); if (!f) return Standard_False; @@ -483,7 +484,7 @@ Standard_Boolean Voxel_Reader::ReadColorBinaryVoxels(const TCollection_ExtendedS Standard_Boolean Voxel_Reader::ReadFloatBinaryVoxels(const TCollection_ExtendedString& file) { // Open file for reading - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "rb"); + FILE* f = OSD_OpenFile(file, "r"); if (!f) return Standard_False; diff --git a/src/Voxel/Voxel_Writer.cxx b/src/Voxel/Voxel_Writer.cxx index c3613c0bbd..e8677c8941 100644 --- a/src/Voxel/Voxel_Writer.cxx +++ b/src/Voxel/Voxel_Writer.cxx @@ -18,6 +18,7 @@ #include #include +#include Voxel_Writer::Voxel_Writer():myFormat(Voxel_VFF_ASCII),myBoolVoxels(0),myColorVoxels(0),myFloatVoxels(0) { @@ -85,7 +86,7 @@ Standard_Boolean Voxel_Writer::WriteBoolAsciiVoxels(const TCollection_ExtendedSt return Standard_False; // Open file for writing - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "w+"); + FILE* f = OSD_OpenFile(file, "w+"); if (!f) return Standard_False; @@ -144,7 +145,7 @@ Standard_Boolean Voxel_Writer::WriteColorAsciiVoxels(const TCollection_ExtendedS return Standard_False; // Open file for writing - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "w+"); + FILE* f = OSD_OpenFile(file, "w+"); if (!f) return Standard_False; @@ -203,7 +204,7 @@ Standard_Boolean Voxel_Writer::WriteFloatAsciiVoxels(const TCollection_ExtendedS return Standard_False; // Open file for writing - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "w+"); + FILE* f = OSD_OpenFile(file, "w+"); if (!f) return Standard_False; @@ -262,7 +263,7 @@ Standard_Boolean Voxel_Writer::WriteBoolBinaryVoxels(const TCollection_ExtendedS return Standard_False; // Open file for writing - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "wb"); + FILE* f = OSD_OpenFile(file, "wb"); if (!f) return Standard_False; @@ -322,7 +323,7 @@ Standard_Boolean Voxel_Writer::WriteColorBinaryVoxels(const TCollection_Extended return Standard_False; // Open file for writing - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "wb"); + FILE* f = OSD_OpenFile(file, "wb"); if (!f) return Standard_False; @@ -382,7 +383,7 @@ Standard_Boolean Voxel_Writer::WriteFloatBinaryVoxels(const TCollection_Extended return Standard_False; // Open file for writing - FILE* f = fopen(TCollection_AsciiString(file, '?').ToCString(), "wb"); + FILE* f = OSD_OpenFile(file, "wb"); if (!f) return Standard_False; diff --git a/src/VrmlAPI/VrmlAPI_Writer.cxx b/src/VrmlAPI/VrmlAPI_Writer.cxx index a77c735c21..a31c9d203f 100644 --- a/src/VrmlAPI/VrmlAPI_Writer.cxx +++ b/src/VrmlAPI/VrmlAPI_Writer.cxx @@ -30,6 +30,7 @@ #include #include #include +#include VrmlAPI_Writer::VrmlAPI_Writer() { @@ -216,7 +217,7 @@ void VrmlAPI_Writer::Write(const TopoDS_Shape& aShape,const Standard_CString aFi OSD_Path thePath(aFile); TCollection_AsciiString theFile;thePath.SystemName(theFile); ofstream outfile; - outfile.open(theFile.ToCString(), ios::out); + OSD_OpenStream(outfile, theFile.ToCString(), ios::out); Handle(VrmlConverter_IsoAspect) ia = new VrmlConverter_IsoAspect; // UIso Handle(VrmlConverter_IsoAspect) ia1 = new VrmlConverter_IsoAspect; //VIso ia->SetMaterial(myUisoMaterial); diff --git a/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx b/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx index 123dd16cc3..1aa875ef10 100644 --- a/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx +++ b/src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx @@ -43,6 +43,7 @@ #include #include +#include #define STORAGE_VERSION "STORAGE_VERSION: " #define REFERENCE_COUNTER "REFERENCE_COUNTER: " @@ -115,8 +116,7 @@ void XmlLDrivers_DocumentStorageDriver::Write if (WriteToDomDocument (theDocument, anElement, theFileName) == Standard_False) { // Write DOM_Document into XML file, - TCollection_AsciiString aFileName (theFileName, '?'); - FILE * aFile = fopen(aFileName.ToCString(), "wt"); + FILE * aFile = OSD_OpenFile(theFileName, "wt"); if (aFile) { LDOM_XmlWriter aWriter (aFile); @@ -129,7 +129,7 @@ void XmlLDrivers_DocumentStorageDriver::Write SetIsError (Standard_True); SetStoreStatus(PCDM_SS_WriteFailure); TCollection_ExtendedString aMsg = - TCollection_ExtendedString("Error: the file ") + aFileName + + TCollection_ExtendedString("Error: the file ") + theFileName + " cannot be opened for writing"; aMessageDriver -> Write (aMsg.ToExtString()); Standard_Failure::Raise("File cannot be opened for writing"); diff --git a/tests/bugs/fclasses/bug25367_brep b/tests/bugs/fclasses/bug25367_brep new file mode 100644 index 0000000000..fccfa75a3b --- /dev/null +++ b/tests/bugs/fclasses/bug25367_brep @@ -0,0 +1,33 @@ +puts "==========" +puts "OCC25367" +puts "==========" +puts "" +################################################################ +# IGES and BRep persistence - support unicode file names on Windows +################################################################ + +set s [encoding convertfrom unicode "\xDE\x30\xF9\x30\xF1\x30"] + +set NameFile ${imagedir}/OCC25367_${s}.brep + +box b 1 1 1 + +bsave b ${NameFile} + +brestore ${NameFile} result + +set square 6 + +set nb_v_good 8 +set nb_e_good 12 +set nb_w_good 6 +set nb_f_good 6 +set nb_sh_good 1 +set nb_sol_good 1 +set nb_compsol_good 0 +set nb_compound_good 0 +set nb_shape_good 34 + +file delete -force [glob -nocomplain ${NameFile}] + +set 2dviewer 1 diff --git a/tests/bugs/fclasses/bug25367_igs b/tests/bugs/fclasses/bug25367_igs new file mode 100644 index 0000000000..c7c27037f3 --- /dev/null +++ b/tests/bugs/fclasses/bug25367_igs @@ -0,0 +1,37 @@ +puts "==========" +puts "OCC25367" +puts "==========" +puts "" +################################################################ +# IGES and BRep persistence - support unicode file names on Windows +################################################################ + +pload XDE + +set s [encoding convertfrom unicode "\xDE\x30\xF9\x30\xF1\x30"] + +set NameFile ${imagedir}/OCC25367_${s}.igs + +box b 1 1 1 + +param write.iges.brep.mode 1 + +brepiges b ${NameFile} + +igesbrep ${NameFile} result * + +set square 6 + +set nb_v_good 8 +set nb_e_good 12 +set nb_w_good 6 +set nb_f_good 6 +set nb_sh_good 1 +set nb_sol_good 1 +set nb_compsol_good 0 +set nb_compound_good 0 +set nb_shape_good 34 + +file delete -force [glob -nocomplain ${NameFile}] + +set 2dviewer 1 diff --git a/tests/bugs/mesh/bug25364 b/tests/bugs/mesh/bug25364 index 0092759d82..130c8b5f76 100755 --- a/tests/bugs/mesh/bug25364 +++ b/tests/bugs/mesh/bug25364 @@ -72,6 +72,11 @@ set mem_delta_wsetpeak 180 set mem_delta_virt 180 set mem_delta_heap 80 +if { [regexp {Debug mode} [dversion]] } { + set mem_delta_swap 150 + set mem_delta_swappeak 250 +} + if { [expr ${mem_private_2} - ${mem_private_1}] > ${mem_delta_private}} { puts "Error : there is memory problem (private)" } diff --git a/tests/bugs/moddata_2/bug22993 b/tests/bugs/moddata_2/bug22993 index 6ad60e9a94..046cbc1164 100755 --- a/tests/bugs/moddata_2/bug22993 +++ b/tests/bugs/moddata_2/bug22993 @@ -1,4 +1,3 @@ -puts "TODO OCC11111 ALL: StepFile Error" puts "===========" puts "OCC22993" puts "===========" diff --git a/tests/bugs/step/bug133_2 b/tests/bugs/step/bug133_2 index 610922de1b..e74f803aba 100755 --- a/tests/bugs/step/bug133_2 +++ b/tests/bugs/step/bug133_2 @@ -1,5 +1,3 @@ -puts "TODO OCC12345 ALL: StepFile Error" - puts "========================" puts "BUC60992" puts "OCC98"