public void ReadEmptyDirectory() { if (!Directory.Exists(Default.Directory)) { Directory.CreateDirectory(Default.Directory); } UVDirectory.Read(Default.Directory, (e, list) => { Assert.IsNull(e); Assert.IsNotNull(list); Assert.AreEqual(list.Length, 0); Directory.Delete(Default.Directory); }); Loop.Default.Run(); }
public void ReadNotEmptyDirectory() { Directory.CreateDirectory(Default.Directory); Directory.CreateDirectory(Path.Combine(Default.Directory, "dir")); File.CreateText(Path.Combine(Default.Directory, "file")).Close(); UVDirectory.Read(Default.Directory, (e, list) => { Assert.IsNull(e); Assert.IsNotNull(list); Assert.AreEqual(list.Length, 2); Assert.IsTrue(list.Contains("dir")); Assert.IsTrue(list.Contains("file")); Directory.Delete(Default.Directory, true); }); Loop.Default.Run(); }
public static Task <string[]> Read(this Loop loop, string path) { var tcs = new TaskCompletionSource <string[]>(); try { UVDirectory.Read(loop, path, (e, dirs) => { if (e == null) { tcs.SetResult(dirs); } else { tcs.SetException(e); } }); } catch (Exception e) { tcs.SetException(e); } return(tcs.Task); }