public Dictionary <string, string> GetAttributes() { if (!_readFileAttrs) { Dictionary <string, string> cacheAttrs = GlobalFileAttributeCache.GetFileAttributes(_fname); if (cacheAttrs == null) { _readFileAttrs = true; int id = HDF4Helper.SDstart(_fname, HDF4Helper.AccessCodes.DFACC_READ); try { int dsCount = 0; int attCount = 0; HDF4Helper.SDfileinfo(id, out dsCount, out attCount); if (attCount == 0) { return(null); } _fileAttrs = GetAttributes(id, attCount); GlobalFileAttributeCache.SetFileAttributes(_fname, _fileAttrs); } finally { HDF4Helper.SDend(id); } } else { _fileAttrs = cacheAttrs; } } return(_fileAttrs); }
public string GetAttributeValue(string datasetName, string attributeName) { int id = HDF4Helper.SDstart(_fname, HDF4Helper.AccessCodes.DFACC_READ); try { int dsIndex = HDF4Helper.SDnametoindex(id, datasetName); int dsObjId = HDF4Helper.SDselect(id, dsIndex); int attIndex = HDF4Helper.SDfindattr(dsObjId, attributeName); return(ReadAttribute(dsObjId, attIndex)); } finally { HDF4Helper.SDend(id); } }
private string[] GetALLDataset() { int sd_id = HDF4Helper.SDstart(_fname, HDF4Helper.AccessCodes.DFACC_READ); try { int num_datasets = 0; int num_global_attrs = 0; HDF4Helper.SDfileinfo(sd_id, out num_datasets, out num_global_attrs); string[] dsNames = ReadSDinfo(sd_id, num_datasets); return(dsNames); } finally { HDF4Helper.SDend(sd_id); } }
private static string[] ReadSDinfo(int sd_id, int num_datasets) { string[] dsNames = new string[num_datasets]; for (int dsIndex = 0; dsIndex < num_datasets; dsIndex++) { int sds_id = HDF4Helper.SDselect(sd_id, dsIndex); try { StringBuilder sds_name = new StringBuilder(256); int rank; int[] dimsizes = new int[256]; GeoDo.HDF4.HDF4Helper.DataTypeDefinitions data_type; int num_attrs; HDF4Helper.SDgetinfo(sds_id, sds_name, out rank, dimsizes, out data_type, out num_attrs); dsNames[dsIndex] = sds_name.ToString(); } finally { HDF4Helper.SDend(sds_id); } } return(dsNames); }