Skip to content

Commit

Permalink
Case Sensitivity Fixes
Browse files Browse the repository at this point in the history
- Fixed case sensitivity searches for ignore files/folders
  • Loading branch information
jhubbard778 committed Jul 27, 2024
1 parent 967225b commit 3a559ca
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions TrackFileCleaner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ private static void RemoveUsedFiles(string folder)
/// <param name="folder">The track folder</param>
private static void AddUnusedFiles(string folder, int numSourceFiles)
{
// Skip folder if folder is an ignore folder
if (Globals.IgnoreFolders.Contains(folder, StringComparer.OrdinalIgnoreCase)) return;

string[] files = Directory.GetFiles(Environment.CurrentDirectory + '\\' + folder, "*", SearchOption.AllDirectories);
foreach (string file in files)
Expand All @@ -224,8 +226,8 @@ private static void AddUnusedFiles(string folder, int numSourceFiles)
int depth = CondensedFilePath.Split('/').Length - 1;
string extension = Path.GetExtension(FileName);

// Skip windows db files and skip any files in the ignore folders
if (extension == ".db" || Globals.IgnoreFolders.Contains(folder)) continue;
// Skip windows db files
if (extension == ".db") continue;

// if we have a saf file on the top level directory then we should skip this file
if (depth <= 1 && extension == ".saf") continue;
Expand All @@ -234,13 +236,13 @@ private static void AddUnusedFiles(string folder, int numSourceFiles)
if (depth <= 2)
{
// check if it's an ignore file
if (Globals.IgnoreFiles.Contains(FileName)) continue;
if (Globals.IgnoreFiles.Contains(FileName, StringComparer.OrdinalIgnoreCase)) continue;

// If we don't have any track source files in this folder we will check to see if skins are there instead
if (numSourceFiles == 0)
{
// TODO: Check for bike or rider skins
string? RiderKeyResult = Globals.RiderFilesToIgnore.FirstOrDefault<string>(skinName => FileName.StartsWith(skinName));
string? RiderKeyResult = Globals.RiderFilesToIgnore.FirstOrDefault<string>(skinName => FileName.StartsWith(skinName, StringComparison.OrdinalIgnoreCase));
char[] ValidNextCharacters = { '.', '-', '_', ' ' };


Expand All @@ -255,7 +257,7 @@ private static void AddUnusedFiles(string folder, int numSourceFiles)
}

string[] bikeSkinsToIgnore = Globals.BikesToIgnoreList.ToArray();
string? bikeKeyResult = bikeSkinsToIgnore.FirstOrDefault<string>(bikeSkin => FileName.StartsWith(bikeSkin));
string? bikeKeyResult = bikeSkinsToIgnore.FirstOrDefault<string>(bikeSkin => FileName.StartsWith(bikeSkin, StringComparison.OrdinalIgnoreCase));

if (bikeKeyResult != null)
{
Expand Down

0 comments on commit 3a559ca

Please sign in to comment.