From fe47ccb0a7b7b1ef034af3b7cfefe1d502af44a7 Mon Sep 17 00:00:00 2001 From: jfa Date: Thu, 8 Feb 2007 11:42:07 +0000 Subject: [PATCH] NPAL14828: Impossible to load a study created in batch mode. Improve getting a directory path in LoadWith method. --- .../SALOMEDSImpl_StudyBuilder.cxx | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index 05d9dec5e..09c214714 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -33,13 +33,16 @@ using namespace std; #include "SALOMEDSImpl_SComponent.hxx" #include "SALOMEDSImpl_Tool.hxx" +#include + #include #include #include #include -#include #include +#include + #include #include @@ -294,6 +297,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(false); TCollection_ExtendedString Res(Att->Value()); + TCollection_AsciiString aHDFPath(Res); Handle(SALOMEDSImpl_AttributeComment) type; TCollection_ExtendedString DataType; @@ -315,8 +319,6 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& DefineComponentInstance (anSCO, aDriver->GetIOR()); - TCollection_AsciiString aHDFPath(Res); - TCollection_AsciiString aHDFUrl; bool isASCII = false; if (HDFascii::isASCII(aHDFPath.ToCString())) { @@ -364,18 +366,20 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& ascii_hdf_dataset->ReadFromDisk(ASCIIfileState); // set path without file name from URL - int aFileNameSize = Res.Length(); - char* aDir = new char[aFileNameSize]; - memcpy(aDir, TCollection_AsciiString(Res).ToCString(), aFileNameSize); - for(int aCounter = aFileNameSize-1; aCounter>=0; aCounter--) - if (aDir[aCounter] == '/') { - aDir[aCounter+1] = 0; - break; - } + //int aFileNameSize = Res.Length(); + //char* aDir = new char[aFileNameSize]; + //memcpy(aDir, TCollection_AsciiString(Res).ToCString(), aFileNameSize); + //for(int aCounter = aFileNameSize-1; aCounter>=0; aCounter--) + //if (aDir[aCounter] == '/') { + // aDir[aCounter+1] = 0; + // break; + //} + // Above code was working wrong for paths without '/' inside. + TCollection_AsciiString aDir = SALOMEDSImpl_Tool::GetDirFromPath(Res); bool aResult = (ASCIIfileState[0]=='A')? - aDriver->LoadASCII(anSCO, aStreamFile, aStreamSize, aDir, aMultifileState[0]=='M'): - aDriver->Load(anSCO, aStreamFile, aStreamSize, aDir, aMultifileState[0]=='M'); + aDriver->LoadASCII(anSCO, aStreamFile, aStreamSize, aDir.ToCString(), aMultifileState[0]=='M'): + aDriver->Load(anSCO, aStreamFile, aStreamSize, aDir.ToCString(), aMultifileState[0]=='M'); if(aStreamFile != NULL) delete []aStreamFile; @@ -386,7 +390,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& throw HDFexception("Unable to load component"); } - if(aDir != NULL) delete []aDir; + //if(aDir != NULL) delete []aDir; multifile_hdf_dataset->CloseOnDisk(); multifile_hdf_dataset = 0; -- 2.39.2