diff --git a/src/LibHac/Fs/FileSystemClient.AccessLog.cs b/src/LibHac/Fs/FileSystemClient.AccessLog.cs index b60a5ce1..f42231f0 100644 --- a/src/LibHac/Fs/FileSystemClient.AccessLog.cs +++ b/src/LibHac/Fs/FileSystemClient.AccessLog.cs @@ -9,7 +9,7 @@ namespace LibHac.Fs public partial class FileSystemClient { private GlobalAccessLogMode GlobalAccessLogMode { get; set; } - private LocalAccessLogMode LocalAccessLogMode { get; set; } + private AccessLogTarget AccessLogTarget { get; set; } private bool AccessLogInitialized { get; set; } private readonly object _accessLogInitLocker = new object(); @@ -40,9 +40,9 @@ namespace LibHac.Fs return Result.Success; } - public void SetLocalAccessLogMode(LocalAccessLogMode mode) + public void SetAccessLogTarget(AccessLogTarget target) { - LocalAccessLogMode = mode; + AccessLogTarget = target; } public void SetAccessLogObject(IAccessLog accessLog) @@ -50,9 +50,9 @@ namespace LibHac.Fs AccessLog = accessLog; } - internal bool IsEnabledAccessLog(LocalAccessLogMode mode) + internal bool IsEnabledAccessLog(AccessLogTarget target) { - if ((LocalAccessLogMode & mode) == 0) + if ((AccessLogTarget & target) == 0) { return false; } @@ -102,7 +102,7 @@ namespace LibHac.Fs internal bool IsEnabledAccessLog() { - return IsEnabledAccessLog(LocalAccessLogMode.All); + return IsEnabledAccessLog(AccessLogTarget.All); } internal bool IsEnabledFileSystemAccessorAccessLog(string mountName) @@ -167,12 +167,12 @@ namespace LibHac.Fs } } - public Result RunOperationWithAccessLog(LocalAccessLogMode logType, Func operation, + public Result RunOperationWithAccessLog(AccessLogTarget logTarget, Func operation, Func textGenerator, [CallerMemberName] string caller = "") { Result rc; - if (IsEnabledAccessLog(logType)) + if (IsEnabledAccessLog(logTarget)) { TimeSpan startTime = Time.GetCurrent(); rc = operation(); @@ -188,12 +188,12 @@ namespace LibHac.Fs return rc; } - public Result RunOperationWithAccessLog(LocalAccessLogMode logType, FileHandle handle, Func operation, + public Result RunOperationWithAccessLog(AccessLogTarget logTarget, FileHandle handle, Func operation, Func textGenerator, [CallerMemberName] string caller = "") { Result rc; - if (IsEnabledAccessLog(logType) && handle.File.Parent.IsAccessLogEnabled) + if (IsEnabledAccessLog(logTarget) && handle.File.Parent.IsAccessLogEnabled) { TimeSpan startTime = Time.GetCurrent(); rc = operation(); @@ -211,7 +211,7 @@ namespace LibHac.Fs } [Flags] - public enum LocalAccessLogMode + public enum AccessLogTarget { None = 0, Application = 1 << 0, diff --git a/src/LibHac/Fs/FileSystemClient.File.cs b/src/LibHac/Fs/FileSystemClient.File.cs index aab0c161..32941dfe 100644 --- a/src/LibHac/Fs/FileSystemClient.File.cs +++ b/src/LibHac/Fs/FileSystemClient.File.cs @@ -73,7 +73,7 @@ namespace LibHac.Fs public Result FlushFile(FileHandle handle) { - return RunOperationWithAccessLog(LocalAccessLogMode.All, handle, + return RunOperationWithAccessLog(AccessLogTarget.All, handle, () => handle.File.Flush(), () => string.Empty); } @@ -85,7 +85,7 @@ namespace LibHac.Fs public Result SetFileSize(FileHandle handle, long size) { - return RunOperationWithAccessLog(LocalAccessLogMode.All, handle, + return RunOperationWithAccessLog(AccessLogTarget.All, handle, () => handle.File.SetSize(size), () => $", size: {size}"); } @@ -97,7 +97,7 @@ namespace LibHac.Fs public void CloseFile(FileHandle handle) { - RunOperationWithAccessLog(LocalAccessLogMode.All, handle, + RunOperationWithAccessLog(AccessLogTarget.All, handle, () => { handle.File.Dispose(); diff --git a/src/LibHac/Fs/Shim/SaveData.cs b/src/LibHac/Fs/Shim/SaveData.cs index 953365b5..b2b5cca7 100644 --- a/src/LibHac/Fs/Shim/SaveData.cs +++ b/src/LibHac/Fs/Shim/SaveData.cs @@ -12,7 +12,7 @@ namespace LibHac.Fs.Shim { Result rc; - if (fs.IsEnabledAccessLog(LocalAccessLogMode.Application)) + if (fs.IsEnabledAccessLog(AccessLogTarget.Application)) { TimeSpan startTime = fs.Time.GetCurrent(); 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); } - if (rc.IsSuccess() && fs.IsEnabledAccessLog(LocalAccessLogMode.Application)) + if (rc.IsSuccess() && fs.IsEnabledAccessLog(AccessLogTarget.Application)) { fs.EnableFileSystemAccessorAccessLog(mountName); } @@ -37,7 +37,7 @@ namespace LibHac.Fs.Shim { Result rc; - if (fs.IsEnabledAccessLog(LocalAccessLogMode.Application)) + if (fs.IsEnabledAccessLog(AccessLogTarget.Application)) { TimeSpan startTime = fs.Time.GetCurrent(); 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); } - if (rc.IsSuccess() && fs.IsEnabledAccessLog(LocalAccessLogMode.Application)) + if (rc.IsSuccess() && fs.IsEnabledAccessLog(AccessLogTarget.Application)) { fs.EnableFileSystemAccessorAccessLog(mountName); } diff --git a/src/LibHac/Fs/Shim/SaveDataManagement.cs b/src/LibHac/Fs/Shim/SaveDataManagement.cs index f478772a..962d7a08 100644 --- a/src/LibHac/Fs/Shim/SaveDataManagement.cs +++ b/src/LibHac/Fs/Shim/SaveDataManagement.cs @@ -12,7 +12,7 @@ namespace LibHac.Fs.Shim public static Result CreateSaveData(this FileSystemClient fs, TitleId applicationId, UserId userId, TitleId ownerId, long size, long journalSize, uint flags) { - return fs.RunOperationWithAccessLog(LocalAccessLogMode.System, + return fs.RunOperationWithAccessLog(AccessLogTarget.System, () => { 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, long size, long journalSize, HashSalt hashSalt, uint flags) { - return fs.RunOperationWithAccessLog(LocalAccessLogMode.System, + return fs.RunOperationWithAccessLog(AccessLogTarget.System, () => { IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject(); @@ -83,7 +83,7 @@ namespace LibHac.Fs.Shim 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(); @@ -114,7 +114,7 @@ namespace LibHac.Fs.Shim public static Result CreateDeviceSaveData(this FileSystemClient fs, TitleId applicationId, TitleId ownerId, long size, long journalSize, uint flags) { - return fs.RunOperationWithAccessLog(LocalAccessLogMode.System, + return fs.RunOperationWithAccessLog(AccessLogTarget.System, () => { 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) { - return fs.RunOperationWithAccessLog(LocalAccessLogMode.System, + return fs.RunOperationWithAccessLog(AccessLogTarget.System, () => { IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject(); @@ -174,7 +174,7 @@ namespace LibHac.Fs.Shim public static Result CreateSystemSaveData(this FileSystemClient fs, SaveDataSpaceId spaceId, 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(); @@ -232,7 +232,7 @@ namespace LibHac.Fs.Shim public static Result DeleteSaveData(this FileSystemClient fs, ulong saveDataId) { - return fs.RunOperationWithAccessLog(LocalAccessLogMode.System, + return fs.RunOperationWithAccessLog(AccessLogTarget.System, () => { IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject(); @@ -243,7 +243,7 @@ namespace LibHac.Fs.Shim 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(); @@ -260,7 +260,7 @@ namespace LibHac.Fs.Shim SaveDataFilter tempFilter = filter; var tempInfo = new SaveDataInfo(); - Result result = fs.RunOperationWithAccessLog(LocalAccessLogMode.System, + Result result = fs.RunOperationWithAccessLog(AccessLogTarget.System, () => { IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject(); @@ -290,7 +290,7 @@ namespace LibHac.Fs.Shim { var tempIterator = new SaveDataIterator(); - Result result = fs.RunOperationWithAccessLog(LocalAccessLogMode.System, + Result result = fs.RunOperationWithAccessLog(AccessLogTarget.System, () => { IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject(); @@ -314,7 +314,7 @@ namespace LibHac.Fs.Shim var tempIterator = new SaveDataIterator(); SaveDataFilter tempFilter = filter; - Result result = fs.RunOperationWithAccessLog(LocalAccessLogMode.System, + Result result = fs.RunOperationWithAccessLog(AccessLogTarget.System, () => { IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject(); @@ -358,7 +358,7 @@ namespace LibHac.Fs.Shim Span byteBuffer = MemoryMarshal.Cast(buffer); - if (FsClient.IsEnabledAccessLog(LocalAccessLogMode.System)) + if (FsClient.IsEnabledAccessLog(AccessLogTarget.System)) { TimeSpan startTime = FsClient.Time.GetCurrent(); rc = Reader.ReadSaveDataInfo(out readCount, byteBuffer); diff --git a/src/hactoolnet/Program.cs b/src/hactoolnet/Program.cs index 6058fdca..7636229e 100644 --- a/src/hactoolnet/Program.cs +++ b/src/hactoolnet/Program.cs @@ -68,7 +68,7 @@ namespace hactoolnet logWriter = new StreamWriter(ctx.Options.AccessLog); 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.SetAccessLogObject(accessLog);