]> OCCT Git - occt-copy.git/commitdiff
0025367: IGES and BRep persistence - support unicode file names on Windows
authorpdn <pdn@opencascade.com>
Wed, 22 Oct 2014 08:17:10 +0000 (12:17 +0400)
committerbugmaster <bugmaster@opencascade.com>
Thu, 6 Nov 2014 10:55:51 +0000 (13:55 +0300)
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

27 files changed:
src/BRepTools/BRepTools.cxx
src/FSD/FSD_BinaryFile.cxx
src/IFSelect/IFSelect_SessionFile.cxx
src/IFSelect/IFSelect_SessionPilot.cxx
src/IGESControl/IGESControl_Writer.cxx
src/IGESFile/igesread.c
src/IGESSelect/IGESSelect_WorkLibrary.cxx
src/Image/Image_AlienPixMap.cxx
src/Message/Message_MsgFile.cxx
src/OSD/FILES
src/OSD/OSD_OpenFile.cxx [new file with mode: 0644]
src/OSD/OSD_OpenFile.hxx [new file with mode: 0644]
src/RWStl/RWStl.cxx
src/StdResource/XCAF
src/StepFile/StepFile_Read.cxx
src/StepFile/stepread.c
src/StepSelect/StepSelect_WorkLibrary.cxx
src/TObj/TObj_Model.cxx
src/Voxel/Voxel_Reader.cxx
src/Voxel/Voxel_Writer.cxx
src/VrmlAPI/VrmlAPI_Writer.cxx
src/XmlLDrivers/XmlLDrivers_DocumentStorageDriver.cxx
tests/bugs/fclasses/bug25367_brep [new file with mode: 0644]
tests/bugs/fclasses/bug25367_igs [new file with mode: 0644]
tests/bugs/mesh/bug25364
tests/bugs/moddata_2/bug22993
tests/bugs/step/bug133_2

index 58e56b19363823526321fcdb754c2353e66bc231..ec467ee53815f6370ead562f6895690c5498974f 100644 (file)
@@ -50,6 +50,7 @@
 #include <Standard_ErrorHandler.hxx>
 #include <Standard_Failure.hxx>
 #include <Geom_RectangularTrimmedSurface.hxx>
+#include <OSD_OpenFile.hxx>
 
 #include <errno.h>
 
@@ -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);
index c04a9b549b842c836a872a72ecca803e2ba758dd..bb90cd171f37139d762314a58f8f95f6a288c588 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <FSD_BinaryFile.ixx>
 #include <OSD.hxx>
+#include <OSD_OpenFile.hxx>
 
 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;
index 56d8926fc00f13ece7caf5ca2666bc76a361e31f..0c954e2ce70e616e8799bf4bdf5e15a03a74e39b 100644 (file)
@@ -33,6 +33,8 @@
 #include <Interface_Macros.hxx>
 #include <stdio.h>
 
+#include <OSD_OpenFile.hxx>
+
 
 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
index 09bd9f1f214a68e67770e3ff98fba4495479d853..ef8daf05084de63899b9f63c22131f92c2431327 100644 (file)
@@ -23,6 +23,7 @@
 #include <Interface_Macros.hxx>
 #include <Message_Messenger.hxx>
 #include <Message.hxx>
+#include <OSD_OpenFile.hxx>
 
 #include <stdio.h>
 
@@ -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 "<<file<<" not found"<<endl; return IFSelect_RetFail; }
     cout << " ...   Reading Script File " << file << endl;
index 8f8caf127a5d1eef151b48ddcd92ff97453cab85..99ef6ddc6dfd9aa4a579039d88e4ea691b0e12e0 100644 (file)
@@ -44,6 +44,7 @@
 #include <TopExp_Explorer.hxx>
 #include <Message_ProgressIndicator.hxx>
 #include <errno.h>
+#include <OSD_OpenFile.hxx>
 
 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") <<"): "<<file<<endl;
index 1f0ef5501d792e2aa29f10881c465cab2f5289d3..7b845631a96d3d87c30e950cdcaeef4aa03df7da 100644 (file)
@@ -16,6 +16,7 @@
 /*  Regroupement des sources "C" pour compilation   */ 
 #include <stdio.h>
 #include "igesread.h"
