summaryrefslogtreecommitdiffstats
path: root/c++/src/H5File.cpp
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2018-10-10 15:10:15 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2018-10-10 15:10:15 (GMT)
commite962df1591bc6eaee5b9e318de83b9c6698bc7b6 (patch)
treede3cb2001c62b76a89837ff1e90044574d71f19d /c++/src/H5File.cpp
parent471150151d29eeb806333a8db41fefc9dfb452bb (diff)
downloadhdf5-e962df1591bc6eaee5b9e318de83b9c6698bc7b6.zip
hdf5-e962df1591bc6eaee5b9e318de83b9c6698bc7b6.tar.gz
hdf5-e962df1591bc6eaee5b9e318de83b9c6698bc7b6.tar.bz2
VOL FEATURE
Diffstat (limited to 'c++/src/H5File.cpp')
-rw-r--r--c++/src/H5File.cpp49
1 files changed, 45 insertions, 4 deletions
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index 07d7e84..719c1ba 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -192,16 +192,17 @@ H5File::H5File(const H5File& original) : Group()
//--------------------------------------------------------------------------
bool H5File::isHdf5(const char* name)
{
- // Calls C routine H5Fis_hdf5 to determine whether the file is in
+ // Calls C routine H5Fis_accessible to determine whether the file is in
// HDF5 format. It returns positive value, 0, or negative value
- htri_t ret_value = H5Fis_hdf5(name);
+ htri_t ret_value = H5Fis_accessible(name, H5P_DEFAULT);
+
if (ret_value > 0)
return true;
else if (ret_value == 0)
return false;
- else // Raise exception when H5Fis_hdf5 returns a negative value
+ else // Raise exception when H5Fis_accessible returns a negative value
{
- throw FileIException("H5File::isHdf5", "H5Fis_hdf5 returned negative value");
+ throw FileIException("H5File::isHdf5", "H5Fis_accessible returned negative value");
}
}
@@ -218,6 +219,46 @@ bool H5File::isHdf5(const H5std_string& name)
}
//--------------------------------------------------------------------------
+// Function: H5File::isAccessible (static)
+///\brief Determines whether a file can be accessed as HDF5. (Static)
+///\param name - IN: Name of the file
+///\param access_plist - IN: File access property list. Default to
+/// FileAccPropList::DEFAULT
+///\return true if the file can be accessed as HDF5, and false, otherwise
+///\exception H5::FileIException
+// September 2018
+//--------------------------------------------------------------------------
+bool H5File::isAccessible(const char* name, const FileAccPropList& access_plist)
+{
+ // Calls C routine H5Fis_accessible to determine whether the file is in
+ // HDF5 format. It returns positive value, 0, or negative value
+ hid_t access_plist_id = access_plist.getId();
+ htri_t ret_value = H5Fis_accessible(name, access_plist_id);
+ if (ret_value > 0)
+ return true;
+ else if (ret_value == 0)
+ return false;
+ else // Raise exception when H5Fis_accessible returns a negative value
+ {
+ throw FileIException("H5File::isAccessible", "H5Fis_accessible returned negative value");
+ }
+}
+
+//--------------------------------------------------------------------------
+// Function: H5File::isAccessible (static)
+///\brief This is an overloaded member function, provided for convenience.
+/// It takes an \c H5std_string for \a name. (Static)
+///\param name - IN: Name of the file - \c H5std_string
+///\param access_plist - IN: File access property list. Default to
+/// FileAccPropList::DEFAULT
+// September 2018
+//--------------------------------------------------------------------------
+bool H5File::isAccessible(const H5std_string& name, const FileAccPropList& access_plist)
+{
+ return(isAccessible(name.c_str(), access_plist));
+}
+
+//--------------------------------------------------------------------------
// Function: openFile
///\brief Opens an HDF5 file
///\param name - IN: Name of the file