summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
authorPedro Vicente Nunes <pvn@hdfgroup.org>2003-12-18 20:25:11 (GMT)
committerPedro Vicente Nunes <pvn@hdfgroup.org>2003-12-18 20:25:11 (GMT)
commit5658d883277c915fa56c111bbb21a487a0659e1f (patch)
treecce6746b89fcc35e491b58b418f8d83c7e4c2900 /tools/lib
parent5b518c102d14f036116e98244fc6856a6c49dc3c (diff)
downloadhdf5-5658d883277c915fa56c111bbb21a487a0659e1f.zip
hdf5-5658d883277c915fa56c111bbb21a487a0659e1f.tar.gz
hdf5-5658d883277c915fa56c111bbb21a487a0659e1f.tar.bz2
[svn-r7971] Purpose:
h5repack bug Description: changed the copy hardlinks algorithm added more tests Solution: Platforms tested: linux solaris IRIX Misc. update:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5trav.c63
-rw-r--r--tools/lib/h5trav.h16
-rw-r--r--tools/lib/h5trav_table.c11
3 files changed, 82 insertions, 8 deletions
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index e065e28..a005636 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -389,11 +389,12 @@ int traverse( hid_t loc_id,
if ( table->objs[j].displayed == 0 )
{
table->objs[j].displayed = 1;
+ trav_table_addlink(table,j,path);
}
else
{
#if defined (H5_TRAV_DEBUG)
- printf("<%s> HARDLINK to <%s>\n", path, table->objs[j].name);
+ printf("<%s> HARDLINK\n", path);
#endif
trav_table_addlink(table,j,path);
}
@@ -429,11 +430,12 @@ int traverse( hid_t loc_id,
if ( table->objs[j].displayed == 0 )
{
table->objs[j].displayed = 1;
+ trav_table_addlink(table,j,path);
}
else
{
#if defined (H5_TRAV_DEBUG)
- printf("<%s> HARDLINK to <%s>\n", path, table->objs[j].name);
+ printf("<%s> HARDLINK\n", path);
#endif
trav_table_addlink(table,j,path);
} /* displayed==1 */
@@ -585,10 +587,65 @@ void h5trav_printtable(trav_table_t *table)
{
for ( j=0; j<table->objs[i].nlinks; j++)
{
- printf(" %-10s %s\n", " hardlink", table->objs[i].links[j] );
+ printf(" %-10s %s\n", " hardlink", table->objs[i].links[j].new_name );
+ }
+ }
+
+ }
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: h5trav_getindext
+ *
+ * Purpose: get index of NAME in list
+ *
+ * Return: index, -1 if not found
+ *
+ * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ *
+ * Date: December 18, 2003
+ *
+ *-------------------------------------------------------------------------
+ */
+
+int h5trav_getindext(const char *name, trav_table_t *table)
+{
+ char *pdest;
+ int result;
+ int i, j;
+
+ for ( i = 0; i < table->nobjs; i++)
+ {
+ if ( strcmp(name,table->objs[i].name)==0 )
+ return i;
+
+ pdest = strstr( table->objs[i].name, name );
+ result = (int)(pdest - table->objs[i].name);
+
+ /* found at position 1, meaning without '/' */
+ if( pdest != NULL && result==1 )
+ return i;
+
+ /* search also in the list of links */
+ if (table->objs[i].nlinks)
+ {
+ for ( j=0; j<table->objs[i].nlinks; j++)
+ {
+ if ( strcmp(name,table->objs[i].links[j].new_name)==0 )
+ return i;
+
+ pdest = strstr( table->objs[i].links[j].new_name, name );
+ result = (int)(pdest - table->objs[i].links[j].new_name);
+
+ /* found at position 1, meaning without '/' */
+ if( pdest != NULL && result==1 )
+ return i;
+
}
}
}
+ return -1;
}
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index cedbc54..5f68da4 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -78,7 +78,7 @@ typedef struct trav_table_t {
/*-------------------------------------------------------------------------
- * "h5trav info" public functions
+ * public functions
*-------------------------------------------------------------------------
*/
@@ -86,12 +86,23 @@ typedef struct trav_table_t {
extern "C" {
#endif
+/*-------------------------------------------------------------------------
+ * "h5trav info" public functions
+ *-------------------------------------------------------------------------
+ */
int h5trav_getinfo( hid_t file_id, trav_info_t *info );
int h5trav_getindex( const char *obj, int nobjs, trav_info_t *info );
void h5trav_freeinfo( trav_info_t *info, int nobjs );
void h5trav_printinfo(int nobjs, trav_info_t *info);
-int h5trav_gettable(hid_t fid, trav_table_t *travt);
+/*-------------------------------------------------------------------------
+ * "h5trav table" public functions
+ *-------------------------------------------------------------------------
+ */
+
+int h5trav_getindext(const char *obj,trav_table_t *travt);
+int h5trav_gettable(hid_t fid, trav_table_t *travt);
+void h5trav_printtable(trav_table_t *table);
#ifdef __cplusplus
}
@@ -119,7 +130,6 @@ void trav_table_addflags(unsigned *flags,
H5G_obj_t type,
trav_table_t *table);
-void h5trav_printtable(trav_table_t *table);
void trav_table_addlink(trav_table_t *table,
int j /* the object index */,
diff --git a/tools/lib/h5trav_table.c b/tools/lib/h5trav_table.c
index 0071559..8e794aa 100644
--- a/tools/lib/h5trav_table.c
+++ b/tools/lib/h5trav_table.c
@@ -235,14 +235,21 @@ void trav_table_addlink(trav_table_t *table,
char *path )
{
int k;
- /* store the link information */
+
+ /* already inserted */
+ if (strcmp(table->objs[j].name,path)==0)
+ return;
+
+ /* allocate space if necessary */
if (table->objs[j].nlinks == table->objs[j].sizelinks) {
table->objs[j].sizelinks += 2;
table->objs[j].links =
(trav_link_t*)HDrealloc(table->objs[j].links,
table->objs[j].sizelinks * sizeof(trav_link_t));
}
- k = table->objs[j].nlinks++;
+
+ /* insert it */
+ k=table->objs[j].nlinks++;
table->objs[j].links[k].new_name = (char*)HDstrdup(path);
}