summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--release_docs/RELEASE.txt3
-rw-r--r--src/H5F.c52
-rw-r--r--src/H5Fpublic.h1
-rw-r--r--test/Makefile.in10
-rw-r--r--test/file_handle.c5
-rw-r--r--test/filename.c3
7 files changed, 70 insertions, 5 deletions
diff --git a/MANIFEST b/MANIFEST
index 0428c71..3bcc745 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -1027,6 +1027,7 @@
./test/extend.c
./test/external.c
./test/file_handle.c
+./test/filename.c
./test/fill_old.h5
./test/fillval.c
./test/flush1.c
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 7f1afcc..58d0e3f 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -41,6 +41,9 @@ New Features
Library:
--------
+ - A new API function H5Fget_name was added. It returns the name
+ of the file by object(file, group, data set, named data type,
+ attribute) ID. SLU - 2004/06/29
- A new API function H5Fget_filesize was added. It returns the
actual file size of the opened file. SLU - 2004/06/24
- Added option that if $HDF5_DISABLE_VERSION_CHECK is set to 2,
diff --git a/src/H5F.c b/src/H5F.c
index 111ceb4..e385d69 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -4706,3 +4706,55 @@ H5Fget_filesize(hid_t file_id)
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Fget_filesize() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Fget_name
+ *
+ * Purpose: Gets the name of the file to which object OBJ_ID belongs.
+ * If `name' is non-NULL then write up to `size' bytes into that
+ * buffer and always return the length of the entry name.
+ * Otherwise `size' is ignored and the function does not store the name,
+ * just returning the number of characters required to store the name.
+ * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL)
+ * is unchanged and the function returns a negative value.
+ *
+ * Return: Success: The length of the file name
+ * Failure: Negative
+ *
+ * Programmer: Raymond Lu
+ * June 29, 2004
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+ssize_t
+H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size)
+{
+ H5G_entry_t *ent; /*symbol table entry */
+ size_t len=0;
+ ssize_t ret_value;
+
+ FUNC_ENTER_API (H5Fget_name, FAIL);
+ H5TRACE3("Zs","ixz",obj_id,name,size);
+
+ /* get symbol table entry */
+ if((ent = H5G_loc(obj_id))==NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID")
+
+ len = HDstrlen(ent->file->name);
+
+ if(name) {
+ HDstrncpy(name, ent->file->name, MIN(len+1,size));
+ if(len >= size)
+ name[size-1]='\0';
+ } /* end if */
+
+ /* Set return value */
+ ret_value=(ssize_t)len;
+
+done:
+ FUNC_LEAVE_API(ret_value);
+} /* end H5Fget_name() */
+
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index 911bdff..c372130 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -114,6 +114,7 @@ H5_DLL herr_t H5Fmount(hid_t loc, const char *name, hid_t child, hid_t plist);
H5_DLL herr_t H5Funmount(hid_t loc, const char *name);
H5_DLL hssize_t H5Fget_freespace(hid_t file_id);
H5_DLL haddr_t H5Fget_filesize(hid_t file_id);
+H5_DLL ssize_t H5Fget_name(hid_t obj_id, char *name, size_t size);
#ifdef __cplusplus
}
diff --git a/test/Makefile.in b/test/Makefile.in
index ad916bf..358dd25 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -28,7 +28,7 @@ TEST_PROGS=testhdf5 lheap ohdr stab gheap hyperslab istore bittests dtypes
dsets cmpd_dset extend external links unlink big mtime fillval mount \
flush1 flush2 enum gass_write gass_read gass_append set_extent \
srb_write srb_append srb_read ttsafe stream_test getname file_handle \
- ntypes dangle
+ ntypes dangle filename
TIMINGS=testmeta
@@ -60,7 +60,8 @@ MOSTLYCLEAN=cmpd_dset.h5 compact_dataset.h5 dataset.h5 extend.h5 istore.h5 \
tmisc13b.h5 tmisc14.h5 set_extent_read.h5 set_extent_create.h5 \
getname.h5 getname1.h5 getname2.h5 getname3.h5 sec2_file.h5 \
family_file000[0-3][0-9].h5 multi_file-[rs].h5 core_file \
- new_move_[ab].h5 ntypes.h5 dangle.h5 test_filters.h5
+ new_move_[ab].h5 ntypes.h5 dangle.h5 test_filters.h5 \
+ get_file_name.h5
CLEAN=$(TIMINGS)
@@ -78,7 +79,7 @@ TEST_SRC=big.c bittests.c cmpd_dset.c dsets.c dtypes.c extend.c \
unlink.c enum.c ttsafe.c ttsafe_dcreate.c ttsafe_error.c \
ttsafe_cancel.c ttsafe_acreate.c gass_write.c gass_read.c \
gass_append.c srb_read.c srb_write.c srb_append.c stream_test.c \
- set_extent.c getname.c file_handle.c ntypes.c dangle.c
+ set_extent.c getname.c file_handle.c ntypes.c dangle.c filename.c
TEST_OBJ=$(TEST_SRC:.c=.lo)
@@ -219,4 +220,7 @@ ntypes: ntypes.lo
dangle: dangle.lo
@$(LT_LINK_EXE) $(CFLAGS) -o $@ dangle.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+filename: filename.lo
+ @$(LT_LINK_EXE) $(CFLAGS) -o $@ filename.lo $(LIB) $(LIBHDF5) $(LDFLAGS) $(LIBS)
+
@CONCLUDE@
diff --git a/test/file_handle.c b/test/file_handle.c
index 1616bb0..ec9362c 100644
--- a/test/file_handle.c
+++ b/test/file_handle.c
@@ -177,6 +177,11 @@ test_core(void)
* Just try to check if it's reasonable. Currently, this file size
* is 976.
*/
+
+
+
+
+
if(file_size<KB/2 || file_size>1*KB)
goto error;
diff --git a/test/filename.c b/test/filename.c
index 992ae0d..79dd19e 100644
--- a/test/filename.c
+++ b/test/filename.c
@@ -19,7 +19,6 @@
* Purpose: Tests the "H5Fget_name" functionality
*/
-#include "hdf5.h"
#include "h5test.h"
#include "testhdf5.h"
@@ -49,7 +48,7 @@ typedef struct s1_t {
if (strcmp(x, val)) { \
TestErrPrintf("*** UNEXPECTED VALUE from %s should be %s, but is %s at line %4d " \
"in %s\n", where, val, x, (int)__LINE__, __FILE__); \
- H5Eprint (H5E_DEFAULT, stdout); \
+ H5Eprint (stdout); \
} \
strcmp(x, ""); \
} while(0)