Apply meta manipulation and load the corresponding files when encountering meta files.

This commit is contained in:
Ottermandias 2021-03-05 15:56:36 +01:00
parent 739627b7c2
commit db5ce7a2e4
5 changed files with 234 additions and 3 deletions

31
Penumbra/Util/TempFile.cs Normal file
View file

@ -0,0 +1,31 @@
using System.IO;
namespace Penumbra.Util
{
public static class TempFile
{
public static FileInfo TempFileName( DirectoryInfo baseDir )
{
const uint maxTries = 15;
for( var i = 0; i < maxTries; ++i )
{
var name = Path.GetRandomFileName();
var path = new FileInfo( Path.Combine( baseDir.FullName, name ) );
if( !path.Exists )
{
return path;
}
}
throw new IOException();
}
public static FileInfo WriteNew( DirectoryInfo baseDir, byte[] data )
{
var fileName = TempFileName( baseDir );
File.WriteAllBytes( fileName.FullName, data );
fileName.Refresh();
return fileName;
}
}
}