diff options
author | Quincey Koziol <koziol@koziol.gov> | 2019-04-14 03:58:16 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@koziol.gov> | 2019-04-14 03:58:16 (GMT) |
commit | d7e1464058515d07b838741f65a77977224814de (patch) | |
tree | c25d0985895862053d6b9d1eb1fce4fa94d471e3 /c++ | |
parent | 4918d443bb2f8406c3be9882a7945853c84760f6 (diff) | |
download | hdf5-d7e1464058515d07b838741f65a77977224814de.zip hdf5-d7e1464058515d07b838741f65a77977224814de.tar.gz hdf5-d7e1464058515d07b838741f65a77977224814de.tar.bz2 |
Add C++, Java, and FORTRAN wrappers and tests for H5Fget_fileno
Diffstat (limited to 'c++')
-rw-r--r-- | c++/src/C2Cppfunction_map.htm | 36 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 21 | ||||
-rw-r--r-- | c++/src/H5File.h | 3 | ||||
-rw-r--r-- | c++/test/tfile.cpp | 59 |
4 files changed, 119 insertions, 0 deletions
diff --git a/c++/src/C2Cppfunction_map.htm b/c++/src/C2Cppfunction_map.htm index b53ea15..2d779a3 100644 --- a/c++/src/C2Cppfunction_map.htm +++ b/c++/src/C2Cppfunction_map.htm @@ -7666,6 +7666,42 @@ normal'><span style='font-size:14.0pt;mso-bidi-font-size:11.0pt;line-height: normal'><o:p> </o:p></p> </td> </tr> + <tr style='mso-yfti-irow:180'> + <td width=263 style='width:197.2pt;border:solid windowtext 1.0pt;border-top: + none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; + padding:0in 5.4pt 0in 5.4pt'> + <p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height: + normal'>H5Fget_fileno</p> + </td> + <td width=474 valign=top style='width:355.2pt;border-top:none;border-left: + none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; + mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; + mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> + <p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height: + normal'>unsigned long H5File::getFileNum()</p> + </td> + <td width=35 valign=top style='width:26.05pt;border-top:none;border-left: + none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; + mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; + mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> + <p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt; + text-align:center;line-height:normal'><o:p> </o:p></p> + </td> + <td width=42 valign=top style='width:31.45pt;border-top:none;border-left: + none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; + mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; + mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> + <p class=MsoNormal align=center style='margin-bottom:0in;margin-bottom:.0001pt; + text-align:center;line-height:normal'><o:p> </o:p></p> + </td> + <td width=169 valign=top style='width:126.65pt;border-top:none;border-left: + none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt; + mso-border-top-alt:solid windowtext .5pt;mso-border-left-alt:solid windowtext .5pt; + mso-border-alt:solid windowtext .5pt;padding:0in 5.4pt 0in 5.4pt'> + <p class=MsoNormal style='margin-bottom:0in;margin-bottom:.0001pt;line-height: + normal'><o:p> </o:p></p> + </td> + </tr> <tr style='mso-yfti-irow:181'> <td width=263 style='width:197.2pt;border:solid windowtext 1.0pt;border-top: none;mso-border-top-alt:solid windowtext .5pt;mso-border-alt:solid windowtext .5pt; diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 719c1ba..b9ecded 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -580,6 +580,27 @@ hsize_t H5File::getFileSize() const } //-------------------------------------------------------------------------- +// Function: H5File::getFileNum +///\brief Returns the file number of the HDF5 file. +///\return File number +///\exception H5::FileIException +///\par Description +/// This function is called after an existing file is opened in +/// order to retrieve the unique 'file number' for the file. +// Programmer Quincey Koziol - April 13, 2019 +//-------------------------------------------------------------------------- +unsigned long H5File::getFileNum() const +{ + unsigned long fileno = 0; + herr_t ret_value = H5Fget_fileno(id, &fileno); + if (ret_value < 0) + { + throw FileIException("H5File::getFileNum", "H5Fget_fileno failed"); + } + return (fileno); +} + +//-------------------------------------------------------------------------- // Function: H5File::getId ///\brief Get the id of this file ///\return File identifier diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 332685e..1b1227f 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -69,6 +69,9 @@ class H5_DLLCPP H5File : public Group { // Returns the file size of the HDF5 file. hsize_t getFileSize() const; + // Returns the 'file number' of the HDF5 file. + unsigned long getFileNum() const; + // Determines if a file, specified by its name, is in HDF5 format static bool isHdf5(const char* name); static bool isHdf5(const H5std_string& name); diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index a2bf1c2..055cf23 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -412,6 +412,64 @@ static void test_file_size() /*------------------------------------------------------------------------- + * Function: test_file_num + * + * Purpose Test file number. + * + * Return None + * + * Programmer Quincey Koziol + * April, 2019 + *------------------------------------------------------------------------- + */ +static void test_file_num() +{ + // Output message about test being performed + SUBTEST("File Number"); + + hid_t fapl_id; + fapl_id = h5_fileaccess(); // in h5test.c, returns a file access template + + try { + // Use the file access template id to create a file access prop. + // list object to pass in H5File::H5File + FileAccPropList fapl(fapl_id); + + // Create two files + H5File file1(FILE1, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + H5File file2(FILE2, H5F_ACC_TRUNC, FileCreatPropList::DEFAULT, fapl); + + // Open the first file again + H5File file3(FILE1, H5F_ACC_RDWR); + + // Get file numbers + unsigned long file_num1 = file1.getFileNum(); + unsigned long file_num2 = file2.getFileNum(); + unsigned long file_num3 = file3.getFileNum(); + + // Check file numbers + if (file_num1 == file_num2) + issue_fail_msg("test_file_num()", __LINE__, __FILE__, "getFileNum() returned wrong value"); + if (file_num1 != file_num3) + issue_fail_msg("test_file_num()", __LINE__, __FILE__, "getFileNum() returned wrong value"); + + PASSED(); + } // end of try block + + catch (Exception& E) + { + issue_fail_msg("test_file_num()", __LINE__, __FILE__, E.getCDetailMsg()); + } + + // use C test utility routine to close property list. + herr_t ret = H5Pclose(fapl_id); + if (ret < 0) + issue_fail_msg("test_file_num()", __LINE__, __FILE__, "H5Pclose failed"); + +} // test_file_num() + + +/*------------------------------------------------------------------------- * Function: test_file_name * * Purpose Test getting file's name. @@ -966,6 +1024,7 @@ void test_file() test_file_create(); // Test file creation (also creation templates) test_file_open(); // Test file opening test_file_size(); // Test file size + test_file_num(); // Test file number test_file_name(); // Test getting file's name test_file_attribute(); // Test file attribute feature test_libver_bounds(); // Test format version |