Exemple #1
0
        public void Load(string filename, DFACC dfacc)
        {
            sw.Start();
            _filename = filename;
            int file_id, sd_id;

            try
            {
                _fileOpenState = false;
                file_id        = HDF4API.Hopen(filename, DFACC.DFACC_READ, 0);
                HDF4API.Vstart(file_id);
                //_gr_id = HDF4API.GRstart(file_id);
            }
            catch
            {
                string strErrInfo = "HDF4打开文件异常";
                throw new Exception(strErrInfo);
            }
            _fileOpenState = true;
            sd_id          = HDF4Helper.SDstart(filename, HDF4Helper.AccessCodes.DFACC_READ);
            if (sd_id == -1)
            {
                //打开失败
            }
            _file_id = file_id;
            _sd_id   = sd_id;
            sw.Stop();
            em = sw.ElapsedMilliseconds;
            Console.WriteLine("打开" + em + "毫秒");
            // load the file hierarchy
            getRootGroup();
        }
Exemple #2
0
        public HObject Get(string path)
        {
            //if (objList == null) {
            //    objList = new Vector();
            //}

            if (string.IsNullOrWhiteSpace(path))
            {
                return(null);
            }
            path = path.Replace('\\', '/');
            if (!path.StartsWith("/"))
            {
                path = "/" + path;
            }
            string name = null, pPath = null;
            bool   isRoot = false;

            if (path.Equals("/"))
            {
                name   = "/"; // the root
                isRoot = true;
            }
            else
            {
                if (path.EndsWith("/"))
                {
                    path = path.Substring(0, path.Length - 2);
                }
                int idx = path.LastIndexOf('/');
                name = path.Substring(idx + 1);
                if (idx == 0)
                {
                    pPath = "/";
                }
                else
                {
                    pPath = path.Substring(0, idx);
                }
            }
            HObject obj        = null;
            bool    isReadOnly = false;

            if (_file_id < 0)
            {
                _file_id = HDF4API.Hopen(_filename, DFACC.DFACC_WRITE, 0);
                if (_file_id < 0)
                {
                    isReadOnly = true;
                    _file_id   = HDF4API.Hopen(_filename, DFACC.DFACC_READ, 0);
                }
                HDF4API.Vstart(_file_id);
                //grid = HDF4API.GRstart(_file_id);
                _sd_id = HDF4Helper.SDstart(_filename, HDF4Helper.AccessCodes.DFACC_READ);
            }
            //if (isRoot)
            //{
            //    obj = getRootGroup();
            //}
            //else
            //{
            //    obj = getAttachedObject(pPath, name);
            //}
            return(obj);
        }