Ejemplo n.º 1
0
        public void DeleteDirectory()
        {
            if (!Directory.Exists(Default.Directory))
            {
                Directory.CreateDirectory(Default.Directory);
            }

            UVDirectory.Delete(Default.Directory, (e) => {
                Assert.IsNull(e);
            });

            Loop.Default.Run();
        }
Ejemplo n.º 2
0
        public void CreateDirectory()
        {
            if (Directory.Exists(Default.Directory))
            {
                Directory.Delete(Default.Directory, true);
            }

            UVDirectory.Create(Default.Directory, 511, (e) => {
                Assert.IsNull(e);
                Assert.IsTrue(Directory.Exists(Default.Directory));
                Directory.Delete(Default.Directory);
            });

            Loop.Default.Run();
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        public void RenameDirectory()
        {
            if (!Directory.Exists(Default.Directory))
            {
                Directory.CreateDirectory(Default.Directory);
            }

            UVDirectory.Rename(Default.Directory, Default.SecondDirectory, (e) => {
                Assert.IsNull(e);
                Assert.IsFalse(Directory.Exists(Default.Directory));
                Assert.IsTrue(Directory.Exists(Default.SecondDirectory));
                Directory.Delete(Default.SecondDirectory);
            });

            Loop.Default.Run();
        }
Ejemplo n.º 5
0
        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();
        }
Ejemplo n.º 6
0
        public static Task Rename(Loop loop, string path, string newPath)
        {
            var tcs = new TaskCompletionSource <object>();

            try {
                UVDirectory.Rename(loop, path, newPath, (e) => {
                    if (e == null)
                    {
                        tcs.SetResult(null);
                    }
                    else
                    {
                        tcs.SetException(e);
                    }
                });
            } catch (Exception e) {
                tcs.SetException(e);
            }
            return(tcs.Task);
        }
Ejemplo n.º 7
0
        public static Task Create(Loop loop, string name, int mode)
        {
            var tcs = new TaskCompletionSource <object>();

            try {
                UVDirectory.Create(loop, name, mode, (e) => {
                    if (e == null)
                    {
                        tcs.SetResult(null);
                    }
                    else
                    {
                        tcs.SetException(e);
                    }
                });
            } catch (Exception e) {
                tcs.SetException(e);
            }
            return(tcs.Task);
        }
Ejemplo n.º 8
0
        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);
        }