mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2025-02-09 13:14:46 +01:00
Fix AesXtsFileSystem
This commit is contained in:
parent
ea8cc33003
commit
4ff12ec21b
@ -107,13 +107,15 @@ namespace LibHac.FsSystem
|
||||
Result rc = BaseFile.Write(0, Header.ToBytes(false));
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
return BaseStorage.SetSize(size);
|
||||
return BaseStorage.SetSize(Util.AlignUp(size, 0x10));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
BaseStorage.Flush();
|
||||
BaseStorage.Dispose();
|
||||
BaseFile?.Dispose();
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ namespace LibHac.FsSystem
|
||||
|
||||
private void RenameDirectoryImpl(string srcDir, string dstDir, bool doRollback)
|
||||
{
|
||||
foreach (DirectoryEntryEx entry in this.EnumerateEntries(srcDir, "*"))
|
||||
foreach (DirectoryEntryEx entry in this.EnumerateEntries(dstDir, "*"))
|
||||
{
|
||||
string subSrcPath = $"{srcDir}/{entry.Name}";
|
||||
string subDstPath = $"{dstDir}/{entry.Name}";
|
||||
@ -185,7 +185,8 @@ namespace LibHac.FsSystem
|
||||
|
||||
AesXtsFileHeader header = ReadXtsHeader(oldPath, oldPath);
|
||||
|
||||
BaseFileSystem.RenameFile(oldPath, newPath);
|
||||
Result rc = BaseFileSystem.RenameFile(oldPath, newPath);
|
||||
if (rc.IsFailure()) return rc;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -109,13 +109,20 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
||||
|
||||
fs.CreateFile("/file", 100, CreateFileOptions.None);
|
||||
|
||||
// The contents of a created file are undefined, so zero the file
|
||||
fs.OpenFile(out IFile file, "/file", OpenMode.Write);
|
||||
using (file)
|
||||
{
|
||||
file.Write(0, new byte[100], WriteOption.None);
|
||||
}
|
||||
|
||||
var bufferExpected = new byte[200];
|
||||
bufferExpected.AsSpan(10).Fill(0xCC);
|
||||
|
||||
var buffer = new byte[200];
|
||||
buffer.AsSpan().Fill(0xCC);
|
||||
|
||||
fs.OpenFile(out IFile file, "/file", OpenMode.Read);
|
||||
fs.OpenFile(out file, "/file", OpenMode.Read);
|
||||
using (file)
|
||||
{
|
||||
Assert.True(file.Read(out _, 90, buffer, ReadOption.None).IsSuccess());
|
||||
|
@ -147,7 +147,10 @@ namespace LibHac.Tests.Fs.IFileSystemTestBase
|
||||
fs.OpenFile(out IFile file, "/file", OpenMode.All);
|
||||
using (file)
|
||||
{
|
||||
file.Write(15, writeBuffer, WriteOption.None).IsSuccess();
|
||||
Assert.True(file.Write(15, writeBuffer, WriteOption.None).IsSuccess());
|
||||
|
||||
// Unwritten portions of new files are undefined, so write to the other portions
|
||||
file.Write(0, new byte[15], WriteOption.None);
|
||||
}
|
||||
|
||||
var readBuffer = new byte[25];
|
||||
|
Loading…
x
Reference in New Issue
Block a user