public static bool Test_Archiver() { PhysFS.Initialize(); TestArchiver archiver = new TestArchiver(); PhysFS.Instance.RegisterArchiver(archiver); PHYSFS_ArchiveInfo[] supportedArchiveTypes = PhysFS.Instance.SupportedArchiveTypes; #if PRINT_INFO foreach (PHYSFS_ArchiveInfo archiveInfo in supportedArchiveTypes) { Debug.WriteLine($" ext: {archiveInfo.Extension} | desc: {archiveInfo.Description} | author: {archiveInfo.Author} | url: {archiveInfo.Url} | sym links: {archiveInfo.SupportsSymlinks == 1}"); } #endif PhysFS.Instance.Mount("folder/hue file.xyz", mountPoint: "", appendToPath: true); ShowAllFilesAt("/"); ShowSearchPaths(); using (PhysFSStream stream = new PhysFSStream(PhysFSFile.OpenRead("file a"))) { byte[] buffer = new byte[stream.Length]; int bytesRead = stream.Read(buffer, 0, buffer.Length); string text = Encoding.UTF8.GetString(buffer); Debug.WriteLine($" File contents:\n{text}"); Debug.WriteLine($" Bytes Read: {bytesRead}"); } PhysFS.Deinitialize(); return(true); }
public static bool Test_PhysFSStreamWrite() { PhysFS.Initialize(); PhysFS.Instance.WriteDirectory = TestWriteDir; Debug.WriteLine($" Write Dir: {PhysFS.Instance.WriteDirectory}"); PhysFSFile file = PhysFSFile.OpenWrite("test-write-stream.txt"); using (PhysFSStream stream = new PhysFSStream(file)) { string text = "Just a PhysFSFileWrite test..."; byte[] textBytes = Encoding.UTF8.GetBytes(text); Debug.WriteLine($" Before writing, file length: {stream.Length}"); Debug.WriteLine(" Writing to file"); stream.Write(textBytes, 0, textBytes.Length); Debug.WriteLine($" After writing, file length: {stream.Length}"); } PhysFS.Deinitialize(); return(true); }
public static bool Test_ReadWriteBytes() { PhysFS.Initialize(); //PhysFS.Instance.WriteDirectory = TestFolder; PhysFS.Instance.Mount(TestFolder, mountPoint: "", appendToPath: true); string filename = "test.txt"; Debug.WriteLine($" Reading '{filename}' file"); PhysFSFile file = PhysFSFile.OpenRead(filename); using (PhysFSStream stream = new PhysFSStream(file)) { uint value = 0; for (int i = 0; i < 5; i++) { /* * if (stream.WriteULE16(60)) { * Debug.WriteLine(" Write to file"); * } else { * Debug.WriteLine(" Can't write to file"); * } */ if (stream.ReadULE32(ref value)) { Debug.WriteLine($" Read ULE 32: {value}"); } else { Debug.WriteLine(" Can't Read ULE 32"); } } Debug.WriteLine($" Current Stream Pos: {stream.Position}"); } PhysFS.Deinitialize(); return(true); }
public static bool Test_PhysFSStreamRead() { PhysFS.Initialize(); PhysFS.Instance.Mount(TestFolder, mountPoint: "", appendToPath: true); Debug.WriteLine($" Reading 'just a text.txt' file"); PhysFSFile file = PhysFSFile.OpenRead("test.txt"); using (PhysFSStream stream = new PhysFSStream(file)) { byte[] buffer = new byte[stream.Length]; int bytesRead = stream.Read(buffer, 0, buffer.Length); string text = Encoding.UTF8.GetString(buffer); //Debug.WriteLine($" File contents:\n{text}"); Debug.WriteLine($" Bytes Read: {bytesRead}"); } PhysFS.Deinitialize(); return(true); }