static bool Cat(string[] args) { if (args.Length < 1) { Console.WriteLine("Usage: cat <file>"); return(false); } using (var stream = physFS.OpenRead(args[0])) using (var reader = new System.IO.StreamReader(stream)) { Console.WriteLine(reader.ReadToEnd()); } return(true); }
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 T DeserializeJsonFile <T>(PhysFS physFSInstance, string filepath) where T : MainGameObject, new() { var filedata = physFSInstance.OpenRead(filepath); var jsonObject = DeserializeJsonFileData <T>(filedata); if (jsonObject == null) { return(new T { Name = "null" }); } return(jsonObject); }