Skip to content

Commit

Permalink
VFS: Basic File Redirection Manager code quality refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
MeFisto94 committed Sep 26, 2024
1 parent b0e0f5b commit 084af69
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions VFS/BasicFileRedirectingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public void Load()
{
var queryFile = SanitizePath(name);
// Debug Logging
// _logger.Trace($"CreateFileA {name} ({queryFile}) => {_fileMap.ContainsKey(queryFile)}");
//if (_fileMap.ContainsKey(queryFile)) _logger.Trace($"{queryFile} redirected to {_fileMap[queryFile]}");
//if (!_fileMap.ContainsKey(queryFile)) _logger.Trace($"{queryFile} could not be redirected");
var fileName = _fileMap.ContainsKey(queryFile) ? _fileMap[queryFile] : name;
//_logger.Trace($"CreateFileA {name} ({queryFile}) => {_fileMap.ContainsKey(queryFile)}");
// if (_fileMap.ContainsKey(queryFile)) _logger.Trace($"{queryFile} redirected to {_fileMap[queryFile]}");
// if (!_fileMap.ContainsKey(queryFile)) _logger.Trace($"{queryFile} could not be redirected");
var fileName = _fileMap.TryGetValue(queryFile, out var value) ? value : name;
return _createFileHook.Original(fileName, access, mode,attributes, disposition, andAttributes, file);
},
this);
Expand All @@ -76,7 +76,7 @@ public void Load()
// Games like Test Drive Unlimited (2006) are abusing FindFirstFile with an explicit file name to
// get all file attributes, such as the file size.
var queryFile = SanitizePath(name);
var fileName = _fileMap.ContainsKey(queryFile) ? _fileMap[queryFile] : name;
var fileName = _fileMap.TryGetValue(queryFile, out var value) ? value : name;

return _findFirstFileHook.Original(fileName, data);
}, this);
Expand Down Expand Up @@ -128,7 +128,7 @@ public void ClearMappings()
/// <br />
/// This method should NOT be called by Mods, only by the modding framework.<br />
/// This is because conflicts cannot be handled and would overwrite each-other.<br />
/// Instead the Framework should handle this gracefully and use a priority value
/// Instead, the Framework should handle this gracefully and use a priority value
/// or ask the user via the Host Application on a per-file basis.
/// </summary>
/// <param name="sourcePath">The path the target application searches for</param>
Expand All @@ -149,7 +149,7 @@ public void AddMapping(string sourcePath, string destPath)
public string? QueryMapping(string sourcePath)
{
var queryFile = SanitizePath(sourcePath);
return _fileMap.ContainsKey(queryFile) ? _fileMap[queryFile] : null;
return _fileMap.TryGetValue(queryFile, out var value) ? value : null;
}
#nullable restore
}
Expand Down

0 comments on commit 084af69

Please sign in to comment.