mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2025-02-09 13:14:46 +01:00
Do some code formatting in LibHac
This commit is contained in:
parent
ef71eedc05
commit
80d52dd499
@ -58,5 +58,6 @@ public struct KeyBlob
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator ReadOnlySpan<byte>(in KeyBlob value) => SpanHelpers.AsReadOnlyByteSpan(in value);
|
||||
|
||||
public readonly override string ToString() => BytesRo.ToHexString();
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Type = LibHac.Common.Keys.KeyInfo.KeyType;
|
||||
|
||||
namespace LibHac.Common.Keys;
|
||||
|
@ -146,8 +146,7 @@ public static class ExternalKeyReader
|
||||
/// <param name="keyList">A list of all the keys that will be loaded into the key set.
|
||||
/// <see cref="DefaultKeySet.CreateKeyList"/> will create a list containing all loadable keys.</param>
|
||||
/// <param name="logger">An optional logger that key-parsing errors will be written to.</param>
|
||||
public static void ReadMainKeys(KeySet keySet, Stream reader, List<KeyInfo> keyList,
|
||||
IProgressReport logger = null)
|
||||
public static void ReadMainKeys(KeySet keySet, Stream reader, List<KeyInfo> keyList, IProgressReport logger = null)
|
||||
{
|
||||
if (reader == null) return;
|
||||
|
||||
|
@ -5,7 +5,6 @@ using System.Text;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Spl;
|
||||
using LibHac.Util;
|
||||
|
||||
using Type = LibHac.Common.Keys.KeyInfo.KeyType;
|
||||
using RangeType = LibHac.Common.Keys.KeyInfo.KeyRangeType;
|
||||
|
||||
@ -150,6 +149,7 @@ public static class ExternalKeyWriter
|
||||
PrintKeys(keySet, sb, DefaultKeySet.CreateKeyList(), Type.Common | Type.Seed | Type.DifferentDev, true);
|
||||
keySet.SetMode(KeySet.Mode.Prod);
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
@ -34,18 +34,14 @@ public class MissingKeyException : LibHacException
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MissingKeyException"/> class.
|
||||
/// </summary>
|
||||
public MissingKeyException()
|
||||
{
|
||||
}
|
||||
public MissingKeyException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MissingKeyException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
public MissingKeyException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MissingKeyException"/> class with a specified error message
|
||||
@ -54,9 +50,7 @@ public class MissingKeyException : LibHacException
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
|
||||
public MissingKeyException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
: base(message, innerException) { }
|
||||
|
||||
public override string Message
|
||||
{
|
||||
|
@ -10,18 +10,14 @@ public class LibHacException : Exception
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibHacException"/> class.
|
||||
/// </summary>
|
||||
public LibHacException()
|
||||
{
|
||||
}
|
||||
public LibHacException() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibHacException"/> class with a specified error message.
|
||||
/// </summary>
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
public LibHacException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
: base(message) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LibHacException"/> class with a specified error message
|
||||
@ -30,7 +26,5 @@ public class LibHacException : Exception
|
||||
/// <param name="message">The error message that explains the reason for the exception.</param>
|
||||
/// <param name="innerException">The exception that is the cause of the current exception, or a null reference if no inner exception is specified.</param>
|
||||
public LibHacException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
: base(message, innerException) { }
|
||||
}
|
@ -110,6 +110,7 @@ public class ProgressBar : IDisposable, IProgressReport
|
||||
int progressBlockCount = (int)Math.Min(progress * BlockCount, BlockCount);
|
||||
text = $"[{new string('#', progressBlockCount)}{new string('-', BlockCount - progressBlockCount)}] {_progress}/{_total} {progress:P1} {Animation[_animationIndex++ % Animation.Length]}{speed}";
|
||||
}
|
||||
|
||||
UpdateText(text);
|
||||
|
||||
ResetTimer();
|
||||
|
@ -35,9 +35,7 @@ public readonly ref struct Ref<T>
|
||||
/// <param name="pointer">The pointer to the target value.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe Ref(void* pointer)
|
||||
: this(ref Unsafe.AsRef<T>(pointer))
|
||||
{
|
||||
}
|
||||
: this(ref Unsafe.AsRef<T>(pointer)) { }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <typeparamref name="T"/> reference represented by the current <see cref="Ref{T}"/> instance.
|
||||
@ -97,9 +95,7 @@ public readonly ref struct ReadOnlyRef<T>
|
||||
/// <param name="pointer">The pointer to the target value.</param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe ReadOnlyRef(void* pointer)
|
||||
: this(in Unsafe.AsRef<T>(pointer))
|
||||
{
|
||||
}
|
||||
: this(in Unsafe.AsRef<T>(pointer)) { }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <typeparamref name="T"/> reference represented by the current <see cref="Ref{T}"/> instance.
|
||||
|
@ -230,6 +230,7 @@ public static class Utilities
|
||||
{
|
||||
return bytes.ToString("0 B"); // Byte
|
||||
}
|
||||
|
||||
// Divide by 1024 to get fractional value
|
||||
readable = readable / 1024;
|
||||
// Return formatted number with suffix
|
||||
|
@ -142,8 +142,7 @@ public static class Rsa
|
||||
{
|
||||
rng.NextBytes(rndBuf);
|
||||
g = GetBigInteger(rndBuf);
|
||||
}
|
||||
while (g >= n);
|
||||
} while (g >= n);
|
||||
|
||||
y = BigInteger.ModPow(g, r, n);
|
||||
|
||||
|
@ -492,7 +492,6 @@ namespace LibHac.Fs.Impl
|
||||
.Append(LogLineEnd);
|
||||
|
||||
OutputAccessLogImpl(fs, new U8Span(sb.Buffer));
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using System;
|
||||
|
||||
using Buffer = LibHac.Mem.Buffer;
|
||||
using CacheHandle = System.UInt64;
|
||||
|
||||
|
@ -27,6 +27,6 @@ internal static class CommonPaths
|
||||
public static ReadOnlySpan<byte> SdCardNintendoRootDirectoryName => // Nintendo
|
||||
new[]
|
||||
{
|
||||
(byte) 'N', (byte) 'i', (byte) 'n', (byte) 't', (byte) 'e', (byte) 'n', (byte) 'd', (byte) 'o'
|
||||
(byte)'N', (byte)'i', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'d', (byte)'o'
|
||||
};
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using LibHac.Common.FixedArrays;
|
||||
|
||||
namespace LibHac.Fs;
|
||||
|
||||
public struct DirectoryEntry
|
||||
{
|
||||
public Array769<byte> Name;
|
||||
|
@ -74,7 +74,6 @@ public enum FileSystemProxyType
|
||||
RegisteredUpdate = 8
|
||||
}
|
||||
|
||||
|
||||
public enum ImageDirectoryId
|
||||
{
|
||||
Nand = 0,
|
||||
|
@ -311,6 +311,7 @@ internal class FileSystemAccessor : IDisposable
|
||||
res = _fileSystem.Get.RenameDirectory(in currentPathNormalized, in newPathNormalized);
|
||||
if (res.IsFailure()) return res.Miss();
|
||||
}
|
||||
|
||||
return Result.Success;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
global using GameCardHandle = System.UInt32;
|
||||
|
||||
using System;
|
||||
using LibHac.Common.FixedArrays;
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.Fs.Impl;
|
||||
using LibHac.FsSrv.Sf;
|
||||
|
||||
using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
|
||||
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
|
||||
|
||||
|
@ -5,7 +5,6 @@ using LibHac.Fs.Fsa;
|
||||
using LibHac.Fs.Impl;
|
||||
using LibHac.FsSrv.Sf;
|
||||
using LibHac.Os;
|
||||
|
||||
using static LibHac.Fs.Impl.AccessLogStrings;
|
||||
using static LibHac.Fs.SaveData;
|
||||
using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
|
||||
|
@ -8,7 +8,6 @@ using LibHac.Ncm;
|
||||
using LibHac.Os;
|
||||
using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
|
||||
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
|
||||
|
||||
using static LibHac.Fs.Impl.AccessLogStrings;
|
||||
using static LibHac.Fs.SaveData;
|
||||
|
||||
|
@ -5,7 +5,6 @@ using LibHac.Common;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.Sf;
|
||||
using LibHac.Util;
|
||||
|
||||
using IFile = LibHac.Fs.Fsa.IFile;
|
||||
using IFileSf = LibHac.FsSrv.Sf.IFile;
|
||||
using IDirectory = LibHac.Fs.Fsa.IDirectory;
|
||||
|
@ -9,10 +9,8 @@ using LibHac.Gc;
|
||||
using LibHac.Os;
|
||||
using LibHac.Sf;
|
||||
using LibHac.Util;
|
||||
|
||||
using static LibHac.Fs.Impl.AccessLogStrings;
|
||||
using static LibHac.Gc.Values;
|
||||
|
||||
using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
|
||||
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
|
||||
using IStorageSf = LibHac.FsSrv.Sf.IStorage;
|
||||
|
@ -6,7 +6,6 @@ using LibHac.FsSrv.Sf;
|
||||
using LibHac.Os;
|
||||
using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
|
||||
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
|
||||
|
||||
using static LibHac.Fs.Impl.AccessLogStrings;
|
||||
|
||||
namespace LibHac.Fs.Shim;
|
||||
|
@ -7,7 +7,6 @@ using LibHac.Ncm;
|
||||
using LibHac.Os;
|
||||
using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
|
||||
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
|
||||
|
||||
using static LibHac.Fs.Impl.AccessLogStrings;
|
||||
|
||||
namespace LibHac.Fs.Shim;
|
||||
|
@ -5,7 +5,6 @@ using LibHac.Diag;
|
||||
using LibHac.Fs.Impl;
|
||||
using LibHac.FsSrv.Sf;
|
||||
using LibHac.Os;
|
||||
|
||||
using static LibHac.Fs.Impl.AccessLogStrings;
|
||||
using static LibHac.Fs.SaveData;
|
||||
|
||||
|
@ -12,7 +12,6 @@ using LibHac.Ncm;
|
||||
using LibHac.Os;
|
||||
using LibHac.Sf;
|
||||
using LibHac.Time;
|
||||
|
||||
using static LibHac.Fs.Impl.AccessLogStrings;
|
||||
using static LibHac.Fs.SaveData;
|
||||
|
||||
|
@ -8,7 +8,6 @@ using LibHac.Fs.Shim;
|
||||
using LibHac.FsSrv.Sf;
|
||||
using LibHac.Sf;
|
||||
using LibHac.Util;
|
||||
|
||||
using static LibHac.Fs.SaveData;
|
||||
|
||||
// ReSharper disable once CheckNamespace
|
||||
|
@ -5,7 +5,6 @@ using LibHac.Fs.Fsa;
|
||||
using LibHac.Fs.Impl;
|
||||
using LibHac.FsSrv.Sf;
|
||||
using LibHac.Os;
|
||||
|
||||
using static LibHac.Fs.Impl.AccessLogStrings;
|
||||
using static LibHac.Fs.SaveData;
|
||||
using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
|
||||
|
@ -67,10 +67,10 @@ internal readonly struct AccessLogService
|
||||
private static ReadOnlySpan<byte> MultiProgramTag => // FS_ACCESS: { multi_program_tag: true }\n
|
||||
new[]
|
||||
{
|
||||
(byte) 'F', (byte) 'S', (byte) '_', (byte) 'A', (byte) 'C', (byte) 'C', (byte) 'E', (byte) 'S',
|
||||
(byte) 'S', (byte) ':', (byte) ' ', (byte) '{', (byte) ' ', (byte) 'm', (byte) 'u', (byte) 'l',
|
||||
(byte) 't', (byte) 'i', (byte) '_', (byte) 'p', (byte) 'r', (byte) 'o', (byte) 'g', (byte) 'r',
|
||||
(byte) 'a', (byte) 'm', (byte) '_', (byte) 't', (byte) 'a', (byte) 'g', (byte) ':', (byte) ' ',
|
||||
(byte) 't', (byte) 'r', (byte) 'u', (byte) 'e', (byte) ' ', (byte) '}', (byte) '\n'
|
||||
(byte)'F', (byte)'S', (byte)'_', (byte)'A', (byte)'C', (byte)'C', (byte)'E', (byte)'S',
|
||||
(byte)'S', (byte)':', (byte)' ', (byte)'{', (byte)' ', (byte)'m', (byte)'u', (byte)'l',
|
||||
(byte)'t', (byte)'i', (byte)'_', (byte)'p', (byte)'r', (byte)'o', (byte)'g', (byte)'r',
|
||||
(byte)'a', (byte)'m', (byte)'_', (byte)'t', (byte)'a', (byte)'g', (byte)':', (byte)' ',
|
||||
(byte)'t', (byte)'r', (byte)'u', (byte)'e', (byte)' ', (byte)'}', (byte)'\n'
|
||||
};
|
||||
}
|
@ -20,6 +20,7 @@ public class EmulatedGameCard
|
||||
{
|
||||
KeySet = keySet;
|
||||
}
|
||||
|
||||
public GameCardHandle GetGameCardHandle()
|
||||
{
|
||||
return Handle;
|
||||
|
@ -2,7 +2,6 @@
|
||||
using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
|
||||
using Utility = LibHac.FsSrv.Impl.Utility;
|
||||
|
||||
namespace LibHac.FsSrv.FsCreator;
|
||||
|
@ -3,7 +3,6 @@ using LibHac.Common;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.Util;
|
||||
|
||||
using Utility = LibHac.FsSrv.Impl.Utility;
|
||||
|
||||
namespace LibHac.FsSrv.FsCreator;
|
||||
|
@ -7,7 +7,6 @@ using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Util;
|
||||
|
||||
using OpenType = LibHac.FsSrv.SaveDataOpenTypeSetFileStorage.OpenType;
|
||||
|
||||
namespace LibHac.FsSrv.FsCreator;
|
||||
|
@ -6,7 +6,6 @@ using LibHac.Fs;
|
||||
using LibHac.Fs.Fsa;
|
||||
using LibHac.FsSystem;
|
||||
using LibHac.Sf;
|
||||
|
||||
using IFile = LibHac.Fs.Fsa.IFile;
|
||||
using IFileSf = LibHac.FsSrv.Sf.IFile;
|
||||
using IDirectory = LibHac.Fs.Fsa.IDirectory;
|
||||
|
@ -53,7 +53,6 @@ public class ProgramIndexMapInfoManager : IDisposable
|
||||
// We skip running ClearImpl() if the allocation failed because we don't need to worry about that in C#
|
||||
|
||||
return Result.Success;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -908,13 +908,13 @@ public class NcaFileSystemServiceImpl
|
||||
private static ReadOnlySpan<byte> SdCardNintendoRootDirectoryName => // Nintendo
|
||||
new[]
|
||||
{
|
||||
(byte) 'N', (byte) 'i', (byte) 'n', (byte) 't', (byte) 'e', (byte) 'n', (byte) 'd', (byte) 'o'
|
||||
(byte)'N', (byte)'i', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'d', (byte)'o'
|
||||
};
|
||||
|
||||
private static ReadOnlySpan<byte> ContentStorageDirectoryName => // Contents
|
||||
new[]
|
||||
{
|
||||
(byte) 'C', (byte) 'o', (byte) 'n', (byte) 't', (byte) 'e', (byte) 'n', (byte) 't', (byte) 's'
|
||||
(byte)'C', (byte)'o', (byte)'n', (byte)'t', (byte)'e', (byte)'n', (byte)'t', (byte)'s'
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,8 @@ using LibHac.Ncm;
|
||||
using LibHac.Os;
|
||||
using LibHac.Sf;
|
||||
using LibHac.Util;
|
||||
|
||||
using static LibHac.Fs.SaveData;
|
||||
using static LibHac.Fs.StringTraits;
|
||||
|
||||
using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
|
||||
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
|
||||
using IFile = LibHac.Fs.Fsa.IFile;
|
||||
|
@ -12,7 +12,6 @@ using LibHac.Kvdb;
|
||||
using LibHac.Os;
|
||||
using LibHac.Sf;
|
||||
using LibHac.Util;
|
||||
|
||||
using static LibHac.Fs.SaveData;
|
||||
|
||||
namespace LibHac.FsSrv;
|
||||
@ -41,8 +40,8 @@ public class SaveDataIndexer : ISaveDataIndexer
|
||||
private static ReadOnlySpan<byte> LastPublishedIdFileName => // lastPublishedId
|
||||
new[]
|
||||
{
|
||||
(byte) 'l', (byte) 'a', (byte) 's', (byte) 't', (byte) 'P', (byte) 'u', (byte) 'b', (byte) 'l',
|
||||
(byte) 'i', (byte) 's', (byte) 'h', (byte) 'e', (byte) 'd', (byte) 'I', (byte) 'd'
|
||||
(byte)'l', (byte)'a', (byte)'s', (byte)'t', (byte)'P', (byte)'u', (byte)'b', (byte)'l',
|
||||
(byte)'i', (byte)'s', (byte)'h', (byte)'e', (byte)'d', (byte)'I', (byte)'d'
|
||||
};
|
||||
|
||||
private static ReadOnlySpan<byte> MountDelimiter => // :/
|
||||
|
@ -234,32 +234,32 @@ internal class SaveDataIndexerManager : ISaveDataIndexerManager, IDisposable
|
||||
private static ReadOnlySpan<byte> BisIndexerMountName =>
|
||||
new[]
|
||||
{
|
||||
(byte) 's', (byte) 'a', (byte) 'v', (byte) 'e', (byte) 'D', (byte) 'a', (byte) 't', (byte) 'a',
|
||||
(byte) 'I', (byte) 'x', (byte) 'r', (byte) 'D', (byte) 'b'
|
||||
(byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a',
|
||||
(byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b'
|
||||
};
|
||||
|
||||
/// <summary>"<c>saveDataIxrDbSd</c>"</summary>
|
||||
private static ReadOnlySpan<byte> SdCardIndexerMountName =>
|
||||
new[]
|
||||
{
|
||||
(byte) 's', (byte) 'a', (byte) 'v', (byte) 'e', (byte) 'D', (byte) 'a', (byte) 't', (byte) 'a',
|
||||
(byte) 'I', (byte) 'x', (byte) 'r', (byte) 'D', (byte) 'b', (byte) 'S', (byte) 'd'
|
||||
(byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a',
|
||||
(byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b', (byte)'S', (byte)'d'
|
||||
};
|
||||
|
||||
/// <summary>"<c>saveDataIxrDbPr</c>"</summary>
|
||||
private static ReadOnlySpan<byte> ProperBisIndexerMountName =>
|
||||
new[]
|
||||
{
|
||||
(byte) 's', (byte) 'a', (byte) 'v', (byte) 'e', (byte) 'D', (byte) 'a', (byte) 't', (byte) 'a',
|
||||
(byte) 'I', (byte) 'x', (byte) 'r', (byte) 'D', (byte) 'b', (byte) 'P', (byte) 'r'
|
||||
(byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a',
|
||||
(byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b', (byte)'P', (byte)'r'
|
||||
};
|
||||
|
||||
/// <summary>"<c>saveDataIxrDbSf</c>"</summary>
|
||||
private static ReadOnlySpan<byte> SafeModeIndexerMountName =>
|
||||
new[]
|
||||
{
|
||||
(byte) 's', (byte) 'a', (byte) 'v', (byte) 'e', (byte) 'D', (byte) 'a', (byte) 't', (byte) 'a',
|
||||
(byte) 'I', (byte) 'x', (byte) 'r', (byte) 'D', (byte) 'b', (byte) 'S', (byte) 'f'
|
||||
(byte)'s', (byte)'a', (byte)'v', (byte)'e', (byte)'D', (byte)'a', (byte)'t', (byte)'a',
|
||||
(byte)'I', (byte)'x', (byte)'r', (byte)'D', (byte)'b', (byte)'S', (byte)'f'
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -420,7 +420,6 @@ public class SaveDataFileStorageHolder
|
||||
ref Entry entry = ref currentEntry.ValueRef;
|
||||
_entryList.Remove(currentEntry);
|
||||
entry.Dispose();
|
||||
|
||||
}
|
||||
|
||||
currentEntry = currentEntry.Next;
|
||||
|
@ -7,7 +7,6 @@ using LibHac.Fs;
|
||||
using LibHac.FsSystem.Buffers;
|
||||
using LibHac.Os;
|
||||
using LibHac.Util;
|
||||
|
||||
using Buffer = LibHac.Mem.Buffer;
|
||||
using CacheHandle = System.UInt64;
|
||||
|
||||
@ -882,7 +881,6 @@ public class BufferedStorage : IStorage
|
||||
using var lk = new ScopedLock<SdkMutexType>(ref _bufferedStorage._mutex);
|
||||
|
||||
_cache.Value.UnprepareFetch();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1693,6 +1691,7 @@ public class BufferedStorage : IStorage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cache.Write(currentOffset, currentSource.Slice(0, currentSize));
|
||||
|
||||
BufferManagerUtility.EnableBlockingBufferManagerAllocation();
|
||||
|
@ -7,7 +7,6 @@ using LibHac.Diag;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Os;
|
||||
using LibHac.Util;
|
||||
|
||||
using Buffer = LibHac.Mem.Buffer;
|
||||
using CacheHandle = System.UInt64;
|
||||
|
||||
|
@ -5,7 +5,6 @@ using LibHac.Diag;
|
||||
using LibHac.Fs;
|
||||
using LibHac.FsSystem.Impl;
|
||||
using LibHac.Os;
|
||||
|
||||
using Buffer = LibHac.Mem.Buffer;
|
||||
using CacheHandle = System.UInt64;
|
||||
|
||||
@ -310,7 +309,6 @@ public class CompressedStorage : IStorage, IAsynchronousAccessSplitter
|
||||
if (res.IsFailure()) return res.Miss();
|
||||
|
||||
return Result.Success;
|
||||
|
||||
}
|
||||
|
||||
public void FinalizeObject()
|
||||
|
@ -5,7 +5,6 @@ using LibHac.Diag;
|
||||
using LibHac.Fs;
|
||||
using LibHac.Os;
|
||||
using LibHac.Util;
|
||||
|
||||
using BlockCache = LibHac.FsSystem.LruListCache<long, System.Memory<byte>>;
|
||||
|
||||
namespace LibHac.FsSystem;
|
||||
|
@ -67,6 +67,7 @@ internal ref struct ValueStringBuilder
|
||||
EnsureCapacity(Length + 1);
|
||||
_chars[Length] = '\0';
|
||||
}
|
||||
|
||||
return ref MemoryMarshal.GetReference(_chars);
|
||||
}
|
||||
|
||||
@ -100,6 +101,7 @@ internal ref struct ValueStringBuilder
|
||||
EnsureCapacity(Length + 1);
|
||||
_chars[Length] = '\0';
|
||||
}
|
||||
|
||||
return _chars.Slice(0, _pos);
|
||||
}
|
||||
|
||||
@ -205,6 +207,7 @@ internal ref struct ValueStringBuilder
|
||||
{
|
||||
dst[i] = c;
|
||||
}
|
||||
|
||||
_pos += count;
|
||||
}
|
||||
|
||||
|
@ -289,6 +289,7 @@ public class KipReader : IDisposable
|
||||
// Copy directly.
|
||||
data[--outOffset] = data[--inOffset];
|
||||
}
|
||||
|
||||
control <<= 1;
|
||||
|
||||
if (outOffset == 0)
|
||||
|
@ -27,8 +27,8 @@ public class FlatMapKeyValueStore<TKey> : IDisposable where TKey : unmanaged, IE
|
||||
private static ReadOnlySpan<byte> ArchiveFileName => // /imkvdb.arc
|
||||
new[]
|
||||
{
|
||||
(byte) '/', (byte) 'i', (byte) 'm', (byte) 'k', (byte) 'v', (byte) 'd', (byte) 'b', (byte) '.',
|
||||
(byte) 'a', (byte) 'r', (byte) 'c'
|
||||
(byte)'/', (byte)'i', (byte)'m', (byte)'k', (byte)'v', (byte)'d', (byte)'b', (byte)'.',
|
||||
(byte)'a', (byte)'r', (byte)'c'
|
||||
};
|
||||
|
||||
public int Count => _index.Count;
|
||||
|
@ -2,6 +2,7 @@
|
||||
using LibHac.Common;
|
||||
using LibHac.Common.FixedArrays;
|
||||
using LibHac.Ncm;
|
||||
|
||||
#pragma warning disable 169 // Unused private fields
|
||||
|
||||
namespace LibHac.Loader;
|
||||
|
@ -241,6 +241,7 @@ public class MultiWaitImpl : IDisposable
|
||||
outHolder = null;
|
||||
return waitResult;
|
||||
}
|
||||
|
||||
break;
|
||||
case WaitCancelled:
|
||||
{
|
||||
|
@ -80,7 +80,6 @@ public static class ReaderWriterLockApi
|
||||
{
|
||||
Assert.SdkRequires(rwLock.LockState == ReaderWriterLockType.State.Initialized);
|
||||
return ReaderWriterLockImpl.GetReadLockCount(in ReaderWriterLockImpl.GetLockCountRo(in rwLock)) != 0;
|
||||
|
||||
}
|
||||
|
||||
// Todo: Use Horizon thread APIs
|
||||
|
@ -434,12 +434,12 @@ public class InMemoryFileSystem : IAttributeFileSystem
|
||||
|
||||
private class FileTable
|
||||
{
|
||||
private DirectoryNode Root;
|
||||
private DirectoryNode _root;
|
||||
|
||||
public FileTable()
|
||||
{
|
||||
Root = new DirectoryNode();
|
||||
Root.Name = new U8String("");
|
||||
_root = new DirectoryNode();
|
||||
_root.Name = new U8String("");
|
||||
}
|
||||
|
||||
public Result AddFile(U8Span path)
|
||||
@ -645,7 +645,7 @@ public class InMemoryFileSystem : IAttributeFileSystem
|
||||
private Result FindDirectory(U8Span path, out DirectoryNode directory)
|
||||
{
|
||||
var parser = new PathParser(path);
|
||||
DirectoryNode current = Root;
|
||||
DirectoryNode current = _root;
|
||||
|
||||
while (parser.MoveNext())
|
||||
{
|
||||
|
@ -122,7 +122,9 @@ public class SwitchFs : IDisposable
|
||||
catch (MissingKeyException ex)
|
||||
{
|
||||
if (ex.Name == null)
|
||||
{ Console.WriteLine($"{ex.Message} File:\n{fileEntry}"); }
|
||||
{
|
||||
Console.WriteLine($"{ex.Message} File:\n{fileEntry}");
|
||||
}
|
||||
else
|
||||
{
|
||||
string name = ex.Type == KeyType.Title ? $"Title key for rights ID {ex.Name}" : ex.Name;
|
||||
|
@ -493,8 +493,7 @@ public static class PathTools
|
||||
|
||||
public static bool MatchesPattern(string searchPattern, string name, bool ignoreCase)
|
||||
{
|
||||
return FileSystemName.MatchesSimpleExpression(searchPattern.AsSpan(),
|
||||
name.AsSpan(), ignoreCase);
|
||||
return FileSystemName.MatchesSimpleExpression(searchPattern.AsSpan(), name.AsSpan(), ignoreCase);
|
||||
}
|
||||
|
||||
private static bool IsValidMountNameChar(char c)
|
||||
|
@ -30,12 +30,14 @@ internal static class HashHelpers
|
||||
// h1(key) + i*h2(key), 0 <= i < size. h2 and the size must be relatively prime.
|
||||
// We prefer the low computation costs of higher prime numbers over the increased
|
||||
// memory allocation of a fixed prime number i.e. when right sizing a HashSet.
|
||||
public static readonly int[] Primes = {
|
||||
public static readonly int[] Primes =
|
||||
{
|
||||
3, 7, 11, 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919,
|
||||
1103, 1327, 1597, 1931, 2333, 2801, 3371, 4049, 4861, 5839, 7013, 8419, 10103, 12143, 14591,
|
||||
17519, 21023, 25229, 30293, 36353, 43627, 52361, 62851, 75431, 90523, 108631, 130363, 156437,
|
||||
187751, 225307, 270371, 324449, 389357, 467237, 560689, 672827, 807403, 968897, 1162687, 1395263,
|
||||
1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369 };
|
||||
1674319, 2009191, 2411033, 2893249, 3471899, 4166287, 4999559, 5999471, 7199369
|
||||
};
|
||||
|
||||
public static bool IsPrime(int candidate)
|
||||
{
|
||||
@ -47,8 +49,10 @@ internal static class HashHelpers
|
||||
if ((candidate % divisor) == 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return (candidate == 2);
|
||||
}
|
||||
|
||||
@ -71,6 +75,7 @@ internal static class HashHelpers
|
||||
if (IsPrime(i) && ((i - 1) % HashPrime != 0))
|
||||
return i;
|
||||
}
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace LibHac.Tools.FsSystem.Save;
|
||||
|
||||
public class JournalMap
|
||||
{
|
||||
private int MapEntryLength = 8;
|
||||
private const int MapEntryLength = 8;
|
||||
public JournalMapHeader Header { get; }
|
||||
private JournalMapEntry[] Entries { get; }
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
# LibHac.Tools
|
||||
|
||||
The `LibHac.Tools` namespace contains classes that aren't necessarily part of Horizon. Some examples might include:
|
||||
|
||||
- Classes that provide additional functionality to that found in nnsdk.
|
||||
- Classes that have a more user-friendly or C#-like API than those in nnsdk. e.g. A standalone NCA reader that streamlines opening and reading an NCA file.
|
||||
- Classes that have a more user-friendly or C#-like API than those in nnsdk. e.g. A standalone NCA reader that
|
||||
streamlines opening and reading an NCA file.
|
||||
- File parsers that read a file's structure into standard C# objects/fields instead of operating on a raw byte array.
|
@ -53,7 +53,6 @@ public class Nro
|
||||
|
||||
return AssetStorage.Slice(header.FileOffset, header.Size, leaveOpen);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class NroStart
|
||||
|
@ -121,6 +121,7 @@ public class Calibration
|
||||
stream.Position = 0x88 + i * 4;
|
||||
WlanCountryCodes[i] = reader.ReadUtf8Z();
|
||||
}
|
||||
|
||||
stream.Position = 0x210;
|
||||
WlanMacAddr = reader.ReadBytes(0x6);
|
||||
|
||||
|
@ -855,7 +855,6 @@ public static class CharacterEncoding
|
||||
|
||||
bufferSrc[1] = source[1];
|
||||
bufferSrc[2] = source[2];
|
||||
|
||||
}
|
||||
else if (source[0] >= 0xF0 && source[0] < 0xF8)
|
||||
{
|
||||
@ -1001,7 +1000,6 @@ public static class CharacterEncoding
|
||||
destination[0] = (byte)(0xE0 | (source >> 12) & 0xF);
|
||||
destination[1] = (byte)(0x80 | (source >> 6) & 0x3F);
|
||||
destination[2] = (byte)(0x80 | (source >> 0) & 0x3F);
|
||||
|
||||
}
|
||||
else if (source < 0x110000)
|
||||
{
|
||||
|
@ -224,10 +224,10 @@ internal static class HexConverter
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 15
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 31
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 47
|
||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 63
|
||||
0xFF, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 79
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 63
|
||||
0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 79
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 95
|
||||
0xFF, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 111
|
||||
0xFF, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 111
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 127
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 143
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 159
|
||||
|
@ -22,8 +22,7 @@ public static class Lz4
|
||||
do
|
||||
{
|
||||
length += sum = cmp[cmpPos++];
|
||||
}
|
||||
while (sum == 0xff);
|
||||
} while (sum == 0xff);
|
||||
}
|
||||
|
||||
return length;
|
||||
@ -70,8 +69,7 @@ public static class Lz4
|
||||
dec[decPos++] = dec[encPos++];
|
||||
}
|
||||
}
|
||||
}
|
||||
while (cmpPos < cmp.Length &&
|
||||
} while (cmpPos < cmp.Length &&
|
||||
decPos < dec.Length);
|
||||
|
||||
return dec;
|
||||
@ -92,8 +90,7 @@ public static class Lz4
|
||||
do
|
||||
{
|
||||
length += sum = cmp[cmpPos++];
|
||||
}
|
||||
while (sum == 0xff);
|
||||
} while (sum == 0xff);
|
||||
}
|
||||
|
||||
return length;
|
||||
@ -140,8 +137,7 @@ public static class Lz4
|
||||
dec[decPos++] = dec[encPos++];
|
||||
}
|
||||
}
|
||||
}
|
||||
while (cmpPos < cmp.Length &&
|
||||
} while (cmpPos < cmp.Length &&
|
||||
decPos < dec.Length);
|
||||
}
|
||||
}
|
@ -11,6 +11,7 @@ public struct Optional<T>
|
||||
private T _value;
|
||||
|
||||
public readonly bool HasValue => _hasValue;
|
||||
|
||||
public ref T Value
|
||||
{
|
||||
get
|
||||
@ -20,6 +21,7 @@ public struct Optional<T>
|
||||
return ref MemoryMarshal.GetReference(SpanHelpers.CreateSpan(ref _value, 1));
|
||||
}
|
||||
}
|
||||
|
||||
public readonly ref readonly T ValueRo
|
||||
{
|
||||
get
|
||||
|
@ -163,6 +163,7 @@ public static class StringUtils
|
||||
{
|
||||
c = (byte)(c | 0x20);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -5,17 +5,17 @@ namespace hactoolnet;
|
||||
|
||||
public struct ScopedIndentation : IDisposable
|
||||
{
|
||||
private IndentingStringBuilder Builder;
|
||||
private IndentingStringBuilder _builder;
|
||||
|
||||
public ScopedIndentation(IndentingStringBuilder builder)
|
||||
{
|
||||
builder.IncreaseLevel();
|
||||
Builder = builder;
|
||||
_builder = builder;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Builder.DecreaseLevel();
|
||||
_builder.DecreaseLevel();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user