public static void UpdateCampaignInfoSet() { long vdsFileId = -1; long vdsMetaFileId = -1; long groupId = -1; lock (_lock) { try { if (File.Exists(_options.VdsFilePath)) { vdsFileId = H5F.open(_options.VdsFilePath, H5F.ACC_RDONLY); vdsMetaFileId = H5F.open(_options.VdsMetaFilePath, H5F.ACC_RDONLY); Program.CampaignInfoSet = GeneralHelper.GetCampaignInfoSet(vdsFileId, false); } else { Program.CampaignInfoSet = new List <CampaignInfo>(); } Program.CampaignDescriptionSet = Program.CampaignInfoSet.ToDictionary(campaignInfo => campaignInfo.Name, campaignInfo => { if (IOHelper.CheckLinkExists(vdsMetaFileId, campaignInfo.Name)) { try { groupId = H5G.open(vdsMetaFileId, campaignInfo.Name); if (H5A.exists(groupId, "description") > 0) { return(IOHelper.ReadAttribute <string>(groupId, "description").First()); } } finally { if (H5I.is_valid(groupId) > 0) { H5G.close(groupId); } } } return("no description available"); }); } finally { if (H5I.is_valid(vdsFileId) > 0) { H5F.close(vdsFileId); } if (H5I.is_valid(vdsMetaFileId) > 0) { H5F.close(vdsMetaFileId); } } } }
public static Dictionary <uint, string> GetLabelWorkingSet(long group_id) { Dictionary <uint, string> labelWorkingSet = new Dictionary <uint, string>(); H5A.operator_t callBackMethod = DelegateMethod; ArrayList attrNameArray = new ArrayList(); GCHandle nameArrayAlloc = GCHandle.Alloc(attrNameArray); IntPtr ptrOnAllocArray = (IntPtr)nameArrayAlloc; int status; ulong beginAt = 0; status = H5A.iterate(group_id, H5.index_t.CRT_ORDER, H5.iter_order_t.INC, ref beginAt, callBackMethod, ptrOnAllocArray); for (int i = 0; i < attrNameArray.Count; i++) { string attr_name = Convert.ToString(attrNameArray[i]); long attr_id = H5A.open(group_id, attr_name); uint[] attr_value = { 0 }; GCHandle valueAlloc = GCHandle.Alloc(attr_value, GCHandleType.Pinned); status = H5A.read(attr_id, H5T.NATIVE_UINT32, valueAlloc.AddrOfPinnedObject()); status = H5A.close(attr_id); labelWorkingSet.Add(attr_value[0], attr_name); } status = H5G.close(group_id); return(labelWorkingSet); }
public void H5Iget_nameTest1() { hid_t gid = H5G.create(m_v0_test_file, "AAAAAAAAAAAAAAAAAAAAA"); Assert.IsTrue(gid > 0); ssize_t buf_size = H5I.get_name(gid, (StringBuilder)null, IntPtr.Zero) + 1; Assert.IsTrue(buf_size.ToInt32() > 1); StringBuilder nameBuilder = new StringBuilder(buf_size.ToInt32()); IntPtr size = H5I.get_name(gid, nameBuilder, buf_size); Assert.IsTrue(size.ToInt32() > 0); Assert.IsTrue(nameBuilder.ToString() == "/AAAAAAAAAAAAAAAAAAAAA"); Assert.IsTrue(H5G.close(gid) >= 0); gid = H5G.create(m_v2_test_file, "AAAAAAAAAAAAAAAAAAAAA"); Assert.IsTrue(gid > 0); buf_size = H5I.get_name(gid, (StringBuilder)null, IntPtr.Zero) + 1; Assert.IsTrue(buf_size.ToInt32() > 1); nameBuilder = new StringBuilder(buf_size.ToInt32()); size = H5I.get_name(gid, nameBuilder, buf_size); Assert.IsTrue(size.ToInt32() > 0); Assert.IsTrue(nameBuilder.ToString() == "/AAAAAAAAAAAAAAAAAAAAA"); Assert.IsTrue(H5G.close(gid) >= 0); }
protected Dictionary <string, long> FindChildren(bool dataSets) { Dictionary <string, long> datasetNames = new Dictionary <string, long>(); Dictionary <string, long> groupNames = new Dictionary <string, long>(); var rootID = Open(); ulong dummy = 0; H5L.iterate(rootID, H5.index_t.NAME, H5.iter_order_t.INC, ref dummy, new H5L.iterate_t( delegate(long objectId, IntPtr namePtr, ref H5L.info_t info, IntPtr op_data) { string objectName = Marshal.PtrToStringAnsi(namePtr); H5O.info_t gInfo = new H5O.info_t(); H5O.get_info_by_name(objectId, objectName, ref gInfo); if (gInfo.type == H5O.type_t.DATASET) { datasetNames[objectName] = objectId; } else if (gInfo.type == H5O.type_t.GROUP) { groupNames[objectName] = objectId; } return(0); }), new IntPtr()); H5G.close(rootID); if (dataSets) { return(datasetNames); } return(groupNames); }
public void H5LmoveTest1() { Assert.IsTrue( H5G.close(H5G.create(m_v0_test_file, "A/B/C/D", m_lcpl)) >= 0); Assert.IsTrue( H5L.create_hard(m_v0_test_file, "A/B/C/D", m_v0_test_file, "shortcut") >= 0); Assert.IsTrue( H5L.move(m_v0_test_file, "shortcut", m_v0_test_file, "A/B/C/D/E") >= 0); Assert.IsTrue( H5L.exists(m_v0_test_file, "A/B/C/D/E") > 0); Assert.IsTrue( H5L.exists(m_v0_test_file, "A/B/C/D/shortcut") == 0); Assert.IsTrue( H5G.close(H5G.create(m_v2_test_file, "A/B/C/D", m_lcpl)) >= 0); Assert.IsTrue( H5L.create_hard(m_v2_test_file, "A/B/C/D", m_v2_test_file, "shortcut") >= 0); Assert.IsTrue( H5L.move(m_v2_test_file, "shortcut", m_v2_test_file, "A/B/C/D/E") >= 0); Assert.IsTrue( H5L.exists(m_v0_test_file, "A/B/C/D/E") > 0); Assert.IsTrue( H5L.exists(m_v0_test_file, "A/B/C/D/shortcut") == 0); }
public void WriteAndReadStringAttribute() { string filename = Path.Combine(folder, "testAttributeString.H5"); try { var fileId = Hdf5.CreateFile(filename); Assert.IsTrue(fileId > 0); var groupId = Hdf5.CreateOrOpenGroup(fileId, "test"); string attrStr = "this is an attribute"; Hdf5.WriteAttribute(groupId, "time", attrStr); string readStr = Hdf5.ReadAttribute <string>(groupId, "time_Non_Exist"); Assert.IsTrue(string.IsNullOrEmpty(readStr)); readStr = Hdf5.ReadAttribute <string>(groupId, "time"); Assert.IsTrue(readStr == attrStr); Assert.IsTrue(H5G.close(groupId) == 0); Assert.IsTrue(Hdf5.CloseFile(fileId) == 0); ErrorCountExpected = 2; } catch (Exception ex) { CreateExceptionAssert(ex); } }
public static unsafe void AddSomeLinks(long fileId) { long res; var groupId = H5G.create(fileId, "simple"); var groupId_sub = H5G.create(groupId, "sub"); // datasets var dataspaceId1 = H5S.create_simple(1, new ulong[] { 1 }, new ulong[] { 1 }); var datasetId1 = H5D.create(fileId, "D", H5T.NATIVE_INT8, dataspaceId1); var data1 = new byte[] { 1 }; fixed(void *ptr = data1) { res = H5D.write(datasetId1, H5T.NATIVE_INT8, dataspaceId1, dataspaceId1, 0, new IntPtr(ptr)); } res = H5D.close(datasetId1); res = H5S.close(dataspaceId1); var dataspaceId2 = H5S.create_simple(1, new ulong[] { 1 }, new ulong[] { 1 }); var datasetId2 = H5D.create(groupId, "D1", H5T.NATIVE_INT8, dataspaceId2); res = H5D.close(datasetId2); res = H5S.close(dataspaceId2); var dataspaceId3 = H5S.create_simple(1, new ulong[] { 1 }, new ulong[] { 1 }); var datasetId3 = H5D.create(groupId_sub, "D1.1", H5T.NATIVE_INT8, dataspaceId3); res = H5D.close(datasetId3); res = H5S.close(dataspaceId3); res = H5G.close(groupId); res = H5G.close(groupId_sub); }
protected override void CloseId(long id) { if (H5I.is_valid(id) > 0) { H5G.close(id); } }
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); }
public override void CloseDocument() { if (fileId != null && fileId.Id > 0 && !_fileClosed) { foreach (var group in EpochGroupsIDs) { try { H5G.close(group.GroupId); H5G.close(group.SubGroupsId); H5G.close(group.EpochsId); } catch (H5GcloseException ex) { log.DebugFormat("HDF5 group already closed: {0}", ex); } } try { H5F.close(fileId); } catch (H5FcloseException ex) { log.DebugFormat("HDF5 file already closed: {0}", ex); } Interlocked.Decrement(ref _openHdf5FileCount); _fileClosed = true; } }
public static ANNDef ReadANNFromKeras(string fnH5Weights, string fnJSONStructure) { ANNDef ann = new ANNDef(); Console.WriteLine("** LOAD file " + fnH5Weights); if (!File.Exists(fnH5Weights)) { throw new Exception("*** File not found"); } const bool READ_ONLY = true; long file = Hdf5.OpenFile(fnH5Weights, READ_ONLY); if (file < 0) { throw new Exception("unable to find/open file " + fnH5Weights); } bool inputLayerIsSparse = false; JsonDocument o = JsonDocument.Parse(File.ReadAllText(fnJSONStructure)); List <(string, ANNDef)> subnets = new(); inputLayerIsSparse = ExtractNetwork(ann, subnets, file, inputLayerIsSparse, o.RootElement, null); if (subnets.Count > 0) { ann.InputSubnetworks = subnets; } H5G.close(file); return(ann); }
public void H5Oexists_by_nameTest1() { Assert.IsTrue(H5L.create_soft("/oh my", m_v0_test_file, "AA") >= 0); hid_t gid = H5G.create(m_v0_test_file, "A/B/C", m_lcpl); Assert.IsTrue(gid >= 0); Assert.IsTrue(H5O.exists_by_name(m_v0_test_file, "A/B") > 0); Assert.IsTrue(H5O.exists_by_name(m_v0_test_file, "AA") == 0); Assert.IsTrue( H5O.exists_by_name(m_v0_test_file, "A/B/Caesar") < 0); Assert.IsTrue(H5G.close(gid) >= 0); Assert.IsTrue(H5L.create_soft("/oh my", m_v2_test_file, "AA") >= 0); gid = H5G.create(m_v2_test_file, "A/B/C", m_lcpl); Assert.IsTrue(gid >= 0); Assert.IsTrue(H5O.exists_by_name(m_v2_test_file, "A/B") > 0); Assert.IsTrue(H5O.exists_by_name(m_v2_test_file, "AA") == 0); Assert.IsTrue( H5O.exists_by_name(m_v2_test_file, "A/B/Caesar") < 0); Assert.IsTrue(H5G.close(gid) >= 0); }
public static double ReadAttribute(string file, string dataSetOrGroup, string attribute) { double attr = Double.NaN; try { H5FileId fileId = H5F.open(file, H5F.OpenMode.ACC_RDONLY); H5ObjectInfo objectInfo = H5O.getInfoByName(fileId, dataSetOrGroup); H5GroupId groupId = null; H5DataSetId dataSetId = null; H5AttributeId attrId; if (objectInfo.objectType == H5ObjectType.GROUP) { groupId = H5G.open(fileId, dataSetOrGroup); attrId = H5A.open(groupId, attribute); } else { dataSetId = H5D.open(fileId, dataSetOrGroup); attrId = H5A.open(dataSetId, attribute); } H5DataTypeId attrTypeId = H5A.getType(attrId); double[] dAttrs = new double[] { }; if (H5T.equal(attrTypeId, H5T.copy(H5T.H5Type.NATIVE_FLOAT))) { float[] fAttrs = new float[H5S.getSimpleExtentNPoints(H5A.getSpace(attrId))]; H5A.read(attrId, attrTypeId, new H5Array <float>(fAttrs)); dAttrs = (from f in fAttrs select(double) f).ToArray(); } else if (H5T.equal(attrTypeId, H5T.copy(H5T.H5Type.NATIVE_DOUBLE))) { dAttrs = new double[H5S.getSimpleExtentNPoints(H5A.getSpace(attrId))]; H5A.read(attrId, attrTypeId, new H5Array <double>(dAttrs)); } H5T.close(attrTypeId); H5A.close(attrId); if (groupId != null) { H5G.close(groupId); } if (dataSetId != null) { H5D.close(dataSetId); } H5F.close(fileId); return((double)dAttrs[0]); } catch (HDFException e) { Console.WriteLine("Error: Unhandled HDF5 exception"); Console.WriteLine(e.Message); } return(attr); }
protected override void OnInitialize() { if (IOHelper.CheckLinkExists(_vdsMetaFileId, _currentPath)) { _groupId = H5G.open(_vdsMetaFileId, _currentPath); if (H5A.exists(_groupId, "unit") > 0) { _unit = IOHelper.ReadAttribute <string>(_groupId, "unit").FirstOrDefault(); } if (H5A.exists(_groupId, "transfer_function_set") > 0) { _vdsMetaTransferFunctionSet = IOHelper.ReadAttribute <hdf_transfer_function_t>(_groupId, "transfer_function_set").ToList(); } else { _vdsMetaTransferFunctionSet = new List <hdf_transfer_function_t>(); } H5G.close(_groupId); } else { _vdsMetaTransferFunctionSet = new List <hdf_transfer_function_t>(); } }
public void H5LdeleteTest1() { Assert.IsTrue( H5G.close(H5G.create(m_v0_test_file, "A/B/C/D", m_lcpl)) >= 0); Assert.IsTrue( H5L.create_hard(m_v0_test_file, Encoding.ASCII.GetBytes("A/B/C/D"), m_v0_test_file, Encoding.ASCII.GetBytes("shortcut")) >= 0); hid_t group = H5G.open(m_v0_test_file, "A/B/C"); Assert.IsTrue(group >= 0); Assert.IsTrue(H5L.delete(group, "D") >= 0); Assert.IsTrue(H5G.close(group) >= 0); Assert.IsTrue(H5L.exists(m_v0_test_file, "shortcut") > 0); Assert.IsTrue(H5L.exists(m_v0_test_file, "A/B/C/D") == 0); Assert.IsTrue( H5G.close(H5G.create(m_v2_test_file, "A/B/C/D", m_lcpl)) >= 0); Assert.IsTrue( H5L.create_hard(m_v2_test_file, Encoding.ASCII.GetBytes("A/B/C/D"), m_v2_test_file, Encoding.ASCII.GetBytes("shortcut")) >= 0); group = H5G.open(m_v2_test_file, "A/B/C"); Assert.IsTrue(group >= 0); Assert.IsTrue(H5L.delete(group, "D") >= 0); Assert.IsTrue(H5G.close(group) >= 0); Assert.IsTrue(H5L.exists(m_v0_test_file, "shortcut") > 0); Assert.IsTrue(H5L.exists(m_v0_test_file, "A/B/C/D") == 0); }
//public string Name { // get { return name; } // //set // //{ // // name = value; // // // Update HDF5 // //} //} public HDF5Group(string name, HDF5Container parent) { this.name = name; this.parent = parent; h5ID = H5G.open(parent.h5ID, name); H5G.close(h5ID); }
public void H5Oget_info_by_idxTest1() { Assert.IsTrue( H5G.close(H5G.create(m_v0_test_file, "A")) >= 0); Assert.IsTrue( H5G.close(H5G.create(m_v0_test_file, "AA")) >= 0); Assert.IsTrue( H5G.close(H5G.create(m_v0_test_file, "AAA")) >= 0); Assert.IsTrue( H5G.close(H5G.create(m_v0_test_file, "AAAA")) >= 0); H5O.info_t info = new H5O.info_t(); Assert.IsTrue(H5O.get_info_by_idx(m_v0_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, 2, ref info) >= 0); Assert.IsTrue(info.type == H5O.type_t.GROUP); Assert.IsTrue( H5G.close(H5G.create(m_v2_test_file, "A")) >= 0); Assert.IsTrue( H5G.close(H5G.create(m_v2_test_file, "AA")) >= 0); Assert.IsTrue( H5G.close(H5G.create(m_v2_test_file, "AAA")) >= 0); Assert.IsTrue( H5G.close(H5G.create(m_v2_test_file, "AAAA")) >= 0); info = new H5O.info_t(); Assert.IsTrue(H5O.get_info_by_idx(m_v2_test_file, ".", H5.index_t.NAME, H5.iter_order_t.NATIVE, 2, ref info) >= 0); Assert.IsTrue(info.type == H5O.type_t.GROUP); }
/// <summary> /// frees a group handle, if the group is different from the file handle. /// </summary> /// <param name="groupId"></param> private void CloseGroup(long groupId) { if (groupId != this.h5FileId) { H5G.close(groupId); } }
private static void WriteFile(string filePath) { var file = H5F.create(filePath, H5F.CreateMode.ACC_TRUNC); var group = H5G.create(file, "/group"); H5G.close(group); const int RANK = 2; const int DIM0 = 3; const int DIM1 = 4; var dims = new long[RANK] { DIM0, DIM1 }; var dataSpace = H5S.create_simple(RANK, dims); var dataSet = H5D.create(file, "/group/dataset", H5T.H5Type.NATIVE_INT, dataSpace); H5S.close(dataSpace); var data = new int[DIM0, DIM1] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; H5D.write(dataSet, new H5DataTypeId(H5T.H5Type.NATIVE_INT), new H5Array <int>(data)); var dataType = new H5DataTypeId(H5T.H5Type.NATIVE_INT); dataSpace = H5S.create(H5S.H5SClass.SCALAR); var integerAttribute = H5A.create(dataSet, "int", dataType, dataSpace); H5A.write(integerAttribute, dataType, new H5Array <int>(new int[1] { 42 })); H5A.close(integerAttribute); H5S.close(dataSpace); //H5T.close(dataType); // Read-only. var str = "Hello, world!"; var strBytes = Encoding.ASCII.GetBytes(str); // There is a H5T.get_cset, but there does not seem to be a way of setting the character encoding, i.e. set_cset. dataType = H5T.copy(H5T.H5Type.C_S1); H5T.setSize(dataType, strBytes.Length); dataSpace = H5S.create(H5S.H5SClass.SCALAR); var stringAttribute = H5A.create(dataSet, "string", dataType, dataSpace); H5A.write(stringAttribute, dataType, new H5Array <byte>(strBytes)); H5A.close(stringAttribute); H5S.close(dataSpace); H5T.close(dataType); H5D.close(dataSet); H5F.close(file); }
public void CreateGroup(string name) { With(id => { var newID = H5G.create(id, name); H5G.close(newID); }); }
static void test_file_open() { try { // Output message about test being performed. Console.Write("Testing file opening I/O"); // First ensure the file does not exist File.Delete(FILE2); // Try opening a non-existent file. This should fail. try { H5FileId non_exist_file = H5F.open(FILE2, H5F.OpenMode.ACC_RDWR); // should fail, but didn't, print out the error message. Console.WriteLine("\ntest_file_open: Attempting to open a non-existent file."); nerrors++; } catch (H5FopenException) { } // does nothing, it should fail // Open the file. H5FileId fileId = H5F.open(FILE1, H5F.OpenMode.ACC_RDWR); // Create dataspace for the dataset in the file. hssize_t[] dims = { 20 }; H5DataSpaceId dspace = H5S.create_simple(RANK, dims); // Create a group. H5GroupId groupId = H5G.create(fileId, GROUP_NAME); // Create a dataset using file as location. H5DataSetId dset1Id = H5D.create(fileId, DSET1_NAME, H5T.H5Type.NATIVE_INT, dspace); // Create a dataset using group as location. H5DataSetId dset2Id = H5D.create(groupId, DSET2_NAME, H5T.H5Type.NATIVE_SHORT, dspace); // Close objects and files. H5D.close(dset1Id); H5D.close(dset2Id); H5S.close(dspace); H5G.close(groupId); H5F.close(fileId); Console.WriteLine("\t\t\t\tPASSED"); } catch (HDFException anyHDF5E) { Console.WriteLine(anyHDF5E.Message); nerrors++; } catch (System.Exception sysE) { Console.WriteLine(sysE.TargetSite); Console.WriteLine(sysE.Message); nerrors++; } } // test_file_open
public static unsafe void AddExternalFileLink(long fileId, string filePath) { long res; var groupId = H5G.create(fileId, "links"); res = H5L.create_external(filePath, "/external/group", groupId, "external_link"); res = H5G.close(groupId); }
public override void Dispose() { base.Dispose(); if (ID > 0) { ID = H5G.close(ID); } }
public void H5Odisable_mdc_flushesTestSWMR2() { hid_t grp = H5G.create(m_v3_test_file_no_swmr, "/A/B/C", m_lcpl); Assert.IsTrue(grp >= 0); Assert.IsTrue(H5O.disable_mdc_flushes(grp) >= 0); Assert.IsTrue(H5G.flush(grp) >= 0); Assert.IsTrue(H5G.close(grp) >= 0); }
private void GetGroupDatasetNames(string groupName) { H5GroupId h5GroupId = H5G.open(_h5FileId, groupName); try { long dscount = H5G.getNumObjects(h5GroupId); for (int i = 0; i < dscount; i++) { string objname = H5G.getObjectNameByIndex(h5GroupId, (ulong)i); ObjectInfo objInfo = H5G.getObjectInfo(h5GroupId, objname, false); switch (objInfo.objectType) { case H5GType.DATASET: if (objInfo.objectType == H5GType.DATASET) { if (groupName == "/") { _datasetNames.Add(objname); } else { _datasetNames.Add(groupName + objname); } } break; case H5GType.GROUP: if (groupName == "/") { GetGroupDatasetNames(objname + "/"); } else { GetGroupDatasetNames(groupName + objname + "/"); } break; case H5GType.LINK: break; case H5GType.TYPE: break; default: break; } } } finally { if (h5GroupId != null) { H5G.close(h5GroupId); } } }
private void Menu_2(Dictionary <string, string> settings) // edit variable name { long fileId; long groupId; string variableGroupPath; string attributeName; string[] attributeContentSet; List <string> filePathSet; // settings = this.PromptEditVariableNameData(settings); if (settings.ContainsKey("DirectoryPath")) { filePathSet = Directory.GetFiles(settings["DirectoryPath"], settings["SearchPattern"], settings["IncludeSubDirectories"] == "Yes" ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).ToList(); } else { filePathSet = new List <string>() { settings["FilePath"] }; } variableGroupPath = settings["VariableGroupPath"]; attributeName = "name_set"; attributeContentSet = new string[] { settings["VariableName"] }; foreach (string filePath in filePathSet) { fileId = H5F.open(filePath, H5F.ACC_RDWR, 0); if (IOHelper.CheckLinkExists(fileId, variableGroupPath)) { groupId = H5G.open(fileId, variableGroupPath); if (settings["AppendMode"] == "Append") { IOHelper.PrepareAttribute(groupId, attributeName, attributeContentSet, new ulong[] { H5S.UNLIMITED }, true); } else { IOHelper.WriteAttribute(groupId, attributeName, attributeContentSet); } // clean up H5G.close(groupId); } // clean up H5F.close(fileId); } }
public static void PopulateChildrenObjects <T>(Hdf5Identifier _fileId, T _parentObject) where T : AbstractHdf5Object { ulong pos = 0; List <string> groupNames = new List <string>(); var id = H5G.open(_fileId.Value, _parentObject.Path.FullPath).ToId(); if (id.Value > 0) { ArrayList al = new ArrayList(); GCHandle hnd = GCHandle.Alloc(al); IntPtr op_data = (IntPtr)hnd; H5L.iterate(_parentObject.Id.Value, H5.index_t.NAME, H5.iter_order_t.NATIVE, ref pos, delegate(int _objectId, IntPtr _namePtr, ref H5L.info_t _info, IntPtr _data) { string objectName = Marshal.PtrToStringAnsi(_namePtr); groupNames.Add(objectName); return(0); }, op_data); hnd.Free(); H5G.close(id.Value); foreach (var groupName in groupNames) { Object hdf5Obj = GetObject(_fileId, _parentObject, groupName); if (hdf5Obj != null) { if (hdf5Obj is Hdf5Dataset) { var parent = _parentObject as IHasDatasets; if (parent != null) { parent.Datasets.Add(hdf5Obj as Hdf5Dataset); } } else if (hdf5Obj is Hdf5Group) { var parent = _parentObject as IHasGroups; if (parent != null) { parent.Groups.Add(hdf5Obj as Hdf5Group); } } } } } }
public void close(long gid) { try { H5G.close(gid); } catch (Exception ex) { Hdf5Utils.LogError?.Invoke($"close(): H5Gclose(gid {gid}): {ex}"); } }
public void H5GcloseTest1() { hid_t gid = H5G.create(m_v0_test_file, "A"); Assert.IsTrue(gid >= 0); Assert.IsTrue(H5G.close(gid) >= 0); gid = H5G.create(m_v2_test_file, "A"); Assert.IsTrue(gid >= 0); Assert.IsTrue(H5G.close(gid) >= 0); }
public void H5GopenTest1() { hid_t group = H5G.open(m_v0_class_file, "."); Assert.IsTrue(group >= 0); Assert.IsTrue(H5G.close(group) >= 0); group = H5G.open(m_v2_class_file, "."); Assert.IsTrue(group >= 0); Assert.IsTrue(H5G.close(group) >= 0); }