public void H5Rget_obj_typeTest2() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte[path.Length + 1]; Array.Copy(path, name, path.Length); Assert.IsTrue( H5G.close(H5G.create(m_v2_test_file, path, m_lcpl_utf8)) >= 0); byte[] refer = new byte[H5R.OBJ_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v2_test_file, name, H5R.type_t.OBJECT, -1) >= 0); H5O.type_t obj_type = H5O.type_t.UNKNOWN; Assert.IsTrue( H5R.get_obj_type(m_v2_test_file, H5R.type_t.OBJECT, hnd.AddrOfPinnedObject(), ref obj_type) >= 0); hnd.Free(); Assert.IsTrue(obj_type == H5O.type_t.GROUP); }
private string[] CollectObjects(H5O.type_t type) { const int CONTINUE = 0; int status; List <string> rv = new List <string>(); // the callback function, called for each item in the iteration #if HDF5_VER1_10 H5L.iterate_t op_fun = (long loc, IntPtr name, ref H5L.info_t info, IntPtr op_data) => #else H5L.iterate_t op_fun = (int loc, IntPtr name, ref H5L.info_t info, IntPtr op_data) => #endif { H5O.info_t oinfo = new H5O.info_t(); var bname = Marshal.PtrToStringAnsi(name); if ((status = H5O.get_info_by_name(loc, bname, ref oinfo, H5P.DEFAULT)) < 0) { return(status); } if (oinfo.type == type) { rv.Add(bname); } return(CONTINUE); }; ulong tracking_index = 0; if ((status = H5L.iterate(ID, H5.index_t.NAME, H5.iter_order_t.NATIVE, ref tracking_index, op_fun, IntPtr.Zero)) < 0) { throw new H5LibraryException($"H5Literate() returned {status}"); } return(rv.ToArray()); }
public void H5Rget_obj_typeTest3() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte[path.Length + 1]; Array.Copy(path, name, path.Length); hsize_t[] dims = new hsize_t[] { 10, 20 }; hid_t space = H5S.create_simple(2, dims, null); Assert.IsTrue(space >= 0); hid_t dset = H5D.create(m_v0_test_file, name, H5T.STD_I32LE, space, m_lcpl_utf8); Assert.IsTrue(dset >= 0); hsize_t[] start = { 5, 10 }; hsize_t[] count = { 1, 1 }; hsize_t[] block = { 2, 4 }; Assert.IsTrue( H5S.select_hyperslab(space, H5S.seloper_t.SET, start, null, count, block) >= 0); byte[] refer = new byte[H5R.DSET_REG_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v0_test_file, name, H5R.type_t.DATASET_REGION, space) >= 0); H5O.type_t obj_type = H5O.type_t.UNKNOWN; Assert.IsTrue( H5R.get_obj_type(m_v0_test_file, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject(), ref obj_type) >= 0); hnd.Free(); Assert.IsTrue(obj_type == H5O.type_t.DATASET); Assert.IsTrue(H5D.close(dset) >= 0); Assert.IsTrue(H5S.close(space) >= 0); }
public static extern herr_t get_obj_type (hid_t loc_id, type_t ref_type, IntPtr refer, ref H5O.type_t obj_type);