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 SetWriteDirectory(string[] args)
 {
     if (args.Length < 1)
     {
         Console.WriteLine("Usage: setwritedir <dir>");
         return(false);
     }
     physFS.SetWriteDir(args[0]);
     return(true);
 }
        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"));
            }
        }
Example #5
0
        public void SetupFileSystems()
        {
            var seporator    = filesystemLink.GetDirSeparator();
            var BaseDataDir  = Environment.CurrentDirectory + seporator + "GameData";
            var UnPackedData = BaseDataDir + seporator + "Unpacked";
            var Packed       = BaseDataDir + seporator + "Packed";
            var saveData     = BaseDataDir + seporator + "SaveData";

            filesystemLink.PermitSymbolicLinks(true);
            Directory.CreateDirectory(BaseDataDir);
            Directory.CreateDirectory(UnPackedData);
            Directory.CreateDirectory(Packed);
            Directory.CreateDirectory(saveData);
            filesystemLink.SetWriteDir(saveData);
            filesystemLink.Mount(UnPackedData, "", true);
            SetupPackedData(Packed);
        }