diff options
Diffstat (limited to 'c++/src')
-rw-r--r-- | c++/src/H5File.cpp | 47 | ||||
-rw-r--r-- | c++/src/H5File.h | 2 |
2 files changed, 49 insertions, 0 deletions
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 92a8d59..6e85015 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -119,6 +119,53 @@ H5File::H5File(const H5std_string &name, unsigned int flags, const FileCreatProp } } +//-------------------------------------------------------------------------- +// Function: H5File overloaded constructor +///\brief Opens an HDF5 file using a non-default access property list +///\param name - IN: Name of the file +///\param flags - IN: File access flags +///\param access_plist - IN: File access property list. Default to +/// FileAccPropList::DEFAULT +///\par Description +/// Valid values of \a flags include: +/// \li \c H5F_ACC_RDONLY - Open file as read-only, if it already +/// exists, and fail, otherwise +/// \li \c H5F_ACC_RDWR - Open file for read/write, if it already +/// exists, and fail, otherwise +// Notes With a PGI compiler (~2012-2013,) the exception thrown by +// p_get_file could not be caught in the applications. Added try +// block here to catch then re-throw it. -BMR 2013/03/21 +//-------------------------------------------------------------------------- +H5File::H5File(const char *name, unsigned int flags, const FileAccPropList &access_plist) + : Group(), id(H5I_INVALID_HID) +{ + try { + p_get_file(name, flags, FileCreatPropList::DEFAULT, access_plist); + } + catch (FileIException &open_file) { + throw open_file; + } +} + +//-------------------------------------------------------------------------- +// Function: H5File overloaded constructor +///\brief This is another overloaded constructor. It differs from the +/// above constructor only in the type of the \a name argument. +///\param name - IN: Name of the file - \c H5std_string +///\param flags - IN: File access flags +///\param access_plist - IN: File access property list +//-------------------------------------------------------------------------- +H5File::H5File(const H5std_string &name, unsigned int flags, const FileAccPropList &access_plist) + : Group(), id(H5I_INVALID_HID) +{ + try { + p_get_file(name.c_str(), flags, FileCreatPropList::DEFAULT, access_plist); + } + catch (FileIException &open_file) { + throw open_file; + } +} + #ifndef DOXYGEN_SHOULD_SKIP_THIS //-------------------------------------------------------------------------- // This function is private and contains common code between the diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 67c033c..38faeef 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -31,6 +31,8 @@ class H5_DLLCPP H5File : public Group { H5File(const H5std_string &name, unsigned int flags, const FileCreatPropList &create_plist = FileCreatPropList::DEFAULT, const FileAccPropList &access_plist = FileAccPropList::DEFAULT); + H5File(const char *name, unsigned int flags, const FileAccPropList &access_plist); + H5File(const H5std_string &name, unsigned int flags, const FileAccPropList &access_plist); // Open the file void openFile(const H5std_string &name, unsigned int flags, |