-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "HDFfile.hxx"
#include "HDFexception.hxx"
-herr_t file_attr(hid_t loc_id, const char *attr_name, void *operator_data)
+herr_t file_attr(hid_t /*loc_id*/, const char *attr_name, void *operator_data)
{
*(char**)operator_data = new char[strlen(attr_name)+1];
strcpy(*(char**)operator_data, attr_name);
void HDFfile::OpenOnDisk(hdf_access_mode access_mode)
{
- _access_mode = access_mode;
+ _access_mode = access_mode;
+ std::string msgerr;
- switch (_access_mode)
- {
- case HDF_RDWR :
- if (access(_name,F_OK))
+ switch (_access_mode)
{
- if ((_id = HDFfileCreate(_name)) < 0)
- throw HDFexception("Can't open HDF file");
+ case HDF_RDWR:
+ if (access(_name, F_OK))
+ {
+ if ((_id = HDFfileCreate(_name)) < 0) {
+ msgerr = "Can't create HDF in RW mode file" + std::string(_name);
+ throw HDFexception(msgerr.c_str());
+ }
+ }
+ else if ((_id = HDFfileOpen(_name, _access_mode)) < 0) {
+ msgerr = "Can't open HDF in RW mode file " + std::string(_name);
+ throw HDFexception(msgerr.c_str());
+ }
+ break;
+
+ case HDF_RDONLY:
+ if ((_id = HDFfileOpen(_name, _access_mode)) < 0) {
+ msgerr = "Can't open HDF in RO mode file " + std::string(_name);
+ throw HDFexception(msgerr.c_str());
+ }
+ break;
+
+ default:
+ msgerr = "Can't open HDF file " + std::string(_name) + " : bad access option";
+ throw HDFexception(msgerr.c_str());
}
- else
- if ((_id = HDFfileOpen(_name,_access_mode)) < 0)
- throw HDFexception("Can't open HDF file");
- break;
-
- case HDF_RDONLY :
- if ((_id = HDFfileOpen(_name,_access_mode)) < 0)
- throw HDFexception("Can't open HDF file");
- break;
-
- default :
- throw HDFexception("Can't open HDF file : bad acces option");
- }
}
void HDFfile::CloseOnDisk()