* Purpose :
*/
//============================================================================
-bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& anSCO, SALOMEDSImpl_Driver* aDriver)
+bool SALOMEDSImpl_StudyBuilder::LoadWith(const Handle(SALOMEDSImpl_SComponent)& anSCO,
+ SALOMEDSImpl_Driver* aDriver)
{
_errorCode = "";
if (_doc->Main().FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID(),Att)) {
int aLocked = anSCO->GetStudy()->GetProperties()->IsLocked();
if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(false);
-
+
TCollection_ExtendedString Res(Att->Value());
Handle(SALOMEDSImpl_AttributeComment) type;
}
DefineComponentInstance (anSCO, aDriver->GetIOR());
-
+
TCollection_AsciiString aHDFPath(Res);
-
- char* aHDFUrl;
+
+ TCollection_AsciiString aHDFUrl;
bool isASCII = false;
if (HDFascii::isASCII(aHDFPath.ToCString())) {
isASCII = true;
- char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aHDFPath.ToCString());
- aHDFUrl = new char[strlen(aResultPath) + 19];
- sprintf(aHDFUrl, "%shdf_from_ascii.hdf", aResultPath);
- delete(aResultPath);
+ aHDFUrl = HDFascii::ConvertFromASCIIToHDF(aHDFPath.ToCString());
+ aHDFUrl += "hdf_from_ascii.hdf";
} else {
- aHDFUrl = aHDFPath.ToCString();
+ aHDFUrl = aHDFPath;
}
//Open the Study HDF file
- HDFfile *hdf_file = new HDFfile(aHDFUrl);
-
+ HDFfile *hdf_file = new HDFfile(aHDFUrl.ToCString());
+
char aMultifileState[2];
char ASCIIfileState[2];
try {
hdf_group->OpenOnDisk();
HDFgroup *hdf_sco_group = new HDFgroup(scoid.ToCString(), hdf_group);
hdf_sco_group->OpenOnDisk();
-
+
unsigned char* aStreamFile = NULL;
int aStreamSize = 0;
hdf_dataset->ReadFromDisk(aStreamFile);
hdf_dataset->CloseOnDisk();
hdf_dataset = 0;
- } else aStreamFile = NULL;
-
+ } else
+ aStreamFile = NULL;
+
HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
multifile_hdf_dataset->OpenOnDisk();
multifile_hdf_dataset->ReadFromDisk(aMultifileState);
-
+
HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group);
ascii_hdf_dataset->OpenOnDisk();
ascii_hdf_dataset->ReadFromDisk(ASCIIfileState);
-
+
// set path without file name from URL
int aFileNameSize = Res.Length();
char* aDir = new char[aFileNameSize];
aDir[aCounter+1] = 0;
break;
}
-
+
bool aResult = (ASCIIfileState[0]=='A')?
aDriver->LoadASCII(anSCO, aStreamFile, aStreamSize, aDir, aMultifileState[0]=='M'):
aDriver->Load(anSCO, aStreamFile, aStreamSize, aDir, aMultifileState[0]=='M');
_errorCode = "Can't load component";
throw HDFexception("Unable to load component");
}
-
+
if(aDir != NULL) delete []aDir;
multifile_hdf_dataset->CloseOnDisk();
multifile_hdf_dataset = 0;
ascii_hdf_dataset->CloseOnDisk();
ascii_hdf_dataset = 0;
-
+
hdf_sco_group->CloseOnDisk();
hdf_sco_group = 0;
hdf_group->CloseOnDisk();
if (isASCII) {
Handle(TColStd_HSequenceOfAsciiString) aFilesToRemove = new TColStd_HSequenceOfAsciiString;
aFilesToRemove->Append(aHDFUrl);
- SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
+ SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl),
+ aFilesToRemove, true);
}
-
- delete aHDFUrl;
}
catch (HDFexception) {
delete hdf_file;
aFilesToRemove->Append(aHDFUrl);
SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
}
- delete aHDFUrl;
if (aLocked) anSCO->GetStudy()->GetProperties()->SetLocked(true);
_errorCode = "No persistent file";