diff --git a/CreamInstaller/Platforms/Steam/SteamCMD.cs b/CreamInstaller/Platforms/Steam/SteamCMD.cs index beccf0d..3518fdf 100644 --- a/CreamInstaller/Platforms/Steam/SteamCMD.cs +++ b/CreamInstaller/Platforms/Steam/SteamCMD.cs @@ -137,9 +137,42 @@ internal static partial class SteamCMD } }); + private static void MigrateLegacyFiles() + { + string oldFilePath = ProgramData.DirectoryPath + @"\steamcmd.exe"; + if (!oldFilePath.FileExists()) + return; + DirectoryPath.CreateDirectory(); + string[] steamCmdFiles = + [ + "steamcmd.exe", "steamcmd.exe.old", "steam.dll", "crashhandler.dll", + "tier0_s.dll", "vstdlib_s.dll", "steamclient.dll", "steamclient64.dll", + "steamerrorreporter.exe", "steamconsole.dll", "crashhandler64.dll", + "vstdlib_s64.dll", "steamconsole64.dll", "tier0_s64.dll", ".crash" + ]; + string[] steamCmdDirs = + [ + "logs", "bin", "public", "siteserverui", "package" + ]; + string oldDirectory = ProgramData.DirectoryPath; + foreach (string file in steamCmdFiles) + { + string source = oldDirectory + @"\" + file; + string dest = DirectoryPath + @"\" + file; + source.MoveFile(dest); + } + foreach (string dir in steamCmdDirs) + { + string source = oldDirectory + @"\" + dir; + string dest = DirectoryPath + @"\" + dir; + source.MoveDirectory(dest); + } + } + internal static async Task Setup(IProgress progress) { await Cleanup(); + MigrateLegacyFiles(); if (!FilePath.FileExists()) { bool retryDownload = true; diff --git a/CreamInstaller/Resources/Resources.cs b/CreamInstaller/Resources/Resources.cs index 0b14617..b75a4f8 100644 --- a/CreamInstaller/Resources/Resources.cs +++ b/CreamInstaller/Resources/Resources.cs @@ -51,6 +51,7 @@ internal static class Resources { using Stream resource = Assembly.GetExecutingAssembly() .GetManifestResourceStream("CreamInstaller.Resources." + resourceIdentifier); + Path.GetDirectoryName(filePath)?.CreateDirectory(); using FileStream file = new(filePath, FileMode.Create, FileAccess.Write); resource?.CopyTo(file); break; @@ -68,6 +69,7 @@ internal static class Resources while (!Program.Canceled) try { + Path.GetDirectoryName(filePath)?.CreateDirectory(); using FileStream fileStream = new(filePath, FileMode.Create, FileAccess.Write); fileStream.Write(resource); return true;