Last active
August 29, 2015 14:17
-
-
Save DexterHaslem/6d4e3a193c61778d71b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.IO; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace asdf | |
{ | |
class CheckCase | |
{ | |
static void Main(string[] args) | |
{ | |
Stopwatch sw = Stopwatch.StartNew(); | |
// dont use '../' stuff here so we can just strip the string from file absolute path | |
var modDsDir = @"D:\FortressForever_246_DS\";//D:\Games\Steam\SteamApps\sourcemods\FortressForever\"; | |
var steamDsDir = @"D:\Games\Steam\SteamApps\common\Fortress Forever Dedicated Server\FortressForever\";//@"D:\Games\Steam\SteamApps\common\Fortress Forever\FortressForever\"; | |
// make sure to trim mod/release dir root off | |
Func<string, IEnumerable<string>> getFilesRelative = rootDir => | |
Directory.EnumerateFiles(rootDir, "*.*", SearchOption.AllDirectories) | |
.Select(f => f.Replace(rootDir, string.Empty)); | |
var modFiles = Task.Run(() => getFilesRelative(modDsDir)).Result.ToList(); | |
var releaseFiles = Task.Run(() => getFilesRelative(steamDsDir)).Result.ToList(); | |
// find files that match case insensitive, but do not match case wise (which could blow up linux) | |
var diffByCase = new Dictionary<string, string>(); // key = mod, val = release name | |
var modFilesByNormalized = new Dictionary<string, string>(); | |
foreach (var mf in modFiles) | |
modFilesByNormalized[mf.ToUpperInvariant()] = mf; | |
var steamFilesByNormalized = new Dictionary<string, string>(); | |
foreach (var sf in releaseFiles) | |
steamFilesByNormalized[sf.ToUpperInvariant()] = sf; | |
foreach (var kvp in steamFilesByNormalized) | |
{ | |
if (!modFilesByNormalized.ContainsKey(kvp.Key)) | |
{ | |
Console.WriteLine("Missing mod file '" + kvp.Value + "'"); | |
continue; | |
} | |
var modFileName = modFilesByNormalized[kvp.Key]; | |
var steamFileName = kvp.Value; | |
if (!string.Equals(modFileName, steamFileName, StringComparison.Ordinal)) | |
Console.WriteLine(string.Format("different files mod='{0}' steam='{1}'", modFileName, steamFileName)); | |
} | |
sw.Stop(); | |
Console.WriteLine("done in " + sw.ElapsedMilliseconds + " ms"); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment