Skip to content

Commit

Permalink
Fixed a bug which occured on systems where Switch.System.IO.UseLegacy…
Browse files Browse the repository at this point in the history
…PathHandling is turned on caused an InvalidCharacter exception to be thrown because NT paths contain invalid characters (?) in legacy mode. (#7)

Co-authored-by: Henri <[email protected]>
  • Loading branch information
0xffhh and 0xffhh authored Nov 18, 2020
1 parent 2a492e6 commit 0019969
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/SauronEye/Searcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,15 @@ public ContentsSearcher(IEnumerable<string> directories, List<string> keywords,
// Searches the contents of filtered files. Does not care about exceptions.
public void Search() {
foreach (String dir in Directories) {
try {
var fileInfo = new FileInfo(ConvertToNTPath(dir));
try {
bool usingLegacyPathHandling = false;
AppContext.TryGetSwitch("Switch.System.IO.UseLegacyPathHandling", out usingLegacyPathHandling);
var dirToCheck = dir;
if (!usingLegacyPathHandling)
{
dirToCheck = ConvertToNTPath(dir);
}
var fileInfo = new FileInfo(dirToCheck);

string fileContents;
if (Convert.ToUInt64(fileInfo.Length) < 1024 * this.MAX_FILE_SIZE) {
Expand Down

0 comments on commit 0019969

Please sign in to comment.