Fix Unix having lower and uppercase files for songs

pull/45/head
Miepee 4 years ago
parent 6252e554c3
commit 86bf5ac9f3

@ -217,6 +217,7 @@ public static class CrossPlatformOperations
{
const string process = "xdelta3";
const string arguments = "-V";
// TODO: for mac, we need to embed two xdelta binaries, for x64 and arm
ProcessStartInfo xdeltaStart = new ProcessStartInfo
{

@ -87,6 +87,36 @@ public static class HelperMethods
Directory.Delete(targetDir, false);
}
/// <summary>
/// Recursively lowercases all files and folders from a specified directory.
/// </summary>
/// <param name="directory">The path to the directory whose contents should be lowercased.</param>
public static void LowercaseFolder(string directory)
{
DirectoryInfo dir = new DirectoryInfo(directory);
foreach(var file in dir.GetFiles())
{
if (file.Name == file.Name.ToLower()) continue;
// Windows is dumb, thus we need to move in two trips
file.MoveTo(file.DirectoryName + "/" + file.Name.ToLower() + "_");
string newPath = file.FullName.Substring(0, file.FullName.Length - 1);
File.Delete(newPath);
file.MoveTo(newPath);
}
foreach(var subDir in dir.GetDirectories())
{
if (subDir.Name == subDir.Name.ToLower()) continue;
// ReSharper disable once PossibleNullReferenceException - since this is a subdirectory, it always has a parent
// Windows is dumb, thus we need to move in two trips
subDir.MoveTo(subDir.Parent.FullName + "/" + subDir.Name.ToLower() + "_");
// -2 because after a moving operation, DirInfo already appends a /
subDir.MoveTo(subDir.FullName.Substring(0, subDir.FullName.Length-2));
LowercaseFolder(subDir.FullName);
}
}
/// <summary>
/// Calculates an MD5 hash from a given file.

@ -12,6 +12,8 @@ using AM2RLauncherLib.XML;
namespace AM2RLauncherLib;
// TODO: grey out create desktop shortcut on download mode
/// <summary>
/// An enum, that has possible return codes for <see cref="Profile.CheckIfZipIsAM2R11"/>.
/// </summary>
@ -50,6 +52,7 @@ public static class Profile
/// </summary>
/// <param name="invalidateCache">Determines if the AM2R_11 Cache should be invalidated.</param>
/// <returns></returns>
// TODO: returns ^
public static bool Is11Installed(bool invalidateCache = false)
{
// Only invalidate if we need to
@ -458,6 +461,10 @@ public static class Profile
if (!profile.UsesCustomMusic && useHqMusic)
HelperMethods.DirectoryCopy($"{Core.PatchDataPath}/data/HDR_HQ_in-game_music", tempPath);
// On Unix, everything needs to be lowercased, so we need to fix the AM2R_11 files / HQ songs
if (OS.IsUnix)
HelperMethods.LowercaseFolder(tempPath);
// Linux post-process
if (OS.IsLinux)
{

Loading…
Cancel
Save