mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0032455: Data Exchange - replace OSD_OpenStream() usage with OSD_FileSystem::DefaultFileSystem()
- replaced OSD_OpenStream() usage with OSD_FileSystem::DefaultFileSystem()
This commit is contained in:
@@ -389,7 +389,7 @@ static Standard_Integer OCC361bug (Draw_Interpretor& di, Standard_Integer nb, co
|
||||
|
||||
#include <Graphic3d_Texture2Dmanual.hxx>
|
||||
#include <Image_AlienPixMap.hxx>
|
||||
#include <OSD_OpenFile.hxx>
|
||||
#include <OSD_FileSystem.hxx>
|
||||
#include <Prs3d_ShadingAspect.hxx>
|
||||
#include <Standard_ArrayStreamBuffer.hxx>
|
||||
//=======================================================================
|
||||
@@ -459,35 +459,34 @@ static Standard_Integer OCC30182 (Draw_Interpretor& , Standard_Integer theNbArgs
|
||||
}
|
||||
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;
|
||||
@@ -495,7 +494,7 @@ static Standard_Integer OCC30182 (Draw_Interpretor& , Standard_Integer theNbArgs
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!anImage->Load (aFile, anImgPath))
|
||||
if (!anImage->Load (*aFile, anImgPath))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@@ -2269,7 +2269,7 @@ static Standard_Integer OCC28829 (Draw_Interpretor&, Standard_Integer, const cha
|
||||
|
||||
#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>
|
||||
@@ -2290,22 +2290,22 @@ static Standard_Integer OCC28887 (Draw_Interpretor&, Standard_Integer theNbArgs,
|
||||
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)))
|
||||
@@ -2314,8 +2314,8 @@ static Standard_Integer OCC28887 (Draw_Interpretor&, Standard_Integer theNbArgs,
|
||||
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;
|
||||
|
Reference in New Issue
Block a user