Ejemplo n.º 1
0
        public void H5Eget_autoTest1()
        {
            H5E.auto_t cb          = null;
            IntPtr     client_data = IntPtr.Zero;

            Assert.IsTrue(
                H5E.get_auto(H5E.DEFAULT, ref cb, ref client_data) >= 0);
        }
Ejemplo n.º 2
0
        public static void SuppressErrors(Action action)
        {
            H5E.auto_t func;
            IntPtr     clientData;

            func       = null;
            clientData = IntPtr.Zero;

            H5E.get_auto(H5E.DEFAULT, ref func, ref clientData);
            H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero);

            action.Invoke();

            H5E.set_auto(H5E.DEFAULT, func, clientData);
        }
Ejemplo n.º 3
0
        public static List <(string Path, string Name)> GetPathSet(long locationId, int maxDepth, bool includeGroups, bool includeDatasets)
        {
            ulong idx;
            List <(string Path, string Name)> datasetPathSet;

            H5E.auto_t func;
            IntPtr     clientData;

            idx            = default;
            datasetPathSet = new List <(string Path, string Name)>();
            func           = null;
            clientData     = IntPtr.Zero;

            H5E.get_auto(H5E.DEFAULT, ref func, ref clientData);
            H5E.set_auto(H5E.DEFAULT, null, IntPtr.Zero);
            H5L.iterate(locationId, H5.index_t.NAME, H5.iter_order_t.INC, ref idx, Callback, Marshal.StringToHGlobalAnsi("/"));
            H5E.set_auto(H5E.DEFAULT, func, clientData);

            return(datasetPathSet);

            int Callback(long groupId, IntPtr intPtrName, ref H5L.info_t info, IntPtr intPtrUserData)
            {
                long datasetId = -1;

                ulong idx2 = default;
                int   level;

                string name;
                string userData;

                H5O.type_t objectType;

                name     = Marshal.PtrToStringAnsi(intPtrName);
                userData = Marshal.PtrToStringAnsi(intPtrUserData);
                level    = userData.Split("/".ToArray()).Count();

                // this is necessary, since H5Oget_info_by_name is slow because it wants verbose object header data
                // and H5G_loc_info is not directly accessible
                // only chance is to modify source code (H5Oget_info_by_name) or use V2 B-tree
                datasetId = H5D.open(groupId, name);

                if (datasetId > -1)
                {
                    objectType = H5O.type_t.DATASET;
                }
                else
                {
                    groupId = H5G.open(groupId, name);

                    if (groupId > -1)
                    {
                        objectType = H5O.type_t.GROUP;
                    }
                    else
                    {
                        objectType = H5O.type_t.UNKNOWN;
                    }
                }

                switch (objectType)
                {
                case H5O.type_t.GROUP:

                    if (level <= maxDepth)
                    {
                        H5L.iterate(groupId, H5.index_t.NAME, H5.iter_order_t.INC, ref idx2, Callback, Marshal.StringToHGlobalAnsi(GeneralHelper.CombinePath(userData, name)));

                        if (includeGroups)
                        {
                            datasetPathSet.Add((userData, name));
                        }

                        H5G.close(groupId);
                    }

                    break;

                case H5O.type_t.DATASET:

                    if (includeDatasets)
                    {
                        datasetPathSet.Add((userData, name));
                    }

                    H5D.close(datasetId);
                    break;

                default:
                    break;
                }

                return(0);
            }
        }