port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ionic.Zip;
using System.IO;
namespace Aiwaz.Common
{
public class FileSystem : IDisposable
{
private ZipFile zipFile;
public FileSystem()
{
if (File.Exists("data.pak"))
{
zipFile = ZipFile.Read("data.pak");
}
}
~FileSystem()
{
this.Dispose();
}
public Stream Open(string argFileName)
{
if (File.Exists(argFileName))
{
Stream fileStream = new FileStream(argFileName, FileMode.Open);
if (fileStream != null)
return fileStream;
}
if (zipFile != null)
{
var file = zipFile[argFileName];
if (file != null)
{
Stream outputStream = new MemoryStream();
file.Extract(outputStream);
return outputStream;
}
}
throw new FileNotFoundException(argFileName);
}
#region IDisposable Members
public void Dispose()
{
if (zipFile != null)
{
zipFile.Dispose();
}
}
#endregion
}
public static class BinaryReaderExtensions
{
public static string ReadNullTerminatedString(this BinaryReader reader)
{
string result = string.Empty;
char readChar = '\0';
do
{
readChar = reader.ReadChar();
if (readChar != '\0')
result += readChar;
}
while (readChar != '\0');
return result;
}
}
}