mirror of
https://github.com/Thealexbarney/LibHac.git
synced 2024-11-14 10:49:41 +01:00
Rename LocalAccessLogMode to AccessLogTarget
This commit is contained in:
parent
57586d75fd
commit
c6a261eeee
5 changed files with 31 additions and 31 deletions
|
@ -9,7 +9,7 @@ namespace LibHac.Fs
|
||||||
public partial class FileSystemClient
|
public partial class FileSystemClient
|
||||||
{
|
{
|
||||||
private GlobalAccessLogMode GlobalAccessLogMode { get; set; }
|
private GlobalAccessLogMode GlobalAccessLogMode { get; set; }
|
||||||
private LocalAccessLogMode LocalAccessLogMode { get; set; }
|
private AccessLogTarget AccessLogTarget { get; set; }
|
||||||
private bool AccessLogInitialized { get; set; }
|
private bool AccessLogInitialized { get; set; }
|
||||||
|
|
||||||
private readonly object _accessLogInitLocker = new object();
|
private readonly object _accessLogInitLocker = new object();
|
||||||
|
@ -40,9 +40,9 @@ namespace LibHac.Fs
|
||||||
return Result.Success;
|
return Result.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLocalAccessLogMode(LocalAccessLogMode mode)
|
public void SetAccessLogTarget(AccessLogTarget target)
|
||||||
{
|
{
|
||||||
LocalAccessLogMode = mode;
|
AccessLogTarget = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetAccessLogObject(IAccessLog accessLog)
|
public void SetAccessLogObject(IAccessLog accessLog)
|
||||||
|
@ -50,9 +50,9 @@ namespace LibHac.Fs
|
||||||
AccessLog = accessLog;
|
AccessLog = accessLog;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool IsEnabledAccessLog(LocalAccessLogMode mode)
|
internal bool IsEnabledAccessLog(AccessLogTarget target)
|
||||||
{
|
{
|
||||||
if ((LocalAccessLogMode & mode) == 0)
|
if ((AccessLogTarget & target) == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ namespace LibHac.Fs
|
||||||
|
|
||||||
internal bool IsEnabledAccessLog()
|
internal bool IsEnabledAccessLog()
|
||||||
{
|
{
|
||||||
return IsEnabledAccessLog(LocalAccessLogMode.All);
|
return IsEnabledAccessLog(AccessLogTarget.All);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool IsEnabledFileSystemAccessorAccessLog(string mountName)
|
internal bool IsEnabledFileSystemAccessorAccessLog(string mountName)
|
||||||
|
@ -167,12 +167,12 @@ namespace LibHac.Fs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result RunOperationWithAccessLog(LocalAccessLogMode logType, Func<Result> operation,
|
public Result RunOperationWithAccessLog(AccessLogTarget logTarget, Func<Result> operation,
|
||||||
Func<string> textGenerator, [CallerMemberName] string caller = "")
|
Func<string> textGenerator, [CallerMemberName] string caller = "")
|
||||||
{
|
{
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
if (IsEnabledAccessLog(logType))
|
if (IsEnabledAccessLog(logTarget))
|
||||||
{
|
{
|
||||||
TimeSpan startTime = Time.GetCurrent();
|
TimeSpan startTime = Time.GetCurrent();
|
||||||
rc = operation();
|
rc = operation();
|
||||||
|
@ -188,12 +188,12 @@ namespace LibHac.Fs
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result RunOperationWithAccessLog(LocalAccessLogMode logType, FileHandle handle, Func<Result> operation,
|
public Result RunOperationWithAccessLog(AccessLogTarget logTarget, FileHandle handle, Func<Result> operation,
|
||||||
Func<string> textGenerator, [CallerMemberName] string caller = "")
|
Func<string> textGenerator, [CallerMemberName] string caller = "")
|
||||||
{
|
{
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
if (IsEnabledAccessLog(logType) && handle.File.Parent.IsAccessLogEnabled)
|
if (IsEnabledAccessLog(logTarget) && handle.File.Parent.IsAccessLogEnabled)
|
||||||
{
|
{
|
||||||
TimeSpan startTime = Time.GetCurrent();
|
TimeSpan startTime = Time.GetCurrent();
|
||||||
rc = operation();
|
rc = operation();
|
||||||
|
@ -211,7 +211,7 @@ namespace LibHac.Fs
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum LocalAccessLogMode
|
public enum AccessLogTarget
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
Application = 1 << 0,
|
Application = 1 << 0,
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace LibHac.Fs
|
||||||
|
|
||||||
public Result FlushFile(FileHandle handle)
|
public Result FlushFile(FileHandle handle)
|
||||||
{
|
{
|
||||||
return RunOperationWithAccessLog(LocalAccessLogMode.All, handle,
|
return RunOperationWithAccessLog(AccessLogTarget.All, handle,
|
||||||
() => handle.File.Flush(),
|
() => handle.File.Flush(),
|
||||||
() => string.Empty);
|
() => string.Empty);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ namespace LibHac.Fs
|
||||||
|
|
||||||
public Result SetFileSize(FileHandle handle, long size)
|
public Result SetFileSize(FileHandle handle, long size)
|
||||||
{
|
{
|
||||||
return RunOperationWithAccessLog(LocalAccessLogMode.All, handle,
|
return RunOperationWithAccessLog(AccessLogTarget.All, handle,
|
||||||
() => handle.File.SetSize(size),
|
() => handle.File.SetSize(size),
|
||||||
() => $", size: {size}");
|
() => $", size: {size}");
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ namespace LibHac.Fs
|
||||||
|
|
||||||
public void CloseFile(FileHandle handle)
|
public void CloseFile(FileHandle handle)
|
||||||
{
|
{
|
||||||
RunOperationWithAccessLog(LocalAccessLogMode.All, handle,
|
RunOperationWithAccessLog(AccessLogTarget.All, handle,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
handle.File.Dispose();
|
handle.File.Dispose();
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace LibHac.Fs.Shim
|
||||||
{
|
{
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
if (fs.IsEnabledAccessLog(LocalAccessLogMode.Application))
|
if (fs.IsEnabledAccessLog(AccessLogTarget.Application))
|
||||||
{
|
{
|
||||||
TimeSpan startTime = fs.Time.GetCurrent();
|
TimeSpan startTime = fs.Time.GetCurrent();
|
||||||
rc = MountSaveDataImpl(fs, mountName, SaveDataSpaceId.User, titleId, userId, SaveDataType.SaveData, false, 0);
|
rc = MountSaveDataImpl(fs, mountName, SaveDataSpaceId.User, titleId, userId, SaveDataType.SaveData, false, 0);
|
||||||
|
@ -25,7 +25,7 @@ namespace LibHac.Fs.Shim
|
||||||
rc = MountSaveDataImpl(fs, mountName, SaveDataSpaceId.User, titleId, userId, SaveDataType.SaveData, false, 0);
|
rc = MountSaveDataImpl(fs, mountName, SaveDataSpaceId.User, titleId, userId, SaveDataType.SaveData, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc.IsSuccess() && fs.IsEnabledAccessLog(LocalAccessLogMode.Application))
|
if (rc.IsSuccess() && fs.IsEnabledAccessLog(AccessLogTarget.Application))
|
||||||
{
|
{
|
||||||
fs.EnableFileSystemAccessorAccessLog(mountName);
|
fs.EnableFileSystemAccessorAccessLog(mountName);
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ namespace LibHac.Fs.Shim
|
||||||
{
|
{
|
||||||
Result rc;
|
Result rc;
|
||||||
|
|
||||||
if (fs.IsEnabledAccessLog(LocalAccessLogMode.Application))
|
if (fs.IsEnabledAccessLog(AccessLogTarget.Application))
|
||||||
{
|
{
|
||||||
TimeSpan startTime = fs.Time.GetCurrent();
|
TimeSpan startTime = fs.Time.GetCurrent();
|
||||||
rc = MountSaveDataImpl(fs, mountName, SaveDataSpaceId.User, titleId, userId, SaveDataType.SaveData, true, 0);
|
rc = MountSaveDataImpl(fs, mountName, SaveDataSpaceId.User, titleId, userId, SaveDataType.SaveData, true, 0);
|
||||||
|
@ -50,7 +50,7 @@ namespace LibHac.Fs.Shim
|
||||||
rc = MountSaveDataImpl(fs, mountName, SaveDataSpaceId.User, titleId, userId, SaveDataType.SaveData, false, 0);
|
rc = MountSaveDataImpl(fs, mountName, SaveDataSpaceId.User, titleId, userId, SaveDataType.SaveData, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc.IsSuccess() && fs.IsEnabledAccessLog(LocalAccessLogMode.Application))
|
if (rc.IsSuccess() && fs.IsEnabledAccessLog(AccessLogTarget.Application))
|
||||||
{
|
{
|
||||||
fs.EnableFileSystemAccessorAccessLog(mountName);
|
fs.EnableFileSystemAccessorAccessLog(mountName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace LibHac.Fs.Shim
|
||||||
public static Result CreateSaveData(this FileSystemClient fs, TitleId applicationId, UserId userId, TitleId ownerId,
|
public static Result CreateSaveData(this FileSystemClient fs, TitleId applicationId, UserId userId, TitleId ownerId,
|
||||||
long size, long journalSize, uint flags)
|
long size, long journalSize, uint flags)
|
||||||
{
|
{
|
||||||
return fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
return fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -48,7 +48,7 @@ namespace LibHac.Fs.Shim
|
||||||
public static Result CreateSaveData(this FileSystemClient fs, TitleId applicationId, UserId userId, TitleId ownerId,
|
public static Result CreateSaveData(this FileSystemClient fs, TitleId applicationId, UserId userId, TitleId ownerId,
|
||||||
long size, long journalSize, HashSalt hashSalt, uint flags)
|
long size, long journalSize, HashSalt hashSalt, uint flags)
|
||||||
{
|
{
|
||||||
return fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
return fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -83,7 +83,7 @@ namespace LibHac.Fs.Shim
|
||||||
|
|
||||||
public static Result CreateBcatSaveData(this FileSystemClient fs, TitleId applicationId, long size)
|
public static Result CreateBcatSaveData(this FileSystemClient fs, TitleId applicationId, long size)
|
||||||
{
|
{
|
||||||
return fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
return fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -114,7 +114,7 @@ namespace LibHac.Fs.Shim
|
||||||
public static Result CreateDeviceSaveData(this FileSystemClient fs, TitleId applicationId, TitleId ownerId,
|
public static Result CreateDeviceSaveData(this FileSystemClient fs, TitleId applicationId, TitleId ownerId,
|
||||||
long size, long journalSize, uint flags)
|
long size, long journalSize, uint flags)
|
||||||
{
|
{
|
||||||
return fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
return fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -144,7 +144,7 @@ namespace LibHac.Fs.Shim
|
||||||
|
|
||||||
public static Result CreateTemporaryStorage(this FileSystemClient fs, TitleId applicationId, TitleId ownerId, long size, uint flags)
|
public static Result CreateTemporaryStorage(this FileSystemClient fs, TitleId applicationId, TitleId ownerId, long size, uint flags)
|
||||||
{
|
{
|
||||||
return fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
return fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -174,7 +174,7 @@ namespace LibHac.Fs.Shim
|
||||||
public static Result CreateSystemSaveData(this FileSystemClient fs, SaveDataSpaceId spaceId,
|
public static Result CreateSystemSaveData(this FileSystemClient fs, SaveDataSpaceId spaceId,
|
||||||
ulong saveDataId, UserId userId, TitleId ownerId, long size, long journalSize, uint flags)
|
ulong saveDataId, UserId userId, TitleId ownerId, long size, long journalSize, uint flags)
|
||||||
{
|
{
|
||||||
return fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
return fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -232,7 +232,7 @@ namespace LibHac.Fs.Shim
|
||||||
|
|
||||||
public static Result DeleteSaveData(this FileSystemClient fs, ulong saveDataId)
|
public static Result DeleteSaveData(this FileSystemClient fs, ulong saveDataId)
|
||||||
{
|
{
|
||||||
return fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
return fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -243,7 +243,7 @@ namespace LibHac.Fs.Shim
|
||||||
|
|
||||||
public static Result DeleteSaveData(this FileSystemClient fs, SaveDataSpaceId spaceId, ulong saveDataId)
|
public static Result DeleteSaveData(this FileSystemClient fs, SaveDataSpaceId spaceId, ulong saveDataId)
|
||||||
{
|
{
|
||||||
return fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
return fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -260,7 +260,7 @@ namespace LibHac.Fs.Shim
|
||||||
SaveDataFilter tempFilter = filter;
|
SaveDataFilter tempFilter = filter;
|
||||||
var tempInfo = new SaveDataInfo();
|
var tempInfo = new SaveDataInfo();
|
||||||
|
|
||||||
Result result = fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
Result result = fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -290,7 +290,7 @@ namespace LibHac.Fs.Shim
|
||||||
{
|
{
|
||||||
var tempIterator = new SaveDataIterator();
|
var tempIterator = new SaveDataIterator();
|
||||||
|
|
||||||
Result result = fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
Result result = fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -314,7 +314,7 @@ namespace LibHac.Fs.Shim
|
||||||
var tempIterator = new SaveDataIterator();
|
var tempIterator = new SaveDataIterator();
|
||||||
SaveDataFilter tempFilter = filter;
|
SaveDataFilter tempFilter = filter;
|
||||||
|
|
||||||
Result result = fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
|
Result result = fs.RunOperationWithAccessLog(AccessLogTarget.System,
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
|
||||||
|
@ -358,7 +358,7 @@ namespace LibHac.Fs.Shim
|
||||||
|
|
||||||
Span<byte> byteBuffer = MemoryMarshal.Cast<SaveDataInfo, byte>(buffer);
|
Span<byte> byteBuffer = MemoryMarshal.Cast<SaveDataInfo, byte>(buffer);
|
||||||
|
|
||||||
if (FsClient.IsEnabledAccessLog(LocalAccessLogMode.System))
|
if (FsClient.IsEnabledAccessLog(AccessLogTarget.System))
|
||||||
{
|
{
|
||||||
TimeSpan startTime = FsClient.Time.GetCurrent();
|
TimeSpan startTime = FsClient.Time.GetCurrent();
|
||||||
rc = Reader.ReadSaveDataInfo(out readCount, byteBuffer);
|
rc = Reader.ReadSaveDataInfo(out readCount, byteBuffer);
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace hactoolnet
|
||||||
logWriter = new StreamWriter(ctx.Options.AccessLog);
|
logWriter = new StreamWriter(ctx.Options.AccessLog);
|
||||||
var accessLog = new TextWriterAccessLog(logWriter);
|
var accessLog = new TextWriterAccessLog(logWriter);
|
||||||
|
|
||||||
ctx.Horizon.Fs.SetLocalAccessLogMode(LocalAccessLogMode.All);
|
ctx.Horizon.Fs.SetAccessLogTarget(AccessLogTarget.All);
|
||||||
ctx.Horizon.Fs.SetGlobalAccessLogMode(GlobalAccessLogMode.Log);
|
ctx.Horizon.Fs.SetGlobalAccessLogMode(GlobalAccessLogMode.Log);
|
||||||
|
|
||||||
ctx.Horizon.Fs.SetAccessLogObject(accessLog);
|
ctx.Horizon.Fs.SetAccessLogObject(accessLog);
|
||||||
|
|
Loading…
Reference in a new issue