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")); }
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); }
public void FileEnumeration() { using var pfs = new PhysFS(""); pfs.Mount("./", "/", false); var effectiveFiles = Directory.GetFiles("./").Select(Path.GetFileName).ToArray(); Array.Sort(effectiveFiles); var enumeratedFiles = pfs.EnumerateFiles("/").ToArray(); Array.Sort(enumeratedFiles); enumeratedFiles.Should().BeEquivalentTo(effectiveFiles); }
void FileEnumeration() { using (var pfs = new PhysFS("")) { pfs.Mount("./", "/", false); var effectiveFiles = Directory.GetFiles("./").Select(x => Path.GetFileName(x)).ToArray(); Array.Sort(effectiveFiles); var enumeratedFiles = pfs.EnumerateFiles("/"); Array.Sort(enumeratedFiles); Assert.Equal(effectiveFiles, enumeratedFiles); } }
public void Mounting() { using var pfs = new PhysFS(""); pfs.GetSearchPath().Should().BeEmpty(); pfs.Mount("./", "/", false); pfs.GetSearchPath().Should().BeEquivalentTo(new string[] { "./" }); pfs.GetMountPoint("./").Should().Be("/"); pfs.IsDirectory("/").Should().BeTrue(); pfs.Mount("../", "foo", true); pfs.GetSearchPath().Should().BeEquivalentTo(new string[] { "./", "../" }); pfs.GetMountPoint("../").Should().Be("foo/"); pfs.IsDirectory("/foo").Should().BeTrue(); pfs.Mount("../../", "bar", false); pfs.GetSearchPath().Should().BeEquivalentTo(new string[] { "../../", "./", "../" }); pfs.GetMountPoint("../../").Should().Be("bar/"); pfs.IsDirectory("/bar").Should().BeTrue(); pfs.UnMount("../"); pfs.GetSearchPath().Should().BeEquivalentTo(new string[] { "../../", "./" }); }
void Mounting() { using (var pfs = new PhysFS("")) { Assert.Empty(pfs.GetSearchPath()); pfs.Mount("./", "/", false); Assert.Equal(new string[] { "./" }, pfs.GetSearchPath()); Assert.Equal("/", pfs.GetMountPoint("./")); Assert.True(pfs.IsDirectory("/")); pfs.Mount("../", "foo", true); Assert.Equal(new string[] { "./", "../", }, pfs.GetSearchPath()); Assert.Equal("foo/", pfs.GetMountPoint("../")); Assert.True(pfs.IsDirectory("/foo")); pfs.Mount("../../", "bar", false); Assert.Equal(new string[] { "../../", "./", "../", }, pfs.GetSearchPath()); Assert.Equal("bar/", pfs.GetMountPoint("../../")); Assert.True(pfs.IsDirectory("/bar")); pfs.RemoveFromSearchPath("../"); Assert.Equal(new string[] { "../../", "./", }, pfs.GetSearchPath()); } }
static bool Mount(string[] args) { if (args.Length < 3) { Console.WriteLine("Usage: mount <archive> <mntpoint> <append>"); return(false); } bool append; if (!bool.TryParse(args[2], out append)) { Console.WriteLine("append can only be true or false"); } physFS.Mount(args[0], args[1], append); return(true); }