+#include <OSD_OpenFile.hxx>
 
 /*
 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;
index a025dd62f62a5eb5f85a589663de2eb4707cbedf..b7f0aa49021ce247950f09709437e3816b9ab964 100644 (file)
@@ -39,6 +39,7 @@
 #include <Interface_Check.hxx>
 
 #include <Interface_Macros.hxx>
+#include <OSD_OpenFile.hxx>
 #include <errno.h>
 
 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;
index 6a97c643b14df241f56076a48111b1f87c85dd94..a264254dd1c6ee75af0139af355fdbff0ef47b19 100644 (file)
@@ -25,6 +25,7 @@
 #include <gp.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
+#include <OSD_OpenFile.hxx>
 #include <fstream>
 #include <algorithm>
 
@@ -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;
index 1dbf2f871ed7ab9a1b4de378dab0b5e294c18762..735182c7dd6505aab06151f56d08a35792ca7732 100644 (file)
@@ -20,6 +20,7 @@
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_ExtendedString.hxx>
 #include <Standard_Mutex.hxx>
+#include <OSD_OpenFile.hxx>
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -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
index 57865f5ac1c579943db8355b2a4d5dbfd3dff223..eadc93711e295876c03132a145804357e54fec51 100755 (executable)
@@ -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 (file)
index 0000000..c2e37cd
--- /dev/null
@@ -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 <OSD_OpenFile.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <NCollection_UtfString.hxx>
+
+// ==============================================
+// 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 (file)
index 0000000..5c4a70a
--- /dev/null
@@ -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 <Standard_Macro.hxx>
+
+#if defined(__cplusplus)
+
+#include <fstream>
+#include <TCollection_ExtendedString.hxx>
+
+//! 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
index 42f0676fd7833d18b20e6f6af5891bceef3cfd18..55eb902bf8b24386f23654324e6b32beda914f9c 100644 (file)
@@ -29,6 +29,7 @@
 #include <gp.hxx>
 #include <stdio.h>
 #include <gp_Vec.hxx>
+#include <OSD_OpenFile.hxx>
 
 #include <BRepBuilderAPI_CellFilter.hxx>
 #include <BRepBuilderAPI_VertexInspector.hxx>
@@ -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
index 1a8e4c8fc2c222e280e5d02f6e9fa4a872f1b32a..0d3c979e2c464ff96e6f2eb3038a862785e2594a 100755 (executable)
@@ -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
 !
index deb4972796d01771d8de73751390f985702cb058..409e827275245d409079b31af49416d84e159fd5 100644 (file)
@@ -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 ; 
index d038391a7506c9368afec70bce3d4f6712310b19..aeff1e918123c336f931b1070dabf99a2d8ca4b6 100644 (file)
@@ -24,6 +24,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "recfile.ph"
+#include <OSD_OpenFile.hxx>
 
 /*    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 {
index dac61f51ca91aaa81559e310676d6759273bc271..5ff57af96450f882a565fe70cffaaeb79f84f010 100644 (file)
@@ -38,6 +38,7 @@
 #include <Message_Messenger.hxx>
 #include <Interface_Macros.hxx>
 #include <Interface_Check.hxx>
+#include <OSD_OpenFile.hxx>
 
 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");
index d1aac05c2e2830f483b6bbc886d742ea365fdd89..918582d8bf49878ec01832541e0ae1113d9c3595 100644 (file)
@@ -41,6 +41,7 @@
 #include <TObj_TModel.hxx>
 #include <TObj_TNameContainer.hxx>
 #include <Message_Msg.hxx>
+#include <OSD_OpenFile.hxx>
 
 #ifdef WNT
   #include <io.h>
@@ -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;
index 9282fcd0627837c8c039fe7ca9b21bfef05b76b5..06380fa4b69b3e6b891aea89c5084252c8e846b5 100644 (file)
@@ -21,6 +21,7 @@
 #include <Voxel_TypeDef.hxx>
 
 #include <TCollection_AsciiString.hxx>
+#include <OSD_OpenFile.hxx>
 
 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;
 
index c3613c0bbd1bb6dafb407c071bfaadbdd010e432..e8677c8941c4a811c8828fb15f5a6784386427c4 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <Precision.hxx>
 #include <TCollection_AsciiString.hxx>
+#include <OSD_OpenFile.hxx>
 
 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;
 
index a77c735c21653fd3fc40a42b020d5cb4df76dd92..a31c9d203ffe23a6bb14a4ed0e20e04def2f979d 100644 (file)
@@ -30,6 +30,7 @@
 #include <Vrml_Instancing.hxx>
 #include <Vrml_Separator.hxx>
 #include <VrmlConverter_WFDeflectionShape.hxx>
+#include <OSD_OpenFile.hxx>
 
 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);
index 123dd16cc38fb24713e8c422b46155ffd1778c42..1aa875ef100a6ca7a1bf520bdf36329b8bbb6e12 100644 (file)
@@ -43,6 +43,7 @@
 
 #include <OSD_File.hxx>
 #include <OSD_Environment.hxx>
+#include <OSD_OpenFile.hxx>
 
 #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 (file)
index 0000000..fccfa75
--- /dev/null
@@ -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 (file)
index 0000000..c7c2703
--- /dev/null
@@ -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
index 0092759d82b2b8ae520ca3fb02056b5c15ba3123..130c8b5f764c81d19bc2a4b1256757dc8c044559 100755 (executable)
@@ -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)"
 }
index 6ad60e9a94a24fee843f363a576f3eee242d6880..046cbc1164c40c3b08dd9da2cb3569e9e6a451fa 100755 (executable)
@@ -1,4 +1,3 @@
-puts "TODO OCC11111 ALL: StepFile Error"
 puts "==========="
 puts "OCC22993"
 puts "==========="
index 610922de1b9f5406212c0bdb6c294a7085f0f10c..e74f803aba44dfeed1107c81b40f41a7779f4199 100755 (executable)
@@ -1,5 +1,3 @@
-puts "TODO OCC12345 ALL: StepFile Error"
-
 puts "========================"
 puts "BUC60992"
 puts "OCC98"