summaryrefslogtreecommitdiffstats
path: root/hl
diff options
context:
space:
mode:
authorScot Breitenfeld <brtnfld@hdfgroup.org>2012-03-16 00:53:56 (GMT)
committerScot Breitenfeld <brtnfld@hdfgroup.org>2012-03-16 00:53:56 (GMT)
commit29e7e2890bf51bce3120090f740ce1f336c0d6c4 (patch)
treee01d91aa98559f61a99a0c5a1c777bd495e2a18b /hl
parentf261344af96dc2d41cce61d888cfa3efd8a1c36c (diff)
downloadhdf5-29e7e2890bf51bce3120090f740ce1f336c0d6c4.zip
hdf5-29e7e2890bf51bce3120090f740ce1f336c0d6c4.tar.gz
hdf5-29e7e2890bf51bce3120090f740ce1f336c0d6c4.tar.bz2
[svn-r22078] New API: H5ltpath_valid
REF: HDFFV-1233 A high-level "H5LTpath_valid" routine for checking if a path is correct Both Fortran and C version. Tested: jam (gnu and intel)
Diffstat (limited to 'hl')
-rwxr-xr-xhl/fortran/src/H5LTf90proto.h8
-rwxr-xr-xhl/fortran/src/H5LTfc.c51
-rwxr-xr-xhl/fortran/src/H5LTff.f9067
-rw-r--r--hl/fortran/test/tstlite.f9087
-rw-r--r--hl/src/H5LT.c108
-rw-r--r--hl/src/H5LTpublic.h3
-rw-r--r--hl/test/test_lite.c316
7 files changed, 634 insertions, 6 deletions
diff --git a/hl/fortran/src/H5LTf90proto.h b/hl/fortran/src/H5LTf90proto.h
index 5525af9..3d2ae3b 100755
--- a/hl/fortran/src/H5LTf90proto.h
+++ b/hl/fortran/src/H5LTf90proto.h
@@ -149,6 +149,7 @@ H5_FCDLL void HD5packFstring (char *src, char *dest, size_t len);
#define nh5ltget_attribute_ndims_c H5_FC_FUNC_(h5ltget_attribute_ndims_c, H5LTGET_ATTRIBUTE_NDIMS_C)
#define nh5ltget_attribute_info_c H5_FC_FUNC_(h5ltget_attribute_info_c, H5LTGET_ATTRIBUTE_INFO_C)
+#define nh5ltpath_valid_c H5_FC_FUNC_(h5ltpath_valid_c, H5LTPATH_VALID_C)
/*-------------------------------------------------------------------------
* Image
@@ -1197,6 +1198,13 @@ nh5ltread_dataset_string_c (hid_t_f *loc_id,
_fcd name,
char *buf);
+HDF5_HL_F90CSTUBDLL
+int_f
+nh5ltpath_valid_c(hid_t_f *loc_id,
+ _fcd path,
+ int_f *pathlen,
+ int_f *check_object_valid_c);
+
/*-------------------------------------------------------------------------
* Image
*-------------------------------------------------------------------------
diff --git a/hl/fortran/src/H5LTfc.c b/hl/fortran/src/H5LTfc.c
index 484acf1..c0b7695 100755
--- a/hl/fortran/src/H5LTfc.c
+++ b/hl/fortran/src/H5LTfc.c
@@ -2124,3 +2124,54 @@ done:
return ret_value;
}
+
+/*-------------------------------------------------------------------------
+* Function: h5ltpath_valid_c
+*
+* Purpose: Calls h5ltpath_valid
+*
+* Return: Success: 0, Failure: -1
+*
+* Programmer: M. Scot Breitenfeld
+*
+* Date: February 18, 2012
+*
+* Comments:
+*
+* Modifications:
+*
+*
+*-------------------------------------------------------------------------
+*/
+
+int_f
+nh5ltpath_valid_c(hid_t_f *loc_id,
+ _fcd path,
+ int_f *pathlen,
+ int_f *check_object_valid_c)
+{
+ htri_t ret = -1;
+ char *c_path = NULL;
+ hbool_t check_object_valid;
+
+ /*
+ * convert FORTRAN name to C name
+ */
+ if( NULL == (c_path = (char *)HD5f2cstring(path, (int)*pathlen)))
+ goto done;
+
+ check_object_valid = FALSE;
+ if(*check_object_valid_c == 1)
+ check_object_valid = TRUE;
+
+ /*
+ * call H5LTpath_valid function.
+ */
+ ret = H5LTpath_valid( (hid_t)*loc_id, c_path, check_object_valid );
+
+done:
+ if(c_path != NULL)
+ free(c_path);
+
+ return (int_f)ret;
+}
diff --git a/hl/fortran/src/H5LTff.f90 b/hl/fortran/src/H5LTff.f90
index cbc9b96..7d53ab7 100755
--- a/hl/fortran/src/H5LTff.f90
+++ b/hl/fortran/src/H5LTff.f90
@@ -6308,6 +6308,73 @@ CONTAINS
errcode = h5ltget_attribute_info_c(loc_id,namelen,dset_name,attrlen,attr_name,dims,type_class,type_size)
END SUBROUTINE h5ltget_attribute_info_f
+
+ !-------------------------------------------------------------------------
+ ! Function: h5ltpath_valid_f
+ !
+ ! Purpose: Validates a path
+ !
+ ! Return: Success: 0, Failure: -1
+ !
+ ! Programmer: M. Scot Breitenfeld
+ !
+ ! Date: February 18, 2012
+ !
+ ! Comments:
+ !
+ ! Modifications:
+ !
+ !-------------------------------------------------------------------------
+
+ SUBROUTINE h5ltpath_valid_f(loc_id, path, check_object_valid, path_valid, errcode)
+
+ IMPLICIT NONE
+ !
+ !This definition is needed for Windows DLLs
+ !DEC$if defined(BUILD_HDF5_DLL)
+ !DEC$attributes dllexport :: h5ltpath_valid_f
+ !DEC$endif
+ !
+ INTEGER(hid_t) , INTENT(IN) :: loc_id ! File or group identifier.
+ CHARACTER(LEN=*), INTENT(IN) :: path ! Path to the object to check, relative to loc_id.
+ LOGICAL , INTENT(IN) :: check_object_valid ! Indicates whether to check if the final component
+ ! of the path resolves to a valid object
+ LOGICAL , INTENT(OUT) :: path_valid ! Object status
+ INTEGER , INTENT(OUT) :: errcode ! Error code: 0 on success and -1 on failure
+
+ INTEGER :: pathlen
+ INTEGER :: check_object_valid_c
+ INTEGER :: status
+
+ INTERFACE
+ INTEGER FUNCTION h5ltpath_valid_c(loc_id, path, pathlen, check_object_valid_c)
+ USE h5global
+ !DEC$IF DEFINED(HDF5F90_WINDOWS)
+ !DEC$ATTRIBUTES C,reference,decorate,alias:'H5LTPATH_VALID_C'::h5ltpath_valid_c
+ !DEC$ENDIF
+ !DEC$ATTRIBUTES reference :: path
+ INTEGER(hid_t), INTENT(in) :: loc_id
+ CHARACTER(len=*), INTENT(in) :: path
+ INTEGER :: pathlen
+ INTEGER :: check_object_valid_c
+ END FUNCTION h5ltpath_valid_c
+ END INTERFACE
+
+ check_object_valid_c = 0
+ IF(check_object_valid) check_object_valid_c = 1
+
+ pathlen = LEN(path)
+ status = h5ltpath_valid_c(loc_id, path, pathlen, check_object_valid_c)
+
+ path_valid = .FALSE.
+ errcode = 0
+ IF(status.EQ.1)THEN
+ path_valid = .TRUE.
+ ELSE IF(status.LT.0)THEN
+ errcode = -1
+ ENDIF
+
+ END SUBROUTINE h5ltpath_valid_f
! end
!
END MODULE H5LT
diff --git a/hl/fortran/test/tstlite.f90 b/hl/fortran/test/tstlite.f90
index b0e28f9..9329dba 100644
--- a/hl/fortran/test/tstlite.f90
+++ b/hl/fortran/test/tstlite.f90
@@ -1067,6 +1067,9 @@ SUBROUTINE test_datasets()
INTEGER :: has ! general purpose integer
INTEGER :: type_class
INTEGER(SIZE_T) :: type_size
+ LOGICAL :: path_valid ! status of the path
+ CHARACTER(LEN=6) :: chr_exact
+ CHARACTER(LEN=8) :: chr_lg
!
! Initialize FORTRAN predefined datatypes.
@@ -1118,6 +1121,7 @@ SUBROUTINE test_datasets()
CALL passed()
+
!-------------------------------------------------------------------------
! real
!-------------------------------------------------------------------------
@@ -1207,9 +1211,60 @@ SUBROUTINE test_datasets()
CALL passed()
+ CALL test_begin(' Test h5ltpath_valid_f ')
+ !
+ ! test function h5ltpath_valid_f
+ !
+ chr_exact = "/"//dsetname2 ! test character buffer the exact size needed
+ CALL h5ltpath_valid_f(file_id, chr_exact, .TRUE., path_valid, errcode)
+ IF(errcode.LT.0.OR..NOT.path_valid)THEN
+ PRINT *, 'error in h5ltpath_valid_f'
+ STOP
+ ENDIF
+ chr_lg = "/"//dsetname2 ! test character buffer larger then needed
+ CALL h5ltpath_valid_f(file_id, chr_lg, .TRUE., path_valid, errcode)
+ IF(errcode.LT.0.OR..NOT.path_valid)THEN
+ PRINT *, 'error in h5ltpath_valid_f'
+ STOP
+ ENDIF
+ CALL h5ltpath_valid_f(file_id, chr_lg, .FALSE., path_valid, errcode)
+ IF(errcode.LT.0.OR..NOT.path_valid)THEN
+ PRINT *, 'error in h5ltpath_valid_f'
+ STOP
+ ENDIF
+ ! Should fail, dataset does not exist
+ CALL h5ltpath_valid_f(file_id, "/"//dsetname2//"junk", .TRUE., path_valid, errcode)
+ IF(errcode.LT.0.OR.path_valid)THEN
+ PRINT *, 'error in h5ltpath_valid_f'
+ STOP
+ ENDIF
+
+ CALL h5ltpath_valid_f(file_id, "/"//dsetname2//"junk", .FALSE., path_valid, errcode)
+ IF(errcode.LT.0.OR.path_valid)THEN
+ PRINT *, 'error in h5ltpath_valid_f'
+ STOP
+ ENDIF
+
+ ! Create a dangling soft link
+ CALL h5lcreate_soft_f("/G2", file_id, "/G3", errcode)
+
+ ! Should pass, does not check for dangled link
+ CALL h5ltpath_valid_f(file_id, "/G3", .FALSE., path_valid, errcode)
+ IF(.NOT.path_valid)THEN
+ PRINT *, 'error in h5ltpath_valid_f'
+ STOP
+ ENDIF
+
+ ! Should fail, dangled link
+ CALL h5ltpath_valid_f(file_id, "/G2", .TRUE., path_valid, errcode)
+ IF(path_valid)THEN
+ PRINT *, 'error in h5ltpath_valid_f'
+ STOP
+ ENDIF
+ CALL passed()
CALL test_begin(' Get dataset dimensions/info ')
@@ -1296,6 +1351,8 @@ SUBROUTINE test_attributes()
CHARACTER(LEN=5), PARAMETER :: attrname5 = "attr5" ! Attribute name
CHARACTER(LEN=8), PARAMETER :: buf1 = "mystring" ! Data buffer
CHARACTER(LEN=8) :: bufr1 ! Data buffer
+ CHARACTER(LEN=10) :: bufr1_lg ! Data buffer
+ CHARACTER(LEN=6) :: bufr1_sm ! Data buffer
INTEGER, DIMENSION(DIM1) :: buf2 ! Data buffer
INTEGER, DIMENSION(DIM1) :: bufr2 ! Data buffer
REAL, DIMENSION(DIM1) :: buf3 ! Data buffer
@@ -1446,20 +1503,46 @@ SUBROUTINE test_attributes()
CALL h5ltset_attribute_string_f(file_id,dsetname1,attrname5,buf1,errcode)
!
- ! read attribute.
+ ! read attribute into a fortran character buf that is the same size as buf1.
!
CALL h5ltget_attribute_string_f(file_id,dsetname1,attrname5,bufr1,errcode)
!
! compare read and write buffers.
!
-
IF ( buf1 .NE. bufr1 ) THEN
PRINT *, 'read buffer differs from write buffer'
PRINT *, buf1, ' and ', bufr1
STOP
ENDIF
+ !
+ ! read attribute into a fortran character buf that is larger then buf1.
+ !
+ CALL h5ltget_attribute_string_f(file_id,dsetname1,attrname5,bufr1_lg,errcode)
+
+ !
+ ! compare read and write buffers, make sure C NULL character was removed.
+ !
+ IF ( buf1(1:8) .NE. bufr1_lg(1:8) .AND. bufr1_lg(9:10) .NE. ' ' ) THEN
+ PRINT *, 'larger read buffer differs from write buffer'
+ PRINT *, buf1, ' and ', bufr1_lg
+ STOP
+ ENDIF
+
+ !
+ ! read attribute into a fortran character buf that is smaller then buf1.
+ !
+ CALL h5ltget_attribute_string_f(file_id,dsetname1,attrname5,bufr1_sm,errcode)
+
+ !
+ ! compare read and write buffers.
+ !
+ IF ( buf1(1:6) .NE. bufr1_sm(1:6) ) THEN
+ PRINT *, 'smaller read buffer differs from write buffer'
+ PRINT *, buf1, ' and ', bufr1_sm
+ STOP
+ ENDIF
CALL passed()
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c
index 1cc1017..eeaceeb 100644
--- a/hl/src/H5LT.c
+++ b/hl/src/H5LT.c
@@ -3030,4 +3030,110 @@ out:
}
-
+htri_t
+H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid)
+ {
+ char *tmp_path = NULL; /* Temporary copy of the path */
+ char *curr_name; /* Pointer to current component of path name */
+ char *delimit; /* Pointer to path delimiter during traversal */
+ H5I_type_t obj_type;
+ htri_t link_exists, obj_exists;
+ size_t path_length;
+ htri_t ret_value;
+
+ /* Initialize */
+ ret_value = FALSE;
+
+ /* Find the type of loc_id */
+ if((obj_type = H5Iget_type(loc_id)) == H5I_BADID) {
+ ret_value = FAIL;
+ goto done;
+ }
+
+ /* Find the length of the path */
+ path_length = HDstrlen(path);
+
+ /* Check if the identifier is the object itself, i.e. path is '.' */
+ if(HDstrncmp(path, ".", path_length) == 0) {
+ if(check_object_valid) {
+ obj_exists = H5Oexists_by_name(loc_id, path, H5P_DEFAULT);
+ ret_value = obj_exists;
+ goto done;
+ } else {
+ ret_value = TRUE; /* Since the object is the identifier itself,
+ * we can only check if loc_id is a valid type */
+ goto done;
+ }
+ }
+
+ /* Duplicate the path to use */
+ if(NULL == (tmp_path = HDstrdup(path))) {
+ ret_value = FAIL;
+ goto done;
+ }
+
+ curr_name = tmp_path;
+
+ /* check if absolute pathname */
+ if(HDstrncmp(path, "/", 1) == 0) curr_name++;
+
+ /* check if relative path name starts with "./" */
+ if(HDstrncmp(path, "./", 2) == 0) curr_name += 2;
+
+ while((delimit=HDstrchr(curr_name,'/'))!=NULL) {
+ /* Change the delimiter to terminate the string */
+ *delimit='\0';
+
+ obj_exists = FALSE;
+ if((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
+ ret_value = FAIL;
+ goto done;
+ }
+
+ /* If target link does not exist then no reason to
+ * continue checking the path */
+ if(link_exists != TRUE) {
+ ret_value = FALSE;
+ goto done;
+ }
+
+ /* Determine if link resolves to an actual object */
+ if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
+ ret_value = FAIL;
+ goto done;
+ }
+
+ if(obj_exists != TRUE)
+ break;
+
+ /* Change the delimiter back to '/' */
+ *delimit='/';
+
+ /* Advance the pointer in the path to the start of the next component */
+ curr_name = delimit + 1;
+
+ } /* end while */
+
+ /* Should be pointing to the last component in the path name now... */
+
+ /* Check if link does not exist */
+ if((link_exists = H5Lexists(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
+ ret_value = FAIL;
+ } else {
+ ret_value = link_exists;
+ /* Determine if link resolves to an actual object for check_object_valid TRUE */
+ if(check_object_valid == TRUE && link_exists == TRUE) {
+ if((obj_exists = H5Oexists_by_name(loc_id, tmp_path, H5P_DEFAULT)) < 0) {
+ ret_value = FAIL;
+ } else {
+ ret_value = obj_exists;
+ }
+ }
+ }
+
+done:
+ if(tmp_path != NULL)
+ HDfree(tmp_path);
+
+ return ret_value;
+ }
diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h
index 7fb873a..6efae68 100644
--- a/hl/src/H5LTpublic.h
+++ b/hl/src/H5LTpublic.h
@@ -340,8 +340,9 @@ H5_HLDLL herr_t H5LTdtype_to_text(hid_t dtype, char *str, H5LT_lang_t lang_type,
*-------------------------------------------------------------------------
*/
-H5_HLDLL herr_t H5LTfind_attribute( hid_t loc_id, const char *name );
+H5_HLDLL herr_t H5LTfind_attribute( hid_t loc_id, const char *name );
+H5_HLDLL htri_t H5LTpath_valid(hid_t loc_id, const char *path, hbool_t check_object_valid);
#ifdef __cplusplus
}
diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c
index 4944143..7a5e43a 100644
--- a/hl/test/test_lite.c
+++ b/hl/test/test_lite.c
@@ -21,6 +21,8 @@
#define FILE_NAME "test_lite1.h5"
#define FILE_NAME2 "test_lite2.h5"
+#define FILE_NAME3 "test_lite3.h5"
+#define FILE_NAME4 "test_lite4.h5"
#define INPUT_FILE "dtype_file.txt"
#define DSET0_NAME "2D int array"
@@ -1805,6 +1807,317 @@ out:
}
/*-------------------------------------------------------------------------
+ * test H5LTpath_valid function
+ *-------------------------------------------------------------------------
+ */
+static int test_valid_path(void)
+{
+ hid_t file_id, group;
+ herr_t status;
+ FILE *fp = NULL;
+ htri_t path_valid;
+ char path[10];
+ const char *data_string_in = "test";
+
+ TESTING("H5LTpath_valid");
+
+ /* Create a new file using default properties. */
+
+ /**************************************************************
+ * The file structure should look like this:
+ *
+ * +----------------------------------+
+ * | / |
+ * +----------------------------------+
+ * / | \ \
+ * / | \ \
+ * / | \ \
+ * / | \ G8 (dangled external link)
+ * / DS \
+ * / \
+ * G1 G2
+ * | --> DS1 |
+ * / \--> DS3 / \
+ * / / \
+ * G2 DS4 G7
+ * | (hard link (dangled soft link
+ * | to /G1/DS3) to /G1/G20 )
+ * / \
+ * / \
+ * G5 \
+ * (soft link G6 (external link /G1 in FILENAME4)
+ * to /G2)
+ *
+ ****************************************************************/
+
+ file_id = H5Fcreate(FILE_NAME3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create dataset "/DS"
+ */
+ if(H5LTmake_dataset_string(file_id, "DS", data_string_in)<0)
+ goto out;
+
+ /*
+ * Create an external dangled link
+ */
+ if(H5Lcreate_external("NonExistant_File.h5", "G8", file_id, "DangledExternalLink", H5P_DEFAULT, H5P_DEFAULT)<0)
+ goto out;
+
+ /*
+ * Create a group named "G2" in the file.
+ */
+ if((group = H5Gcreate(file_id, "G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
+ goto out;
+
+ /*
+ * Create a dataset named "G2/DS4" in the file.
+ */
+ if(H5LTmake_dataset_string(group, "/G2/DS4", data_string_in)<0)
+ goto out;
+
+ /*
+ * Create a soft link
+ */
+ if(H5Lcreate_soft("/G1/G20", file_id, "/G2/G7", H5P_DEFAULT, H5P_DEFAULT) <0)
+ goto out;
+
+ if(H5Gclose(group)<0)
+ goto out;
+
+ /*
+ * Create a group named "G1" in the file.
+ */
+ if((group = H5Gcreate(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
+ goto out;
+
+ /*
+ * Create a group named "G1/DS1" in the file.
+ */
+ if(H5LTmake_dataset_string(group, "/G1/DS1", data_string_in)<0)
+ goto out;
+
+ if(H5Gclose(group)<0)
+ goto out;
+
+ /*
+ * Create a group named "/G3/G5" in the file.
+ */
+ if(H5Lcreate_hard(file_id, "/G2/DS4", file_id, "/G1/DS3",H5P_DEFAULT, H5P_DEFAULT)<0)
+ goto out;
+ /*
+ * Create a group named "/G1/G2" in the file.
+ */
+ if((group = H5Gcreate (file_id, "/G1/G2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
+ goto out;
+
+ /*
+ * Create a soft link
+ */
+ if(H5Lcreate_soft("/G2", file_id, "/G1/G2/G5", H5P_DEFAULT, H5P_DEFAULT)<0)
+ goto out;
+
+ if(H5Gclose(group)<0)
+ goto out;
+
+ /*
+ * Create a group named "/G1/G2/G6" in the file.
+ */
+ if((group = H5Gcreate(file_id, "/G1/G2/G6", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
+ goto out;
+
+ /*
+ * Create an external link
+ */
+ if(H5Lcreate_external( FILE_NAME4, "G1", group, "ExternalLink", H5P_DEFAULT, H5P_DEFAULT)<0)
+ goto out;
+
+ if(H5Gclose(group)<0)
+ goto out;
+ /*
+ * Close the file.
+ */
+ status = H5Fclose (file_id);
+
+ /* Create another file for checking external links */
+
+ /**************************************************************
+ * The file structure should look like this:
+ *
+ * +----+
+ * | / |
+ * +----+
+ * |
+ * |
+ * |
+ * G1
+ * / \
+ * / \
+ * DS1 G2
+ * (dangled soft link to /G1/G20)
+ *
+ ****************************************************************/
+
+ /* Make external link file */
+ file_id = H5Fcreate(FILE_NAME4, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*
+ * Create a group named "G1" in the file.
+ */
+ if((group = H5Gcreate(file_id, "G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT))<0)
+ goto out;
+ /*
+ * Create a dataset named "G1/DS1" in the file.
+ */
+ if(H5LTmake_dataset_string(group, "/G1/DS1", data_string_in)<0)
+ goto out;
+
+ /*
+ * Create a dangling soft link
+ */
+
+ if(H5Lcreate_soft("/G1/G2", file_id, "/G1/G20", H5P_DEFAULT, H5P_DEFAULT)<0)
+ goto out;
+
+ if(H5Gclose(group)<0)
+ goto out;
+
+ H5Fclose(file_id);
+
+ /* Open input file */
+ if((file_id = H5Fopen(FILE_NAME3,H5F_ACC_RDONLY, H5P_DEFAULT))<0)
+ goto out;
+
+ /**************************************
+ * CHECK ABSOLUTE PATHS
+ **************************************/
+
+ strncpy(path, "/G1",3);
+ if( (path_valid = H5LTpath_valid(file_id, path, TRUE)) != TRUE) {
+ goto out;
+ }
+
+ if((path_valid = H5LTpath_valid(file_id, "/G1/DS1", TRUE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(file_id, "/G1/DS3", TRUE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(file_id, "/G1/G2", TRUE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G5", TRUE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(file_id, "/G2", TRUE)) != TRUE)
+ goto out;
+
+ /* check soft link points to a valid object*/
+ if( (path_valid = H5LTpath_valid(file_id, "/G2/DS4", TRUE)) != TRUE)
+ goto out;
+
+ /* check if path exist, but not the object */
+ if( (path_valid = H5LTpath_valid(file_id, "/G2/G7", FALSE)) != TRUE )
+ goto out;
+
+ /* check if path exist and if the object exists. It should fail
+ * since it is a dangling soft link
+ */
+ if( (path_valid = H5LTpath_valid(file_id, "/G2/G7", TRUE)) == TRUE)
+ goto out;
+
+ /* check soft links */
+ if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G5/DS4", TRUE)) != TRUE)
+ goto out;
+
+ /**************************************
+ * CHECK RELATIVE PATHS
+ ***************************************/
+
+ if( (group = H5Gopen(file_id, "/G1", H5P_DEFAULT)) < 0)
+ goto out;
+
+ /* The identifier (file id) is the object itself, i.e. "." */
+
+ if((path_valid = H5LTpath_valid(file_id, ".", FALSE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(file_id, ".", TRUE)) != TRUE)
+ goto out;
+
+ /* The identifier (group id) is the object itself, i.e. "." */
+
+ if( (path_valid = H5LTpath_valid(group, ".", TRUE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(group, "DS3", FALSE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(group, "DS3", TRUE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(group, "G2/G5", TRUE)) != TRUE)
+ goto out;
+
+ /* Check the "./" case */
+ if( (path_valid = H5LTpath_valid(group, "./DS3", TRUE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(group, "./G2/G5", TRUE)) != TRUE)
+ goto out;
+
+ /* Should fail, does not exist */
+ if( (path_valid = H5LTpath_valid(group, "./G2/G20", FALSE)) == TRUE)
+ goto out;
+
+ /* Should fail, does not exist */
+ if( (path_valid = H5LTpath_valid(group, "./G2/G20", TRUE)) == TRUE)
+ goto out;
+
+ if(H5Gclose(group)<0)
+ goto out;
+
+ /*****************************
+ * Check external links
+ *****************************/
+
+ /* The dangled external link path is valid */
+ if( (path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", FALSE)) != TRUE)
+ goto out;
+
+ /* The file however does not exists, so the link dangles -> should return false */
+ if( (path_valid = H5LTpath_valid(file_id, "/DangledExternalLink", TRUE)) == TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", FALSE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink", TRUE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/DS1", TRUE)) != TRUE)
+ goto out;
+
+ if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", FALSE)) != TRUE)
+ goto out;
+
+ /* Should fail, does not exist */
+ if( (path_valid = H5LTpath_valid(file_id, "/G1/G2/G6/ExternalLink/G20", TRUE)) == TRUE)
+ goto out;
+
+ if(H5Fclose(file_id)<0)
+ goto out;
+
+ PASSED();
+ return 0;
+
+ out:
+ H5_FAILED();
+ return -1;
+}
+
+
+/*-------------------------------------------------------------------------
* the main program
*-------------------------------------------------------------------------
*/
@@ -1819,7 +2132,7 @@ int main( void )
nerrors += test_attr();
/* test text-dtype functions */
- nerrors += test_text_dtype();
+ nerrors += test_valid_path();
/* check for errors */
if (nerrors)
@@ -1832,4 +2145,3 @@ error:
}
-