mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Remove old SaveFsEntry file
This commit is contained in:
parent
f7b983ccb2
commit
5b764e487e
2 changed files with 22 additions and 120 deletions
|
@ -1,37 +0,0 @@
|
|||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Fs.Save
|
||||
{
|
||||
internal ref struct SaveEntryKey
|
||||
{
|
||||
public ReadOnlySpan<byte> Name;
|
||||
public int Parent;
|
||||
|
||||
public SaveEntryKey(ReadOnlySpan<byte> name, int parent)
|
||||
{
|
||||
Name = name;
|
||||
Parent = parent;
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x14)]
|
||||
public struct SaveFileInfo
|
||||
{
|
||||
public int StartBlock;
|
||||
public long Length;
|
||||
public long Reserved;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents the current position when enumerating a directory's contents.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x14)]
|
||||
public struct SaveFindPosition
|
||||
{
|
||||
/// <summary>The ID of the next directory to be enumerated.</summary>
|
||||
public int NextDirectory;
|
||||
/// <summary>The ID of the next file to be enumerated.</summary>
|
||||
public int NextFile;
|
||||
}
|
||||
}
|
|
@ -1,98 +1,37 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace LibHac.Fs.Save
|
||||
{
|
||||
[DebuggerDisplay("{" + nameof(FullPath) + "}")]
|
||||
public abstract class SaveFsEntry
|
||||
internal ref struct SaveEntryKey
|
||||
{
|
||||
public int ParentDirIndex { get; protected set; }
|
||||
public string Name { get; protected set; }
|
||||
public ReadOnlySpan<byte> Name;
|
||||
public int Parent;
|
||||
|
||||
public string FullPath { get; private set; }
|
||||
public SaveDirectoryEntry ParentDir { get; internal set; }
|
||||
|
||||
internal static void ResolveFilenames(IEnumerable<SaveFsEntry> entries)
|
||||
public SaveEntryKey(ReadOnlySpan<byte> name, int parent)
|
||||
{
|
||||
var list = new List<string>();
|
||||
var sb = new StringBuilder();
|
||||
string delimiter = "/";
|
||||
foreach (SaveFsEntry file in entries)
|
||||
{
|
||||
list.Add(file.Name);
|
||||
SaveDirectoryEntry dir = file.ParentDir;
|
||||
while (dir != null)
|
||||
{
|
||||
list.Add(delimiter);
|
||||
list.Add(dir.Name);
|
||||
dir = dir.ParentDir;
|
||||
}
|
||||
|
||||
for (int i = list.Count - 1; i >= 0; i--)
|
||||
{
|
||||
sb.Append(list[i]);
|
||||
}
|
||||
|
||||
file.FullPath = sb.Length == 0 ? delimiter : sb.ToString();
|
||||
list.Clear();
|
||||
sb.Clear();
|
||||
}
|
||||
Name = name;
|
||||
Parent = parent;
|
||||
}
|
||||
}
|
||||
|
||||
public class SaveFileEntry : SaveFsEntry
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x14)]
|
||||
public struct SaveFileInfo
|
||||
{
|
||||
public int NextSiblingIndex { get; }
|
||||
public int BlockIndex { get; }
|
||||
public long FileSize { get; }
|
||||
public long Field54 { get; }
|
||||
public int NextInChainIndex { get; }
|
||||
|
||||
public SaveFileEntry NextSibling { get; internal set; }
|
||||
public SaveFileEntry NextInChain { get; internal set; }
|
||||
|
||||
public SaveFileEntry(BinaryReader reader)
|
||||
{
|
||||
long start = reader.BaseStream.Position;
|
||||
ParentDirIndex = reader.ReadInt32();
|
||||
Name = reader.ReadUtf8Z(0x40);
|
||||
reader.BaseStream.Position = start + 0x44;
|
||||
|
||||
NextSiblingIndex = reader.ReadInt32();
|
||||
BlockIndex = reader.ReadInt32();
|
||||
FileSize = reader.ReadInt64();
|
||||
Field54 = reader.ReadInt64();
|
||||
NextInChainIndex = reader.ReadInt32();
|
||||
}
|
||||
public int StartBlock;
|
||||
public long Length;
|
||||
public long Reserved;
|
||||
}
|
||||
|
||||
public class SaveDirectoryEntry : SaveFsEntry
|
||||
/// <summary>
|
||||
/// Represents the current position when enumerating a directory's contents.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 0x14)]
|
||||
public struct SaveFindPosition
|
||||
{
|
||||
public int NextSiblingIndex { get; }
|
||||
public int FirstChildIndex { get; }
|
||||
public long FirstFileIndex { get; }
|
||||
public long Field54 { get; }
|
||||
public int NextInChainIndex { get; }
|
||||
|
||||
public SaveDirectoryEntry NextSibling { get; internal set; }
|
||||
public SaveDirectoryEntry FirstChild { get; internal set; }
|
||||
public SaveFileEntry FirstFile { get; internal set; }
|
||||
public SaveDirectoryEntry NextInChain { get; internal set; }
|
||||
|
||||
public SaveDirectoryEntry(BinaryReader reader)
|
||||
{
|
||||
long start = reader.BaseStream.Position;
|
||||
ParentDirIndex = reader.ReadInt32();
|
||||
Name = reader.ReadUtf8Z(0x40);
|
||||
reader.BaseStream.Position = start + 0x44;
|
||||
|
||||
NextSiblingIndex = reader.ReadInt32();
|
||||
FirstChildIndex = reader.ReadInt32();
|
||||
FirstFileIndex = reader.ReadInt64();
|
||||
Field54 = reader.ReadInt64();
|
||||
NextInChainIndex = reader.ReadInt32();
|
||||
}
|
||||
/// <summary>The ID of the next directory to be enumerated.</summary>
|
||||
public int NextDirectory;
|
||||
/// <summary>The ID of the next file to be enumerated.</summary>
|
||||
public int NextFile;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue