Exemplo n.º 1
0
        public void FileManipulation()
        {
            using var pfs = new PhysFS("");
            pfs.SetWriteDir("./");
            pfs.Mount("./", "/", true);

            using (var sw = new StreamWriter(pfs.OpenWrite("foo")))
            {
                sw.Write("hello, world! èòàùã こんにちは世界 你好世界");
            }

            Assert.True(File.Exists("./foo"));

            var fileContent = File.ReadAllText("./foo");

            using (var sr = new StreamReader(pfs.OpenRead("foo")))
            {
                sr.ReadToEnd().Should().BeEquivalentTo(fileContent);
            }

            using (var sw = new StreamWriter(pfs.OpenAppend("foo")))
            {
                sw.Write("foo");
            }
            File.ReadAllText("./foo").Should().BeEquivalentTo(fileContent + "foo");

            pfs.Delete("foo");
            Assert.False(File.Exists("./foo"));
        }
 static bool Delete(string[] args)
 {
     if (args.Length < 1)
     {
         Console.WriteLine("Usage: delete <dir>");
         return(false);
     }
     physFS.Delete(args[0]);
     return(true);
 }
Exemplo n.º 3
0
        public void DirectoryManipulation()
        {
            using var pfs = new PhysFS("");
            pfs.SetWriteDir("./");
            pfs.GetWriteDir().Should().Be("./");

            pfs.CreateDirectory("hello");
            Directory.Exists("./hello").Should().BeTrue();

            pfs.Delete("hello");
            Directory.Exists("./hello").Should().BeFalse();
        }
        void DirectoryManipulation()
        {
            using (var pfs = new PhysFS(""))
            {
                pfs.SetWriteDir("./");
                Assert.Equal("./", pfs.GetWriteDir());

                pfs.Mkdir("hello");
                Assert.True(Directory.Exists("./hello"));

                pfs.Delete("hello");
                Assert.False(Directory.Exists("./hello"));
            }
        }