public void H5Fis_hdf5Test2() { Assert.IsTrue(H5F.is_hdf5("") < 0); string fname = Path.GetTempFileName(); Assert.IsTrue(H5F.is_hdf5(fname) == 0); File.Delete(fname); }
/// <summary> /// Check if the file at `path` is a readable HDF5 file. /// </summary> /// <remarks> /// Throws a `FileNotFoundException` if file does not exist. /// <remarks> public static bool IsReadable(string path) { if (!File.Exists(path)) { throw new FileNotFoundException(path); } return(H5F.is_hdf5(path) > 0); }
public void H5Fis_hdf5Test1() { string fname = Path.GetTempFileName(); hid_t file = H5F.create(fname, H5F.ACC_TRUNC); Assert.IsTrue(file >= 0); Assert.IsTrue(H5F.close(file) >= 0); Assert.IsTrue(H5F.is_hdf5(fname) > 0); File.Delete(fname); }
public static bool IsHdf5File(string filePath, bool failIfNotExists = false) { if (string.IsNullOrEmpty(filePath)) { throw new ArgumentException("filePath"); } if (!failIfNotExists && !File.Exists(filePath)) { return(false); } return(htri_t_to_bool(H5F.is_hdf5(filePath), "H5F.is_hdf5")); }
public void H5TSforeachTest1() { // run only if we have a thread-safe build of the library hbool_t flag = 0; Assert.IsTrue(H5.is_library_threadsafe(ref flag) >= 0); if (flag > 0) { List <string> ls = new List <string>(); for (int i = 0; i < NUM_FILES; ++i) { ls.Add(Path.GetTempFileName()); } var totalLength = 0; Parallel.ForEach <string, TaskLocals> (ls, () => { TaskLocals tl = new TaskLocals(); tl.handle = -1; tl.runningLength = 0; return(tl); }, (name, loop, taskLocals) => { // handle is "thread-local" taskLocals.handle = H5F.create(name, H5F.ACC_TRUNC); Assert.IsTrue(H5F.close(taskLocals.handle) >= 0); Assert.IsTrue(H5F.is_hdf5(name) > 0); File.Delete(name); taskLocals.handle = -1; taskLocals.runningLength += name.Length; return(taskLocals); }, (taskLocals) => { Interlocked.Add(ref totalLength, taskLocals.runningLength); } ); Assert.IsTrue(totalLength > NUM_FILES); } }
public HDF5GroupObject open(string file) { if (H5F.is_hdf5(file)) { int result = H5.Open(); if (result < 0) { Console.WriteLine("can't open the file!"); } // get fildID. H5FileId fileID = H5F.open(file, H5F.OpenMode.ACC_RDONLY); //get groupid H5GroupId rootid = H5G.open(fileID, "/"); HDF5GroupObject hdf5Object = new HDF5GroupObject(); createHD5GroupObject(rootid, "/", ref hdf5Object); return(hdf5Object); } else { Console.WriteLine("this is not HDF5 file! please try open hdf5 file again."); return(null); } }