- tweak: file managment

This commit is contained in:
2025-01-08 18:00:06 +03:00
parent b16b21e954
commit e5ed27f72d
20 changed files with 539 additions and 161 deletions

View File

@@ -51,15 +51,24 @@ public class FileService
return new FileApi(Path.Join(RootPath, path));
}
public ZipFileApi OpenZip(string path, IFileApi fileApi)
public ZipFileApi? OpenZip(string path, IFileApi fileApi)
{
if (!fileApi.TryOpen(path, out var zipStream))
return null;
Stream? zipStream = null;
try
{
if (!fileApi.TryOpen(path, out zipStream))
return null;
var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Read);
var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Read);
var prefix = "";
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) prefix = "Space Station 14.app/Contents/Resources/";
return new ZipFileApi(zipArchive, prefix);
var prefix = "";
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) prefix = "Space Station 14.app/Contents/Resources/";
return new ZipFileApi(zipArchive, prefix);
}
catch (Exception e)
{
zipStream?.Dispose();
throw;
}
}
}