mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
Redirect references from TemporaryFileStorage to LocalFileSystem
Related: #1581
This commit is contained in:
parent
98759280e0
commit
9793a943a6
@ -36,7 +36,7 @@ public partial class FileSystem
|
|||||||
|
|
||||||
public virtual void Delete(string path) => throw new NotSupportedException();
|
public virtual void Delete(string path) => throw new NotSupportedException();
|
||||||
|
|
||||||
public string CreateTemporaryFolder()
|
public string CreateTemporary()
|
||||||
{
|
{
|
||||||
string path = Path.Join(Parent.TemporaryDirectory, GetRandomString()[0..8]);
|
string path = Path.Join(Parent.TemporaryDirectory, GetRandomString()[0..8]);
|
||||||
Directory.Create(path);
|
Directory.Create(path);
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
using AssetRipper.IO.Files.Utils;
|
namespace AssetRipper.IO.Files.Streams.Smart;
|
||||||
|
|
||||||
namespace AssetRipper.IO.Files.Streams.Smart;
|
|
||||||
|
|
||||||
public sealed partial class SmartStream : Stream
|
public sealed partial class SmartStream : Stream
|
||||||
{
|
{
|
||||||
@ -33,7 +31,7 @@ public sealed partial class SmartStream : Stream
|
|||||||
|
|
||||||
public static SmartStream CreateTemp()
|
public static SmartStream CreateTemp()
|
||||||
{
|
{
|
||||||
string tempFile = TemporaryFileStorage.CreateTemporaryFile();
|
string tempFile = LocalFileSystem.Instance.File.CreateTemporary();
|
||||||
return new SmartStream(new FileStream(tempFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.DeleteOnClose));
|
return new SmartStream(new FileStream(tempFile, FileMode.Open, FileAccess.ReadWrite, FileShare.None, 4096, FileOptions.DeleteOnClose));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
namespace AssetRipper.IO.Files.Utils;
|
|
||||||
|
|
||||||
public static class TemporaryFileStorage
|
|
||||||
{
|
|
||||||
private static string ExecutingDirectory => AppContext.BaseDirectory;
|
|
||||||
|
|
||||||
public static string LocalTemporaryDirectory { get; } = Path.Join(ExecutingDirectory, "temp", GetRandomString()[0..4]);
|
|
||||||
|
|
||||||
public static string TemporaryDirectory
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrWhiteSpace(value))
|
|
||||||
{
|
|
||||||
field = Path.GetFullPath(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} = LocalTemporaryDirectory;
|
|
||||||
|
|
||||||
public static void DeleteTemporaryDirectory()
|
|
||||||
{
|
|
||||||
if (Directory.Exists(TemporaryDirectory))
|
|
||||||
{
|
|
||||||
Directory.Delete(TemporaryDirectory, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetRandomString() => Guid.NewGuid().ToString();
|
|
||||||
|
|
||||||
public static string CreateTemporaryFolder()
|
|
||||||
{
|
|
||||||
string path = Path.Join(TemporaryDirectory, GetRandomString()[0..8]);
|
|
||||||
Directory.CreateDirectory(path);
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string CreateTemporaryFile()
|
|
||||||
{
|
|
||||||
Directory.CreateDirectory(TemporaryDirectory);
|
|
||||||
string path = Path.Join(TemporaryDirectory, GetRandomString());
|
|
||||||
File.Create(path).Dispose();
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,5 +1,5 @@
|
|||||||
using AssetRipper.Import.Logging;
|
using AssetRipper.Import.Logging;
|
||||||
using AssetRipper.IO.Files.Utils;
|
using AssetRipper.IO.Files;
|
||||||
using ICSharpCode.SharpZipLib.Zip;
|
using ICSharpCode.SharpZipLib.Zip;
|
||||||
|
|
||||||
namespace AssetRipper.Import.Structure;
|
namespace AssetRipper.Import.Structure;
|
||||||
@ -52,7 +52,7 @@ public static class ZipExtractor
|
|||||||
return zipFilePath;
|
return zipFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
string outputDirectory = TemporaryFileStorage.CreateTemporaryFolder();
|
string outputDirectory = LocalFileSystem.Instance.Directory.CreateTemporary();
|
||||||
DecompressZipArchive(zipFilePath, outputDirectory);
|
DecompressZipArchive(zipFilePath, outputDirectory);
|
||||||
return outputDirectory;
|
return outputDirectory;
|
||||||
}
|
}
|
||||||
@ -64,8 +64,8 @@ public static class ZipExtractor
|
|||||||
return xapkFilePath;
|
return xapkFilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
string intermediateDirectory = TemporaryFileStorage.CreateTemporaryFolder();
|
string intermediateDirectory = LocalFileSystem.Instance.Directory.CreateTemporary();
|
||||||
string outputDirectory = TemporaryFileStorage.CreateTemporaryFolder();
|
string outputDirectory = LocalFileSystem.Instance.Directory.CreateTemporary();
|
||||||
DecompressZipArchive(xapkFilePath, intermediateDirectory);
|
DecompressZipArchive(xapkFilePath, intermediateDirectory);
|
||||||
foreach (string filePath in Directory.GetFiles(intermediateDirectory))
|
foreach (string filePath in Directory.GetFiles(intermediateDirectory))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user