const BRep_Builder& B,
const Message_ProgressRange& theProgress)
{
- std::filebuf fic;
- std::istream in(&fic);
- OSD_OpenStream (fic, File, std::ios::in);
- if(!fic.is_open()) return Standard_False;
-
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aStream = aFileSystem->OpenIStream (File, std::ios::in);
+ if (aStream.get() == NULL)
+ {
+ return Standard_False;
+ }
BRepTools_ShapeSet SS(B);
- SS.Read(in, theProgress);
+ SS.Read (*aStream, theProgress);
if(!SS.NbShapes()) return Standard_False;
- SS.Read(Sh,in);
+ SS.Read (Sh,*aStream);
return Standard_True;
}
#include <Message_Messenger.hxx>
#include <FSD_BinaryFile.hxx>
#include <FSD_FileHeader.hxx>
-#include <OSD_OpenFile.hxx>
+#include <OSD_FileSystem.hxx>
#include <PCDM_Document.hxx>
#include <PCDM_ReadWriter.hxx>
#include <Standard_ErrorHandler.hxx>
const Handle(PCDM_ReaderFilter)& theFilter,
const Message_ProgressRange& theRange)
{
- std::ifstream aFileStream;
- OSD_OpenStream (aFileStream, theFileName, std::ios::in | std::ios::binary);
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFileStream = aFileSystem->OpenIStream (theFileName, std::ios::in | std::ios::binary);
- if (aFileStream.is_open() && aFileStream.good())
+ if (aFileStream.get() != NULL && aFileStream->good())
{
Handle(Storage_Data) dData;
- TCollection_ExtendedString aFormat = PCDM_ReadWriter::FileFormat (aFileStream, dData);
+ TCollection_ExtendedString aFormat = PCDM_ReadWriter::FileFormat (*aFileStream, dData);
- Read (aFileStream, dData, theNewDocument, theApplication, theFilter, theRange);
+ Read (*aFileStream, dData, theNewDocument, theApplication, theFilter, theRange);
if (!theRange.More())
{
myReaderStatus = PCDM_RS_UserBreak;
#include <BinTools.hxx>
#include <BinTools_ShapeSet.hxx>
#include <FSD_FileHeader.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_OpenFile.hxx>
#include <Storage_StreamTypeMismatchError.hxx>
Standard_Boolean BinTools::Read (TopoDS_Shape& theShape, const Standard_CString theFile,
const Message_ProgressRange& theRange)
{
- std::filebuf aBuf;
- OSD_OpenStream (aBuf, theFile, std::ios::in | std::ios::binary);
- if (!aBuf.is_open())
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aStream = aFileSystem->OpenIStream (theFile, std::ios::in | std::ios::binary);
+ if (aStream.get() == NULL)
+ {
return Standard_False;
+ }
- Standard_IStream aStream (&aBuf);
- Read (theShape, aStream, theRange);
- return aStream.good();
+ Read (theShape, *aStream, theRange);
+ return aStream->good();
}
#include <GProp.hxx>
#include <GProp_GProps.hxx>
#include <NCollection_Vector.hxx>
-#include <OSD_OpenFile.hxx>
+#include <OSD_FileSystem.hxx>
#include <Precision.hxx>
#include <TColStd_Array1OfInteger.hxx>
#include <TColStd_Array1OfReal.hxx>
bool isBinaryFormat = true;
{
// probe file header to recognize format
- std::ifstream aFile;
- OSD_OpenStream (aFile, aFileName, std::ios::in | std::ios::binary);
- if (!aFile.is_open())
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream (aFileName, std::ios::in | std::ios::binary);
+ if (aFile.get() == NULL)
{
theDI << "Error: cannot read the file '" << aFileName << "'";
return 1;
}
char aStringBuf[255] = {};
- aFile.read (aStringBuf, 255);
- if (aFile.fail())
+ aFile->read (aStringBuf, 255);
+ if (aFile->fail())
{
theDI << "Error: cannot read the file '" << aFileName << "'";
return 1;
#include <TDF_Tool.hxx>
#include <PCDM_ReaderFilter.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_Path.hxx>
#include <OSD_OpenFile.hxx>
#include <TDocStd_PathParser.hxx>
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator(di, 1);
if (anUseStream)
{
- std::ifstream aFileStream;
- OSD_OpenStream (aFileStream, path, std::ios::in | std::ios::binary);
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFileStream = aFileSystem->OpenIStream (path, std::ios::in | std::ios::binary);
- theStatus = A->Open (aFileStream, D, aFilter, aProgress->Start());
+ theStatus = A->Open (*aFileStream, D, aFilter, aProgress->Start());
}
else
{
#include <errno.h>
#include <OSD_Environment.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_OpenFile.hxx>
Standard_Boolean Draw_ParseFailed = Standard_True;
const char* aFileName = theArgVec[1];
const char* aVarName = theArgVec[2];
-
- std::filebuf aFileBuf;
- std::istream aStream (&aFileBuf);
- OSD_OpenStream (aFileBuf, aFileName, std::ios::in);
- if (!aFileBuf.is_open())
+
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aStream = aFileSystem->OpenIStream (aFileName, std::ios::in);
+ if (aStream.get() == NULL)
{
theDI << "Error: cannot open file for reading: '" << aFileName << "'";
return 1;
}
-
char aType[255] = {};
- aStream >> aType;
- if (aStream.fail())
+ *aStream >> aType;
+ if (aStream->fail())
{
theDI << "Error: cannot read file: '" << aFileName << "'";
return 1;
{
Handle(Draw_ProgressIndicator) aProgress = new Draw_ProgressIndicator (theDI, 1);
Draw::SetProgressBar (aProgress);
- Handle(Draw_Drawable3D) aDrawable = Draw_Drawable3D::Restore (aType, aStream);
+ Handle(Draw_Drawable3D) aDrawable = Draw_Drawable3D::Restore (aType, *aStream);
if (aDrawable.IsNull())
{
// assume that this file stores a DBRep_DrawableShape variable
- aStream.seekg (0, std::ios::beg);
- aDrawable = Draw_Drawable3D::Restore ("DBRep_DrawableShape", aStream);
+ aStream->seekg (0, std::ios::beg);
+ aDrawable = Draw_Drawable3D::Restore ("DBRep_DrawableShape", *aStream);
}
if (aDrawable.IsNull())
{
#include <Image_PixMap.hxx>
#include <Image_SupportedFormats.hxx>
#include <Message.hxx>
-#include <OSD_OpenFile.hxx>
+#include <OSD_FileSystem.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Image_CompressedPixMap, Standard_Transient)
const Standard_Integer theFaceIndex,
const int64_t theFileOffset)
{
- std::ifstream aFile;
- OSD_OpenStream (aFile, theFile.ToCString(), std::ios::in | std::ios::binary);
-
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream (theFile, std::ios::in | std::ios::binary);
char aHeader[128] = {};
- if (!aFile.is_open()
- || !aFile.good())
+ if (aFile.get() == NULL || !aFile->good())
{
return Handle(Image_CompressedPixMap)();
}
if (theFileOffset != 0)
{
- aFile.seekg ((std::streamoff )theFileOffset, std::ios::beg);
+ aFile->seekg ((std::streamoff )theFileOffset, std::ios::beg);
}
- aFile.read (aHeader, 128);
- Standard_Size aNbReadBytes = (Standard_Size )aFile.gcount();
+ aFile->read (aHeader, 128);
+ Standard_Size aNbReadBytes = (Standard_Size )aFile->gcount();
if (aNbReadBytes < 128
|| ::memcmp (aHeader, "DDS ", 4) != 0)
{
const Standard_Size anOffset = aDef->FaceBytes() * theFaceIndex;
if (anOffset != 0)
{
- aFile.seekg ((std::streamoff )anOffset, std::ios::cur);
+ aFile->seekg ((std::streamoff )anOffset, std::ios::cur);
}
Handle(NCollection_Buffer) aBuffer = new NCollection_Buffer (Image_PixMap::DefaultAllocator(), aDef->FaceBytes());
- aFile.read ((char* )aBuffer->ChangeData(), aDef->FaceBytes());
- aNbReadBytes = (Standard_Size )aFile.gcount();
+ aFile->read ((char* )aBuffer->ChangeData(), aDef->FaceBytes());
+ aNbReadBytes = (Standard_Size )aFile->gcount();
if (aNbReadBytes < aDef->FaceBytes())
{
Message::SendFail (TCollection_AsciiString ("DDS Reader error - unable to read face #") + theFaceIndex + " data from file\n" + theFile);
#include <Image_SupportedFormats.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_OpenFile.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Image_Texture, Standard_Transient)
return Handle(Image_PixMap)();
}
- std::ifstream aFile;
- OSD_OpenStream (aFile, thePath.ToCString(), std::ios::in | std::ios::binary);
- if (!aFile)
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream (thePath, std::ios::in | std::ios::binary);
+ if (aFile.get() == NULL)
{
Message::SendFail (TCollection_AsciiString ("Error: Image file '") + thePath + "' cannot be opened");
return Handle(Image_PixMap)();
}
- aFile.seekg ((std::streamoff )theOffset, std::ios_base::beg);
- if (!aFile.good())
+ aFile->seekg ((std::streamoff )theOffset, std::ios_base::beg);
+ if (!aFile->good())
{
Message::SendFail (TCollection_AsciiString ("Error: Image is defined with invalid file offset '") + thePath + "'");
return Handle(Image_PixMap)();
}
Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
- if (!anImage->Load (aFile, thePath))
+ if (!anImage->Load (*aFile, thePath))
{
return Handle(Image_PixMap)();
}
}
else
{
- std::ifstream aFileIn;
- OSD_OpenStream (aFileIn, myImagePath.ToCString(), std::ios::in | std::ios::binary);
- if (!aFileIn)
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFileIn = aFileSystem->OpenIStream (myImagePath, std::ios::in | std::ios::binary);
+ if (aFileIn.get() == NULL)
{
Message::SendFail (TCollection_AsciiString ("Error: Unable to open file '") + myImagePath + "'");
return false;
}
if (myOffset >= 0)
{
- aFileIn.seekg ((std::streamoff )myOffset, std::ios_base::beg);
- if (!aFileIn.good())
+ aFileIn->seekg ((std::streamoff )myOffset, std::ios_base::beg);
+ if (!aFileIn->good())
{
Message::SendFail (TCollection_AsciiString ("Error: Image is defined with invalid file offset '") + myImagePath + "'");
return false;
}
}
- if (!aFileIn.read (aBuffer, THE_PROBE_SIZE))
+ if (!aFileIn->read (aBuffer, THE_PROBE_SIZE))
{
Message::SendFail (TCollection_AsciiString ("Error: unable to read image file '") + myImagePath + "'");
return false;
return true;
}
- std::ifstream aFileIn;
- OSD_OpenStream (aFileIn, myImagePath.ToCString(), std::ios::in | std::ios::binary);
- if (!aFileIn)
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFileIn = aFileSystem->OpenIStream (myImagePath, std::ios::in | std::ios::binary);
+ if (aFileIn.get() == NULL)
{
Message::SendFail (TCollection_AsciiString ("Error: Unable to open file ") + myImagePath + "!");
return false;
int64_t aLen = myLength;
if (myOffset >= 0)
{
- aFileIn.seekg ((std::streamoff )myOffset, std::ios_base::beg);
- if (!aFileIn.good())
+ aFileIn->seekg ((std::streamoff )myOffset, std::ios_base::beg);
+ if (!aFileIn->good())
{
Message::SendFail (TCollection_AsciiString ("Error: Image is defined with invalid file offset '") + myImagePath + "'");
return false;
}
else
{
- aFileIn.seekg (0, std::ios_base::end);
- aLen = (int64_t )aFileIn.tellg();
- aFileIn.seekg (0, std::ios_base::beg);
+ aFileIn->seekg (0, std::ios_base::end);
+ aLen = (int64_t )aFileIn->tellg();
+ aFileIn->seekg (0, std::ios_base::beg);
}
Standard_Integer aChunkSize = 4096;
{
aChunkSize = Standard_Integer(aLen - aChunkIter);
}
- if (!aFileIn.read ((char* )&aBuffer.ChangeFirst(), aChunkSize))
+ if (!aFileIn->read ((char* )&aBuffer.ChangeFirst(), aChunkSize))
{
Message::SendFail (TCollection_AsciiString ("Error: unable to read image file '") + myImagePath + "'");
return false;
#include <LDOM_BasicText.hxx>
#include <LDOM_CharReference.hxx>
#include <TCollection_ExtendedString.hxx>
-#include <OSD_OpenFile.hxx>
+#include <OSD_FileSystem.hxx>
#include <fcntl.h>
#ifdef _MSC_VER
Standard_Boolean LDOMParser::parse (const char * const aFileName)
{
- std::ifstream aFileStream;
- OSD_OpenStream (aFileStream, aFileName, std::ios::in);
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFileStream = aFileSystem->OpenIStream (aFileName, std::ios::in);
- if (aFileStream.good())
+ if (aFileStream.get() != NULL && aFileStream->good())
{
- return parse (aFileStream);
+ return parse (*aFileStream);
}
else
{
#include <Graphic3d_Texture2Dmanual.hxx>
#include <Image_AlienPixMap.hxx>
-#include <OSD_OpenFile.hxx>
+#include <OSD_FileSystem.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include <Standard_ArrayStreamBuffer.hxx>
//=======================================================================
}
else
{
- std::ifstream aFile;
- OSD_OpenStream (aFile, anImgPath.ToCString(), std::ios::in | std::ios::binary);
- if (!aFile.is_open())
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream (anImgPath, std::ios::in | std::ios::binary);
+ if (aFile.get() == NULL)
{
std::cout << "Syntax error: image file '" << anImgPath << "' cannot be found\n";
return 1;
}
if (anOffset != 0)
{
- aFile.seekg (anOffset);
+ aFile->seekg (anOffset);
}
if (aSrc == 2)
{
- aFile.seekg (0, std::ios::end);
- Standard_Integer aLen = (Standard_Integer )aFile.tellg() - anOffset;
- aFile.seekg (anOffset);
+ aFile->seekg (0, std::ios::end);
+ Standard_Integer aLen = (Standard_Integer )aFile->tellg() - anOffset;
+ aFile->seekg (anOffset);
if (aLen <= 0)
{
std::cout << "Syntax error: wrong offset\n";
return 1;
}
NCollection_Array1<Standard_Byte> aBuff (1, aLen);
- if (!aFile.read ((char* )&aBuff.ChangeFirst(), aBuff.Size()))
+ if (!aFile->read ((char* )&aBuff.ChangeFirst(), aBuff.Size()))
{
std::cout << "Error: unable to read file\n";
return 1;
}
- aFile.close();
if (!anImage->Load (&aBuff.ChangeFirst(), aBuff.Size(), anImgPath))
{
return 0;
}
else
{
- if (!anImage->Load (aFile, anImgPath))
+ if (!anImage->Load (*aFile, anImgPath))
{
return 0;
}
#include <NCollection_Buffer.hxx>
#include <DDocStd_DrawDocument.hxx>
-#include <OSD_OpenFile.hxx>
+#include <OSD_FileSystem.hxx>
#include <Standard_ArrayStreamBuffer.hxx>
#include <TDataStd_Name.hxx>
#include <TDocStd_Application.hxx>
const TCollection_AsciiString aName (theArgVec[2]);
Handle(NCollection_Buffer) aBuffer;
{
- std::ifstream aFile;
- OSD_OpenStream (aFile, aFilePath.ToCString(), std::ios::binary | std::ios::in);
- if (!aFile.is_open())
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream (aFilePath, std::ios::binary | std::ios::in);
+ if (aFile.get() == NULL)
{
std::cout << "Error: input file '" << aFilePath << "' cannot be read\n";
return 1;
}
- aFile.seekg (0, std::ios_base::end);
- const int64_t aFileLength = int64_t (aFile.tellg());
+ aFile->seekg (0, std::ios_base::end);
+ const int64_t aFileLength = int64_t (aFile->tellg());
if (aFileLength > int64_t (std::numeric_limits<ptrdiff_t>::max())
|| aFileLength < 1)
{
std::cout << "Error: input file '" << aFilePath << "' is too large\n";
return 1;
}
- aFile.seekg (0, std::ios_base::beg);
+ aFile->seekg (0, std::ios_base::beg);
aBuffer = new NCollection_Buffer (NCollection_BaseAllocator::CommonBaseAllocator());
if (!aBuffer->Allocate (size_t(aFileLength)))
return 1;
}
- aFile.read ((char* )aBuffer->ChangeData(), aBuffer->Size());
- if (!aFile.good())
+ aFile->read ((char* )aBuffer->ChangeData(), aBuffer->Size());
+ if (!aFile->good())
{
std::cout << "Error: input file '" << aFilePath << "' reading failure\n";
return 1;
#include <Message_Messenger.hxx>
#include <Message_ProgressScope.hxx>
#include <OSD_CachedFileSystem.hxx>
-#include <OSD_OpenFile.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_ThreadPool.hxx>
#include <fstream>
Message_ProgressScope aPSentry (theProgress, "Reading glTF", 2);
aPSentry.Show();
- std::ifstream aFile;
- OSD_OpenStream (aFile, theFile.ToCString(), std::ios::in | std::ios::binary);
- if (!aFile.is_open()
- || !aFile.good())
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFile = aFileSystem->OpenIStream (theFile, std::ios::in | std::ios::binary);
+ if (aFile.get() == NULL || !aFile->good())
{
Message::SendFail (TCollection_AsciiString ("File '") + theFile + "' is not found");
return false;
bool isBinaryFile = false;
char aGlbHeader[12] = {};
- aFile.read (aGlbHeader, sizeof(aGlbHeader));
+ aFile->read (aGlbHeader, sizeof (aGlbHeader));
int64_t aBinBodyOffset = 0;
int64_t aBinBodyLen = 0;
int64_t aJsonBodyOffset = 0;
}
char aHeader1[8] = {};
- aFile.read (aHeader1, sizeof(aHeader1));
+ aFile->read (aHeader1, sizeof (aHeader1));
const uint32_t* aSceneLen = (const uint32_t* )(aHeader1 + 0);
const uint32_t* aSceneFormat = (const uint32_t* )(aHeader1 + 4);
Message::SendWarning (TCollection_AsciiString ("File '") + theFile + "' is written using unknown version " + int(*aVer));
}
- for (int aChunkIter = 0; !aFile.eof() && aChunkIter < 2; ++aChunkIter)
+ for (int aChunkIter = 0; !aFile->eof() && aChunkIter < 2; ++aChunkIter)
{
char aChunkHeader2[8] = {};
- if (int64_t(aFile.tellg()) + int64_t(sizeof(aChunkHeader2)) > int64_t(*aLen))
+ if (int64_t (aFile->tellg()) + int64_t (sizeof (aChunkHeader2)) > int64_t (*aLen))
{
break;
}
- aFile.read (aChunkHeader2, sizeof(aChunkHeader2));
- if (!aFile.good())
+ aFile->read (aChunkHeader2, sizeof (aChunkHeader2));
+ if (!aFile->good())
{
Message::SendFail (TCollection_AsciiString ("File '") + theFile + "' is written using unsupported format");
return false;
const uint32_t* aChunkType = (const uint32_t* )(aChunkHeader2 + 4);
if (*aChunkType == 0x4E4F534A)
{
- aJsonBodyOffset = int64_t(aFile.tellg());
- aJsonBodyLen = int64_t(*aChunkLen);
+ aJsonBodyOffset = int64_t (aFile->tellg());
+ aJsonBodyLen = int64_t (*aChunkLen);
}
else if (*aChunkType == 0x004E4942)
{
- aBinBodyOffset = int64_t(aFile.tellg());
- aBinBodyLen = int64_t(*aChunkLen);
+ aBinBodyOffset = int64_t (aFile->tellg());
+ aBinBodyLen = int64_t (*aChunkLen);
}
if (*aChunkLen != 0)
{
- aFile.seekg (*aChunkLen, std::ios_base::cur);
+ aFile->seekg (*aChunkLen, std::ios_base::cur);
}
}
- aFile.seekg ((std::streamoff )aJsonBodyOffset, std::ios_base::beg);
+ aFile->seekg ((std::streamoff )aJsonBodyOffset, std::ios_base::beg);
}
}
else
{
- aFile.seekg (0, std::ios_base::beg);
+ aFile->seekg (0, std::ios_base::beg);
}
TCollection_AsciiString anErrPrefix = TCollection_AsciiString ("File '") + theFile + "' defines invalid glTF!\n";
#ifdef HAVE_RAPIDJSON
rapidjson::ParseResult aRes;
- rapidjson::IStreamWrapper aFileStream (aFile);
+ rapidjson::IStreamWrapper aFileStream (*aFile);
if (isBinaryFile)
{
aRes = aDoc.ParseStream<rapidjson::kParseStopWhenDoneFlag, rapidjson::UTF8<>, rapidjson::IStreamWrapper> (aFileStream);
#include <Message_Messenger.hxx>
#include <Message_ProgressScope.hxx>
#include <NCollection_DataMap.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_File.hxx>
#include <OSD_Path.hxx>
if (aFullLen64 < std::numeric_limits<uint32_t>::max())
{
{
- std::ifstream aBinFile;
- OSD_OpenStream (aBinFile, myBinFileNameFull.ToCString(), std::ios::in | std::ios::binary);
- if (!aBinFile.is_open()
- || !aBinFile.good())
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aBinFile = aFileSystem->OpenIStream (myBinFileNameFull, std::ios::in | std::ios::binary);
+ if (aBinFile.get() == NULL || !aBinFile->good())
{
Message::SendFail (TCollection_AsciiString ("File '") + myBinFileNameFull + "' cannot be opened");
return false;
}
char aBuffer[4096];
- for (; aBinFile.good();)
+ for (; aBinFile->good();)
{
- aBinFile.read (aBuffer, 4096);
- const Standard_Integer aReadLen = (Standard_Integer )aBinFile.gcount();
+ aBinFile->read (aBuffer, 4096);
+ const Standard_Integer aReadLen = (Standard_Integer )aBinFile->gcount();
if (aReadLen == 0)
{
break;
#include <Message_ProgressScope.hxx>
#include <NCollection_Vector.hxx>
#include <OSD_File.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_OpenFile.hxx>
#include <RWStl_Reader.hxx>
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();
+ opencascade::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);
Reader aReader;
- if (!aReader.ReadBinary (aStream, theProgress))
+ if (!aReader.ReadBinary (*aStream, theProgress))
{
return Handle(Poly_Triangulation)();
}
#include <NCollection_DataMap.hxx>
#include <NCollection_IncAllocator.hxx>
#include <FSD_BinaryFile.hxx>
-#include <OSD_OpenFile.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_Timer.hxx>
#include <Precision.hxx>
#include <Standard_CLocaleSentry.hxx>
Standard_Boolean RWStl_Reader::Read (const char* theFile,
const Message_ProgressRange& theProgress)
{
- std::filebuf aBuf;
- OSD_OpenStream (aBuf, theFile, std::ios::in | std::ios::binary);
- if (!aBuf.is_open())
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aStream = aFileSystem->OpenIStream (theFile, std::ios::in | std::ios::binary);
+ if (aStream.get() == NULL)
{
Message::SendFail (TCollection_AsciiString("Error: file '") + theFile + "' is not found");
return Standard_False;
}
-
- Standard_IStream aStream (&aBuf);
-
// get length of file to feed progress indicator in Ascii mode
- 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);
// binary STL files cannot be shorter than 134 bytes
// (80 bytes header + 4 bytes facet count + 50 bytes for one facet);
// thus assume files shorter than 134 as Ascii without probing
// (probing may bring stream to fail state if EOF is reached)
- bool isAscii = ((size_t)theEnd < THE_STL_MIN_FILE_SIZE || IsAscii (aStream, true));
+ bool isAscii = ((size_t)theEnd < THE_STL_MIN_FILE_SIZE || IsAscii (*aStream, true));
Standard_ReadLineBuffer aBuffer (THE_BUFFER_SIZE);
// For this reason use infinite (logarithmic) progress scale,
// but in special mode so that the first cycle will take ~ 70% of it
Message_ProgressScope aPS (theProgress, NULL, 1, true);
- while (aStream.good())
+ while (aStream->good())
{
if (isAscii)
{
- if (!ReadAscii (aStream, aBuffer, theEnd, aPS.Next(2)))
+ if (!ReadAscii (*aStream, aBuffer, theEnd, aPS.Next (2)))
{
break;
}
}
else
{
- if (!ReadBinary (aStream, aPS.Next(2)))
+ if (!ReadBinary (*aStream, aPS.Next (2)))
{
break;
}
}
- aStream >> std::ws; // skip any white spaces
+ *aStream >> std::ws; // skip any white spaces
}
- return ! aStream.fail();
+ return ! aStream->fail();
}
//==============================================================================
#include <BinTObjDrivers.hxx>
#include <XmlTObjDrivers.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_OpenFile.hxx>
#include <stdio.h>
aModel = new TObjDRAW_Model();
if (anUseStream)
{
- std::ifstream aFileStream;
- OSD_OpenStream (aFileStream, aPath, std::ios::in | std::ios::binary);
- isLoaded = aModel->Load (aFileStream);
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFileStream = aFileSystem->OpenIStream (aPath, std::ios::in | std::ios::binary);
+ isLoaded = aModel->Load (*aFileStream);
}
else
isLoaded = aModel->Load (aPath);
#include <LDOM_DocumentType.hxx>
#include <LDOM_LDOMImplementation.hxx>
#include <LDOMParser.hxx>
+#include <OSD_FileSystem.hxx>
#include <OSD_Path.hxx>
-#include <OSD_OpenFile.hxx>
#include <PCDM_Document.hxx>
#include <PCDM_DOMHeaderParser.hxx>
#include <Standard_Type.hxx>
myReaderStatus = PCDM_RS_DriverFailure;
myFileName = theFileName;
- std::ifstream aFileStream;
- OSD_OpenStream (aFileStream, myFileName, std::ios::in);
+ const Handle(OSD_FileSystem)& aFileSystem = OSD_FileSystem::DefaultFileSystem();
+ opencascade::std::shared_ptr<std::istream> aFileStream = aFileSystem->OpenIStream (myFileName, std::ios::in);
- if (aFileStream.is_open() && aFileStream.good())
+ if (aFileStream.get() != NULL && aFileStream->good())
{
- Read (aFileStream, NULL, theNewDocument, theApplication, theFilter, theRange);
+ Read (*aFileStream, NULL, theNewDocument, theApplication, theFilter, theRange);
}
else
{