I try to mount different files that all have the same structure to a single new one (in C++). Therefore I create a new File "new.h5" and in there a new Group "/G". The existing two files ("file1.h5" and "file2.h5") have some Attributes in the root-Group "/" and then a path "dataset1/data1/data", where "dataset1/data1" contains some Attributes and the "data"-Path with numerical Data in it.
/dataset1
/attribute1
/attribute2
/data1
/data
/attribute1
/attribute2
In the new file I want a structure:
/G
/dataset1
/attribute1
/attribute2
/data1
/data
/attribute1
/attribute2
/dataset2
/attribute1
/attribute2
/data1
/data
/attribute1
/attribute2
I tried it this way:
#include "hdf5.h"
#ifdef OLD_HEADER_FILENAME
#include <iostream.h>
#else
#include <iostream>
#endif
#include <string>
#ifndef H5_NO_NAMESPACE
#ifndef H5_NO_STD
using std::cout;
using std::endl;
#endif // H5_NO_STD
#endif
#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif
#define FILE_NAME_1 "file1.h5"
#define FILE_NAME_2 "file2.h5"
#define FILE_NAME_ALL "new.h5"
int main(void)
{
hid_t fid1, fid2, fid3, gid; /* Files and group identifiers */
fid1 = H5Fopen(FILE_NAME_1, H5F_ACC_RDWR, H5P_DEFAULT);
fid2 = H5Fopen(FILE_NAME_2, H5F_ACC_RDWR, H5P_DEFAULT);
fid3 = H5Fcreate(FILE_NAME_ALL, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
gid = H5Gcreate2(fid3, "/G", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
H5Gclose(gid);
/*
* Mount second file under G in the first file.
*/
H5Fmount(fid3, "/G", fid1, H5P_DEFAULT);
H5Fmount(fid3, "/G", fid2, H5P_DEFAULT);
H5Fclose(fid1);
H5Fclose(fid2);
H5Fclose(fid3);
return 0;
}
When I take a look to new.h5 with h5dump
I get:
h5dump new.h5
HDF5 "new.h5" {
GROUP "/" {
GROUP "G" {
}
}
}
so I created the Group G but there are no files in it?! What went wrong?
And is there a possibility to rename the "dataset1" from the second file to "dataset2" while mounting the files or do I have to do it before?
Thank you!
EDIT:
I might have found a problem: I want to mount files from the root-group. What I mean: I want to have a common file that contains everything from the other two files. That makes it difficult to find a mounting point. It can't be the root-directory but there are no groups called "/G" in the existing files. How can I solve this?