Handle(Poly_Triangulation) RWStl::ReadBinary (const OSD_Path& theFile,
const Message_ProgressRange& theProgress)
{
- OSD_File aFile(theFile);
- if (!aFile.Exists())
- {
- return Handle(Poly_Triangulation)();
- }
-
TCollection_AsciiString aPath;
theFile.SystemName (aPath);
Handle(Poly_Triangulation) RWStl::ReadAscii (const OSD_Path& theFile,
const Message_ProgressRange& theProgress)
{
- OSD_File aFile (theFile);
- if (!aFile.Exists())
- {
- return Handle(Poly_Triangulation)();
- }
-
TCollection_AsciiString aPath;
theFile.SystemName (aPath);
- std::filebuf aBuf;
- OSD_OpenStream (aBuf, aPath, std::ios::in | std::ios::binary);
- if (!aBuf.is_open())
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ std::shared_ptr<std::istream> aStream = aFileSystem->OpenIStream (aPath, std::ios::in | std::ios::binary);
+ if (aStream.get() == NULL)
{
return Handle(Poly_Triangulation)();
}
- Standard_IStream aStream (&aBuf);
// get length of file to feed progress indicator
- aStream.seekg (0, aStream.end);
- std::streampos theEnd = aStream.tellg();
- aStream.seekg (0, aStream.beg);
+ aStream->seekg (0, aStream->end);
+ std::streampos theEnd = aStream->tellg();
+ aStream->seekg (0, aStream->beg);
Reader aReader;
Standard_ReadLineBuffer aBuffer (THE_BUFFER_SIZE);
- if (!aReader.ReadAscii (aStream, aBuffer, theEnd, theProgress))
+ if (!aReader.ReadAscii (*aStream, aBuffer, theEnd, theProgress))
{
return Handle(Poly_Triangulation)();
}
FILE* theFile,
const Message_ProgressRange& theProgress)
{
- char aHeader[80] = "STL Exported by OpenCASCADE [www.opencascade.com]";
+ char aHeader[80] = "STL Exported by Open CASCADE Technology [dev.opencascade.org]";
if (fwrite (aHeader, 1, 80, theFile) != 80)
{
return Standard_False;
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-// StepFile_Read
-
-// routine assurant l enchainement des operations de lecture d un fichier
-// STEP dans un StepModel, en fonction d une cle de reconnaissance
-// Retour de la fonction :
-// 0 si OK (le StepModel a ete charge)
-// -1 si abandon car fichier pas pu etre ouvert
-// 1 si erreur en cours de lecture
-
-// Compilation conditionnelle : concerne les mesures de performances
-
-#include <stdio.h>
-#include <iostream>
-
-#include <step.tab.hxx>
#include <StepFile_Read.hxx>
+
#include <StepFile_ReadData.hxx>
#include <Interface_Check.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
-#include <OSD_OpenFile.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_Timer.hxx>
+#include "step.tab.hxx"
+
+#include <stdio.h>
+
#ifdef OCCT_DEBUG
#define CHRONOMESURE
#endif
const Handle(StepData_FileRecognizer)& theRecogData)
{
// if stream is not provided, open file stream here
- std::istream *aStreamPtr = theIStream;
- std::ifstream aFileStream;
- if (!aStreamPtr) {
- OSD_OpenStream(aFileStream, theName, std::ios_base::in | std::ios_base::binary);
- aStreamPtr = &aFileStream;
+ std::istream* aStreamPtr = theIStream;
+ std::shared_ptr<std::istream> aFileStream;
+ if (aStreamPtr == nullptr)
+ {
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ aFileStream = aFileSystem->OpenIStream (theName, std::ios::in | std::ios::binary);
+ aStreamPtr = aFileStream.get();
}
-
- if (aStreamPtr->fail())
+ if (aStreamPtr == nullptr || aStreamPtr->fail())
{
return -1;
}