From 5dc09db449421ce567da2c7d200d2ff3037e78c5 Mon Sep 17 00:00:00 2001 From: cozyuno Date: Sun, 11 Dec 2016 18:38:14 -0600 Subject: [PATCH] Fixed null exception when importing package template --- RocksmithCustomSongCreator.sln | 7 - .../DLCPackageCreator/DLCPackageCreator.cs | 7 +- RocksmithTookitGUI/Resources/BetaInfo.rtf | Bin 1366 -> 815 bytes RocksmithTookitGUI/RocksmithToolkitGUI.csproj | 4 - RocksmithToolkitCLI/remastered/CLI.ico | Bin 67646 -> 0 bytes RocksmithToolkitCLI/remastered/Program.cs | 713 ----------- RocksmithToolkitCLI/remastered/Program.cs.org | 391 ------ .../remastered/Properties/AssemblyInfo.cs | 35 - .../Properties/Resources.Designer.cs | 63 - .../remastered/Properties/Resources.resx | 120 -- .../remastered/PsarcLoader/Entry.cs | 76 -- .../remastered/PsarcLoader/PSARC.cs | 1047 ----------------- .../remastered/PsarcLoader/PsarcExtensions.cs | 320 ----- .../remastered/PsarcLoader/PsarcLoader.cs | 397 ------- .../remastered/PsarcLoader/PsarcPackager.cs | 60 - .../remastered/remastered.csproj | 168 --- .../remastered/remastered.exe -org -pre.bat | 34 - .../remastered/remastered.exe -org.bat | 27 - .../remastered/remastered.exe -pre.bat | 28 - .../remastered/remastered.exe -ren.bat | 25 - .../remastered/remastered.exe.bat | 25 - VersionInfo.txt | 2 +- 22 files changed, 6 insertions(+), 3543 deletions(-) delete mode 100644 RocksmithToolkitCLI/remastered/CLI.ico delete mode 100644 RocksmithToolkitCLI/remastered/Program.cs delete mode 100644 RocksmithToolkitCLI/remastered/Program.cs.org delete mode 100644 RocksmithToolkitCLI/remastered/Properties/AssemblyInfo.cs delete mode 100644 RocksmithToolkitCLI/remastered/Properties/Resources.Designer.cs delete mode 100644 RocksmithToolkitCLI/remastered/Properties/Resources.resx delete mode 100644 RocksmithToolkitCLI/remastered/PsarcLoader/Entry.cs delete mode 100644 RocksmithToolkitCLI/remastered/PsarcLoader/PSARC.cs delete mode 100644 RocksmithToolkitCLI/remastered/PsarcLoader/PsarcExtensions.cs delete mode 100644 RocksmithToolkitCLI/remastered/PsarcLoader/PsarcLoader.cs delete mode 100644 RocksmithToolkitCLI/remastered/PsarcLoader/PsarcPackager.cs delete mode 100644 RocksmithToolkitCLI/remastered/remastered.csproj delete mode 100644 RocksmithToolkitCLI/remastered/remastered.exe -org -pre.bat delete mode 100644 RocksmithToolkitCLI/remastered/remastered.exe -org.bat delete mode 100644 RocksmithToolkitCLI/remastered/remastered.exe -pre.bat delete mode 100644 RocksmithToolkitCLI/remastered/remastered.exe -ren.bat delete mode 100644 RocksmithToolkitCLI/remastered/remastered.exe.bat diff --git a/RocksmithCustomSongCreator.sln b/RocksmithCustomSongCreator.sln index f0d6dcae9..7aa7bf783 100644 --- a/RocksmithCustomSongCreator.sln +++ b/RocksmithCustomSongCreator.sln @@ -70,8 +70,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ddc", "ddc", "{CB7159F6-4CF EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RocksmithToolkitUpdater", "RocksmithToolkitUpdater\RocksmithToolkitUpdater.csproj", "{4404D0DD-017E-4CC5-8302-3C150FDF06E7}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "remastered", "RocksmithToolkitCLI\remastered\remastered.csproj", "{88A34EB4-10FE-495C-9A54-97DBBBA37D2D}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -135,10 +133,6 @@ Global {4404D0DD-017E-4CC5-8302-3C150FDF06E7}.Debug|x86.Build.0 = Debug|x86 {4404D0DD-017E-4CC5-8302-3C150FDF06E7}.Release|x86.ActiveCfg = Release|x86 {4404D0DD-017E-4CC5-8302-3C150FDF06E7}.Release|x86.Build.0 = Release|x86 - {88A34EB4-10FE-495C-9A54-97DBBBA37D2D}.Debug|x86.ActiveCfg = Debug|x86 - {88A34EB4-10FE-495C-9A54-97DBBBA37D2D}.Debug|x86.Build.0 = Debug|x86 - {88A34EB4-10FE-495C-9A54-97DBBBA37D2D}.Release|x86.ActiveCfg = Release|x86 - {88A34EB4-10FE-495C-9A54-97DBBBA37D2D}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -155,7 +149,6 @@ Global {ED268869-387A-477E-A652-C6E47BE2AC02} = {7CFB8499-8B82-40B3-89EA-7971F5FD1E0C} {E742753F-9DC3-4AB7-B129-DC11EB2302CA} = {7CFB8499-8B82-40B3-89EA-7971F5FD1E0C} {FE4E3BDA-2942-4009-9F42-07ECEF8DE350} = {7CFB8499-8B82-40B3-89EA-7971F5FD1E0C} - {88A34EB4-10FE-495C-9A54-97DBBBA37D2D} = {7CFB8499-8B82-40B3-89EA-7971F5FD1E0C} {8BDB8985-CC6B-4479-A9A7-0489836D87CD} = {17ADB8C7-17DF-4BE3-8460-3E342F334B53} {CB7159F6-4CF1-4296-A7EA-BCC4127C0441} = {17ADB8C7-17DF-4BE3-8460-3E342F334B53} EndGlobalSection diff --git a/RocksmithTookitGUI/DLCPackageCreator/DLCPackageCreator.cs b/RocksmithTookitGUI/DLCPackageCreator/DLCPackageCreator.cs index 3631d2c05..43dcd02bc 100644 --- a/RocksmithTookitGUI/DLCPackageCreator/DLCPackageCreator.cs +++ b/RocksmithTookitGUI/DLCPackageCreator/DLCPackageCreator.cs @@ -209,7 +209,7 @@ public string AverageTempo { AverageTempoTB.Text = value.GetValidTempo(); } } - public string PackageVersion + public string PackageVersion { get { return packageVersionTB.Text; } @@ -1023,6 +1023,9 @@ private void FillPackageCreatorForm(DLCPackageData info, string filesBaseDir) platformXBox360.Checked = info.XBox360; platformPS3.Checked = info.PS3; + if (info.ToolkitInfo == null) + info.ToolkitInfo = new ToolkitInfo{PackageVersion = "1"}; + PackageVersion = info.ToolkitInfo.PackageVersion; PackageComment = info.ToolkitInfo.PackageComment; @@ -1464,7 +1467,7 @@ private DLCPackageData GetPackageData() ToolkitInfo = new ToolkitInfo { PackageVersion = PackageVersion.GetValidVersion(), - PackageComment = PackageComment + PackageComment = PackageComment }, AlbumArtPath = AlbumArtPath, diff --git a/RocksmithTookitGUI/Resources/BetaInfo.rtf b/RocksmithTookitGUI/Resources/BetaInfo.rtf index e00ef9eaf812ae08fbd3c32bdd3eae9705f52559..2e96c69254a1d55e9bc7eb5cfb2f696645de9689 100644 GIT binary patch delta 78 zcmcb{wVrLmXGSNt%!Ef+)&YiZXr-#`Dq`}4)!$*y*)rd9hv}|ko!Pj9OTRL3fN2g@lU?kFHgR!&M^(F z^h~{)zgHvU?)Gx%(A6@*iuf~HQ-2{05YX)jbnq=?@21lv(FKa+_z6}*Eq$m6xFNU* zyfl^~UDYU!3mFg{W^Zy|ec;Uf$7IN^{Ktn|x8}Gnq@Xp@A zC+}#Uf-)i)quD#LgHh_`Af3UtWDF|rYLhx2mBxSaNKz#S!q%FENV$70cyAAe*G_xz zyRTI7)05^+3ND42yjsY;(`Mg`ZIOKoHEHZEL*c7KY{zs#vuSn;$-bm?4k{@_ey-HE z__!)Au3)*|T$b>9_;B_{sgh+lrR1Sti(MC$s(jmuA@x8MVB#qqv$KaG)3=uWZ2Gvb NboTdM{a8J}{{yLF=3W2* diff --git a/RocksmithTookitGUI/RocksmithToolkitGUI.csproj b/RocksmithTookitGUI/RocksmithToolkitGUI.csproj index 69bad7606..34c0b5097 100644 --- a/RocksmithTookitGUI/RocksmithToolkitGUI.csproj +++ b/RocksmithTookitGUI/RocksmithToolkitGUI.csproj @@ -367,10 +367,6 @@ {822D185A-28A3-4AE0-A811-800E968AA2E7} packer - - {88A34EB4-10FE-495C-9A54-97DBBBA37D2D} - remastered - {8FDBC548-DEBF-46D6-A933-33C8D72F33AB} sng2014 diff --git a/RocksmithToolkitCLI/remastered/CLI.ico b/RocksmithToolkitCLI/remastered/CLI.ico deleted file mode 100644 index f57db7cacbef6ec387b6fc40e73aa8da33958ce2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 67646 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%0AjX;O{$)-wFKTqWLr(H^n@!ADD6mAXs_Z zG-Wy~Hod;8{mC8>4~6~rXT`*$4XmSJm(T#O7hw5lhGVs8bdjbGVe%S$|R6cJnV9zuo1-g>h`2?UYfE zf9Lywt%bjIpvm>B&*2_7DHGdQC+WW!+4I+G+h&_mFMhP3bx^wQVi`vcLae`-!C`_gI}+S)KN3 z+ih`7US-O}zwGzF%Z!2SRo|wS*Uq@xxNAL4$!swAhvqt1`#|#Qwm2lyDtSZ2Uvu@j zD8H%L@4s8Fo05hMTep-~l^6Wm@%`Vb z^J%(Wx9}}mM^(A;{-5Q~-+$)szc%&$Z`FA<)vicx-BMmvUgEF&KmGmh9{=I-Tv+?J z$N$5DXAD*rl25nCcFkqdG5z=d{uh3N^8&IgGsaNX?RM^3Ulkd{((+%tc(I!`YnGch zabo8G^Y~X8YpB{tKHVNyk#CRx@bdAoJ=|&h*;{4iME$aDQu>d{teeVGWZ~Dr_7nL1 z&(*6}ySnxtd1{P2mbQ-S68HGmvqe^xscE18qD6}u^Z%B=P3O%mkAF(rygteACLNEh zB_@NsGWhfR&*(qDPq1*|!p8X9G3zj_)3(Pyd{2yAkZT_Q2@@uiKL6+0b&X~BLz#4s zf0|z?BU3SHl7HFp^XkX;QC^!^e#~ZeQ&~&~p|Ym+KQu-s)BDqo%bIsf(er}^07uurP+->_lB7WzMa{P@!6ztnNd z)I;87>WAtM2WCyqF(iXfp4I&Ib6|>(4&>EMvQJKB7KmPcm`}yae-S^*rpYf;d zmtTI_3&UInUw!pe#t@$PChYsNWy>7D0l8wu3is=;zdHZl@4x@^(Z&~pE f@9f#L`CAsfe?1BGB+!#UPXav&^dzvAN#OqhIM1!f diff --git a/RocksmithToolkitCLI/remastered/Program.cs b/RocksmithToolkitCLI/remastered/Program.cs deleted file mode 100644 index aaf6b098a..000000000 --- a/RocksmithToolkitCLI/remastered/Program.cs +++ /dev/null @@ -1,713 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Xml.Linq; -using RocksmithToolkitLib.DLCPackage; -using RocksmithToolkitLib.Extensions; -using RocksmithToolkitLib.PsarcLoader; -using RocksmithToolkitLib.Sng; -using RocksmithToolkitLib.Xml; - -namespace remastered -{ - class Program - { - private enum MessageType { Default, Info, Warning, Error, Other }; - private const ConsoleColor DefaultBackColor = ConsoleColor.Black; - private const ConsoleColor DefaultForeColor = ConsoleColor.Green; - private const string LogFileName = "remastered_error.log"; - private const string TKI_ARRID = "(Arrangement ID by CLI)"; - private const string TKI_REMASTER = "(Remastered by CLI)"; - private const string corExt = ".cor"; - private const string orgExt = ".org"; - private static List cleanFolders = new List(); - private static bool optionLog; - private static bool optionOrg; - private static bool optionPre; - private static bool optionRen; - private static bool optionSil; - private static string platformExt; - private static StringBuilder sbErrors = new StringBuilder(); - private static string workDirectory; - - private static int Main(string[] args) - { - Console.Title = AppDomain.CurrentDomain.FriendlyName; - Console.WindowWidth = 85; - Console.WindowHeight = 35; - Console.BackgroundColor = DefaultBackColor; - Console.ForegroundColor = DefaultForeColor; - -#if (DEBUG) - // give the progie some dumby file to work on - // args = new string[] { "D:\\Temp\\Test\\The_Beatles-NowhereMan_p.psarc" }; - // args = new string[] { "D:\\Temp\\Test\\PeppaPig_p.psarc" }; - args = new string[] { "D:\\Temp\\test" }; - // args = new string[] { "-org", "-pre", "D:\\Temp\\Test\\PeppaPig_p.psarc.org" }; - // args = new string[] { "-pre", "D:\\Temp\\Test\\PeppaPig_p.psarc" }; - // args = new string[] { "-ren", "D:\\Temp\\Test\\PeppaPig_p.psarc.org" }; - // args = new string[] { "-log \"D:\\Temp\\Test\"", "D:\\Temp\\Test\\PeppaPig_p.psarc" }; - ShowMessage("Running in Debug Mode ... Help is not available"); -#endif - - // catch if there are no cmd line arguments - if (args.GetLength(0) == 0) args = new string[] { "?" }; - if (args[0].Contains(@"?") || args[0].ToLower().Contains(@"help")) - { - var helpMsg = - "remastered.exe DropletApp for Rocksmith 2014 CDLC" + Environment.NewLine + Environment.NewLine + - " - PC Version: " + ProjectVersion() + Environment.NewLine + - " Copyright (C) 2016 Toolkit Developers" + Environment.NewLine + Environment.NewLine + - " - Purpose: Converts CDLC for use with Rocksmith 2014 Remastered Version." + Environment.NewLine + - " Repairs the 100% bug issue and improves mastery function." + Environment.NewLine + - " Original (*.psarc) files will be renamed as (*.psarc.org)." + Environment.NewLine + - " ODLC and CDLC that have already been repaired are skipped." + Environment.NewLine + - " The CDLC version number is not changed by this tool." + Environment.NewLine + - " Use the toolkit CDLC Creator feature to change version numbers." + Environment.NewLine + Environment.NewLine + - " - Now includes CDLC corruption and validation checking" + Environment.NewLine + Environment.NewLine + - " - Usage: Drag/Drop CDLC song file(s) and/or folder(s) onto the executable." + Environment.NewLine + - " There is typically a 132 character limit for Drag/Drop content." + Environment.NewLine + Environment.NewLine + - " - CLI Command Prompt Syntax:" + Environment.NewLine + - " remastered.exe [option] [option] [source1] [source2] [source3].." + Environment.NewLine + - " option: [-org] to remaster files that have extension (.org)" + Environment.NewLine + - " option: [-pre] to repair CDLC that have not been played in" + Environment.NewLine + - " Rocksmith 2014 Remastered and preserve song stats." + Environment.NewLine + - " option: [-ren] to rename (.org) files to (.psarc) files" + Environment.NewLine + - " option: [-log] [directory path] to specify a custom log path" + Environment.NewLine + - " folder for CLI generated (.org), (.cor), and (.log) files" + Environment.NewLine + - " source: [Pathname] of CDLC files or folders to be repaired]" + Environment.NewLine + Environment.NewLine; - ShowMessage(helpMsg); - - var warningMsg = - " - WARNING: Do not use this DroplettApp for short jingle/riff CDLC." + Environment.NewLine + - " CDLC with less than 30 seconds audio will not be synced properly." + Environment.NewLine + Environment.NewLine + - " Make sure all CDLC with (.org) or (.cor) have been removed from" + Environment.NewLine + - " the Rocksmith 2014 'dlc' folder prior to playing the game." + Environment.NewLine + Environment.NewLine; - ShowMessage(warningMsg, MessageType.Warning); - - var footerMsg = - "The more you Drag/Drop the longer it takes to process. Coffee break + Environment.NewLine +)" + Environment.NewLine + Environment.NewLine + - "Press any key to continue ..."; - ShowMessage(footerMsg); - if (!optionSil) - Console.ReadKey(); - return 0; - } - - // ShowMessage(@"Initializing Remastered CLI ...", prefixLine: true, postfixLine: true); - ShowMessage("Remastred CLI has been depricated ...", MessageType.Warning); // a bad thing - ShowMessage("Please use Bulk Repair feature in CFSM ...", MessageType.Warning); // a bad thing - Console.WriteLine(); - if (!optionSil) - Console.ReadKey(); - return 0; - - // set and add the default workDirectory to cleanDirectories list so that no files get deleted - workDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "REMASTERED_CLI"); - cleanFolders.Add(workDirectory); - - // detect, set and remove [option] from args - var argsClean = args; - for (int i = 0; i < args.Length; i++) - { - switch (args[i].Substring(0, 4).ToLower()) - { - case "-org": - optionOrg = true; - // TODO: move to code grave yard - // argsClean = argsClean.Where((src, ndx) => ndx != i).ToArray(); - argsClean = argsClean.Where(x => x != args[i]).ToArray(); - ShowMessage("CLI option [-org] was found ..."); - break; - case "-pre": - optionPre = true; - argsClean = argsClean.Where(x => x != args[i]).ToArray(); - ShowMessage("CLI option [-pre] was found ..."); - break; - case "-ren": - optionRen = true; - argsClean = argsClean.Where(x => x != args[i]).ToArray(); - ShowMessage("CLI option [-ren] was found ..."); - break; - case "-log": - optionLog = true; - workDirectory = args[i].Substring(5).Trim().Trim('"'); - // add the user specified workDirectory to cleanDirectories list - cleanFolders.Add(workDirectory); - argsClean = argsClean.Where(x => x != args[i]).ToArray(); - ShowMessage("CLI option [-log] was found ..."); - ShowMessage("Custom Log Path: " + workDirectory); - break; - case "-sil": - optionSil = true; - argsClean = argsClean.Where(x => x != args[i]).ToArray(); - ShowMessage("CLI option [-sil] was found ..."); - break; - } - } - - if ((optionOrg || optionPre) && optionRen) - { - ShowMessage("Multiple CLI options may not be used with option [-ren]", MessageType.Warning, prefixLine: true, postfixLine: true); - ShowMessage("Press any key to continue ..."); - if (!optionSil) - Console.ReadKey(); - return 4; - } - - if (!Directory.Exists(workDirectory)) - Directory.CreateDirectory(workDirectory); - - args = argsClean; - foreach (var arg in args) - { - // throws a good error if directory/file is not found - if (IsDirectory(arg)) - { - ShowMessage("Parsing folder: " + arg, prefixLine: true, postfixLine: true); - - // enumerate files and skip empty folders - var allFiles = Directory.EnumerateFiles(arg, "*", SearchOption.AllDirectories).ToList(); - if (!allFiles.Any()) - continue; - - if (optionRen) - RenameFiles(allFiles); - else - { - // cleanup the directory removing (.org) and (.cor) files - CleanArgFolder(arg); - RepairFiles(allFiles); - } - } - else // single files - { - if (optionOrg && !arg.ToLower().Contains(orgExt)) - { - ShowMessage(arg + ", Can not be repaired using CLI option [-org]", MessageType.Error, prefixLine: true, postfixLine: true); - continue; - } - - if (optionRen) - RenameFiles(new string[] { arg }); - else - { - // cleanup the directory removing (.org) and (.cor) files - CleanArgFolder(Path.GetDirectoryName(arg)); - RepairFiles(new string[] { arg }); - } - } - } - - var errorLogLines = Regex.Matches(sbErrors.ToString(), Environment.NewLine).Count; - if (errorLogLines > 0) - { - // error log can be turned into CSV file - sbErrors.Insert(0, "File Path, Error Message" + Environment.NewLine); - sbErrors.Insert(0, DateTime.Now.ToString("MM-dd-yy HH:mm") + Environment.NewLine); - var errorLogPath = Path.Combine(workDirectory, LogFileName); - using (TextWriter tw = new StreamWriter(errorLogPath, true)) - { - tw.WriteLine(sbErrors + Environment.NewLine); - tw.Close(); - } - } - -#if (!DEBUG) - CleanLocalTemp(); -#endif - - if (optionRen) - { - var renMsg = - "Done renaming CDLC (.org) to (.psarc) ..." + Environment.NewLine + - "Now you can use the CLI with option [-pre] to" + Environment.NewLine + - "preserve original song stats and redo the repair."; - ShowMessage(renMsg, prefixLine: true, postfixLine: true); - // - var infoMsg = - "The [-pre] option does not work for CDLC that have" + Environment.NewLine + - "been played in Rocksmith 2014 Remastered because the" + Environment.NewLine + - "100% bug is already stored to the game save song stats."; - ShowMessage(infoMsg, MessageType.Info, postfixLine: true); - } - else - { - ShowMessage("Done applying Remastered Repair to CDLC ...", prefixLine: true, postfixLine: true); - ShowMessage(" - 'Notice: Unrecognized line in toolkit.version'", MessageType.Info); - ShowMessage(" is an informational message. This indicates the"); - ShowMessage(" original CDLC was produced with an older version"); - ShowMessage(" of the toolkit. The Remastered CDLC has been"); - ShowMessage(" updated to the current version of the toolkit.", postfixLine: true); - // - ShowMessage(" Log Path Folder used (.org), (.cor), and (.log) files:", MessageType.Info); - ShowMessage(" " + workDirectory, MessageType.Info, postfixLine: true); - // - ShowMessage(" - The original non-remastered CDLC have been renamed with"); - ShowMessage(" file extension (.org) and moved to the log path folder."); - ShowMessage(" The (.org) backup files can be archived or deleted after"); - ShowMessage(" it is confirm that the Remastered CDLC are working.", postfixLine: true); - // - ShowMessage(" - Corrupt CDLC have been renamed with file extension (.cor)"); - ShowMessage(" and moved to the log path folder."); - ShowMessage(" Corrupt (non-repairable) CDLC should be submitted to"); - ShowMessage(" the original charter so they can be repaired.", postfixLine: true); - // - ShowMessage(" - See the 'remastered_error.log' in the log path folder"); - ShowMessage(" for a list of non-repairable files.", postfixLine: true); - } - ShowMessage("Press any key to continue ..."); - if (!optionSil) - Console.ReadKey(); - return 0; - } - - private static void CleanArgFolder(string argFolderPath) - { - // only clean a directory once to save time - if (cleanFolders.Contains(argFolderPath)) - return; - - // remove (.org) and (.cor) files from dlc folder and subfolders - ShowMessage("Cleaning arg folder and subfolders ..."); - bool neededCleaning = false; - - string[] extensions = { orgExt, corExt }; - foreach (var extension in extensions) - { - var filter = String.Format("*{0}*", extension); - var filterFilePaths = Directory.EnumerateFiles(argFolderPath, filter, SearchOption.AllDirectories).ToList(); - foreach (var filterFilePath in filterFilePaths) - { - neededCleaning = true; - var destFilePath = Path.Combine(workDirectory, Path.GetFileName(filterFilePath)); - try - { - File.SetAttributes(filterFilePath, FileAttributes.Normal); - if (!File.Exists(destFilePath)) - { - File.Copy(filterFilePath, destFilePath, true); - ShowMessage("Moved file: " + Path.GetFileName(filterFilePath)); - } - else - ShowMessage("Deleted duplicate file: " + Path.GetFileName(filterFilePath)); - - // this could throw an error if file is "Read-Only" or does not exist - File.Delete(filterFilePath); - } - catch (IOException ex) - { - ShowMessage(filterFilePath + ", " + ex.Message, MessageType.Error, prefixLine: true, postfixLine: true); - } - } - } - - if (neededCleaning) - ShowMessage("Finished cleaning: " + argFolderPath + " ...", postfixLine: true); - else - ShowMessage(argFolderPath + " didn't need cleaning ...", postfixLine: true); - - cleanFolders.Add(argFolderPath); - } - - private static void CleanLocalTemp() - { - var di = new DirectoryInfo(Path.GetTempPath()); - - // 'Local Settings\Temp' in WinXp - // 'AppData\Local\Temp' in Win7 - // confirm this is the correct temp directory before deleting - if (di.Parent != null) - { - if (di.Parent.Name.Contains("Local") && di.Name == "Temp") - { - foreach (FileInfo file in di.GetFiles()) - try - { - file.Delete(); - } - catch { /*Don't worry just skip locked file*/ } - - foreach (DirectoryInfo dir in di.GetDirectories()) - try - { - dir.Delete(true); - } - catch { /*Don't worry just skip locked directory*/ } - } - } - } - - private static bool CreateBackup(string srcFilePath) - { - if (srcFilePath.ToLower().Contains(orgExt)) - return false; - - ShowMessage("File: " + Path.GetFileName(srcFilePath), MessageType.Info, prefixLine: true); - ShowMessage(" - Making a backup copy ..."); - try - { - var properExt = Path.GetExtension(srcFilePath); - var orgFilePath = String.Format(@"{0}{1}{2}", Path.Combine(workDirectory, Path.GetFileNameWithoutExtension(srcFilePath)), orgExt, properExt).Trim(); - if (!File.Exists(orgFilePath)) - { - File.SetAttributes(srcFilePath, FileAttributes.Normal); - File.Copy(srcFilePath, orgFilePath, false); - ShowMessage(" - Sucessfully created backup ..."); - } - else - ShowMessage(" - Backup already exists ..."); - } - catch (Exception ex) - { - ShowMessage(" - Backup failed ...", MessageType.Warning); // a bad thing - ShowMessage(ex.Message, MessageType.Warning); - ShowMessage(srcFilePath + ", Backup Failed", MessageType.Error, prefixLine: true, postfixLine: true); - return false; - } - return true; - } - - private static ConsoleColor GetMessageColor(MessageType msgType) - { - switch (msgType) - { - case MessageType.Default: - return ConsoleColor.Green; - case MessageType.Info: - return ConsoleColor.Cyan; - case MessageType.Warning: - return ConsoleColor.Yellow; - case MessageType.Error: - return ConsoleColor.Red; - } - return ConsoleColor.Green; - } - - private static int GetMessageReturnValue(MessageType msgType) - { - switch (msgType) - { - case MessageType.Default: - return 0; - case MessageType.Info: - return 1; - case MessageType.Warning: - return 2; - case MessageType.Error: - return 3; - } - return 4; - } - - private static bool IsDirectory(string path) - { - bool isDirectory = false; - try - { - FileAttributes attr = File.GetAttributes(path); - if ((attr & FileAttributes.Directory) == FileAttributes.Directory) - isDirectory = true; - } - catch (Exception ex) - { - if (ex.Message.Contains("find file")) - ShowMessage(path + ", File Not Found", MessageType.Warning, true); - else - ShowMessage(path + ", " + ex.Message, MessageType.Warning, true); - } - return isDirectory; - } - - private static string OfficialOrRepaired(string filePath) - { - ToolkitInfo entryTkInfo; - try - { - using (var browser = new PsarcLoader(filePath, true)) - entryTkInfo = browser.ExtractToolkitInfo(); - } - catch (Exception ex) - { - ShowMessage(SplitString(ex.Message, 55), prefixLine: true, postfixLine: true); - return null; - } - - - if (entryTkInfo == null) - return "Official"; - - if (entryTkInfo != null && entryTkInfo.PackageAuthor != null) - if (entryTkInfo.PackageAuthor.Equals("Ubisoft")) - return "Official"; - - if (entryTkInfo != null && entryTkInfo.PackageComment != null) - if (entryTkInfo.PackageComment.Contains("Remastered")) - return "Remastered"; - - return null; - } - - private static string ProjectVersion() - { - return String.Format(@"{0}.{1}.{2}", - Assembly.GetExecutingAssembly().GetName().Version.Major, - Assembly.GetExecutingAssembly().GetName().Version.Minor, - Assembly.GetExecutingAssembly().GetName().Version.Build); - } - - private static void RemasterSong(string srcFilePath) - { - try - { - // SNG's needs to be regenerated - // ArrangmentIDs are stored in multiple place and all need to be updated - // therefore we are going to unpack, apply repair, and repack - ShowMessage(" - Extracting CDLC artifacts ..."); - DLCPackageData packageData; - - using (var psarcOld = new PsarcPackager()) - packageData = psarcOld.ReadPackage(srcFilePath); - - // Update arrangement song info - foreach (Arrangement arr in packageData.Arrangements) - { - if (!optionPre) - { - // generate new AggregateGraph - arr.SongFile = new RocksmithToolkitLib.DLCPackage.AggregateGraph.SongFile { File = "" }; - - // generate new Arrangement IDs - arr.Id = IdGenerator.Guid(); - arr.MasterId = RandomGenerator.NextInt(); - } - - // skip vocal and showlight arrangements - if (arr.ArrangementType == ArrangementType.Vocal || arr.ArrangementType == ArrangementType.ShowLight) - continue; - - // validate SongInfo - var songXml = Song2014.LoadFromFile(arr.SongXml.File); - songXml.AlbumYear = packageData.SongInfo.SongYear.ToString().GetValidYear(); - songXml.ArtistName = packageData.SongInfo.Artist.GetValidAtaSpaceName(); - songXml.Title = packageData.SongInfo.SongDisplayName.GetValidAtaSpaceName(); - songXml.AlbumName = packageData.SongInfo.Album.GetValidAtaSpaceName(); - songXml.ArtistNameSort = packageData.SongInfo.ArtistSort.GetValidSortableName(); - songXml.SongNameSort = packageData.SongInfo.SongDisplayNameSort.GetValidSortableName(); - songXml.AlbumNameSort = packageData.SongInfo.AlbumSort.GetValidSortableName(); - songXml.AverageTempo = Convert.ToSingle(packageData.SongInfo.AverageTempo.ToString().GetValidTempo()); - - // write updated xml arrangement - using (var stream = File.Open(arr.SongXml.File, FileMode.Create)) - songXml.Serialize(stream, true); - - // add comments back to xml arrangement - Song2014.WriteXmlComments(arr.SongXml.File, arr.XmlComments); - } - - if (!optionPre) - { - // add comment to ToolkitInfo to identify CDLC - var arrIdComment = packageData.ToolkitInfo.PackageComment; - if (String.IsNullOrEmpty(arrIdComment)) - arrIdComment = TKI_ARRID; - else if (!arrIdComment.Contains(TKI_ARRID)) - arrIdComment = arrIdComment + " " + TKI_ARRID; - - packageData.ToolkitInfo.PackageComment = arrIdComment; - } - - // add comment to ToolkitInfo to identify CDLC - var remasterComment = packageData.ToolkitInfo.PackageComment; - if (String.IsNullOrEmpty(remasterComment)) - remasterComment = TKI_REMASTER; - else if (!remasterComment.Contains(TKI_REMASTER)) - remasterComment = remasterComment + " " + TKI_REMASTER; - - packageData.ToolkitInfo.PackageComment = remasterComment; - - // add default package version if missing - if (String.IsNullOrEmpty(packageData.ToolkitInfo.PackageVersion)) - packageData.ToolkitInfo.PackageVersion = "1"; - else - packageData.ToolkitInfo.PackageVersion = packageData.ToolkitInfo.PackageVersion.GetValidVersion(); - - // validate packageData (important) - packageData.Name = packageData.Name.GetValidKey(); // DLC Key - ShowMessage(" - Repackaging remastered CDLC ..."); - - // regenerates the SNG with the repair and repackages - using (var psarcNew = new PsarcPackager(true)) - psarcNew.WritePackage(srcFilePath, packageData); - - ShowMessage(" - Repair was sucessful ..."); - } - catch (Exception ex) - { - ShowMessage(" - Repair failed ... " + SplitString(ex.Message, 55), MessageType.Warning); - ShowMessage(" - See 'remastered_error.log' file ... ", MessageType.Warning); - ShowMessage(srcFilePath + ", Corrupt File", MessageType.Error, postfixLine: true); - - // copy (org) to corrupt (cor), delete backup (org), delete original - var properExt = Path.GetExtension(srcFilePath); - var orgFilePath = String.Format(@"{0}{1}{2}", Path.Combine(workDirectory, Path.GetFileNameWithoutExtension(srcFilePath)), orgExt, properExt).Trim(); - if (File.Exists(orgFilePath)) - { - var corFilePath = String.Format(@"{0}{1}{2}", Path.Combine(workDirectory, Path.GetFileNameWithoutExtension(srcFilePath)), corExt, properExt).Trim(); - File.Copy(orgFilePath, corFilePath, true); - File.Delete(orgFilePath); - File.Delete(srcFilePath); - } - } - } - - private static List RenameFiles(IEnumerable srcFilePaths) - { - var renamedFilePaths = new List(); - - foreach (var srcFilePath in srcFilePaths) - { - var destFilePath = srcFilePath; - if (srcFilePath.ToLower().Contains(orgExt)) - destFilePath = srcFilePath.Replace(orgExt, ""); - if (srcFilePath.ToLower().Contains(corExt)) - destFilePath = srcFilePath.Replace(corExt, ""); - - try - { - File.SetAttributes(srcFilePath, FileAttributes.Normal); - if (!File.Exists(destFilePath)) - { - File.Copy(srcFilePath, destFilePath, true); - renamedFilePaths.Add(destFilePath); - ShowMessage("Moved file: " + Path.GetFileName(srcFilePath)); - } - - // this could throw an error if file is "Read-Only" or does not exist - File.Delete(srcFilePath); - ShowMessage("Deleted file: " + Path.GetFileName(srcFilePath)); - } - catch (IOException ex) - { - ShowMessage(srcFilePath + ", " + ex.Message, MessageType.Error, prefixLine: true, postfixLine: true); - } - } - - return renamedFilePaths; - } - - private static void RepairFiles(IEnumerable srcFilePaths) - { - foreach (var srcFilePath in srcFilePaths) - { - // srcFilePath may have been removed by CleanArgFolder - if (!File.Exists(srcFilePath)) - continue; - - if (!srcFilePath.IsValidPSARC()) - ShowMessage(srcFilePath + ", Is not a valid CDLC", MessageType.Error, prefixLine: true, postfixLine: true); - else - { - var officialOrRepaired = OfficialOrRepaired(srcFilePath); - if (String.IsNullOrEmpty(officialOrRepaired)) - { - if (CreateBackup(srcFilePath)) - RemasterSong(srcFilePath); - } - else - { - if (officialOrRepaired.Contains(@"Official")) - ShowMessage("Skipped ODLC File: " + Path.GetFileName(srcFilePath), MessageType.Warning); - else if (officialOrRepaired.Contains(@"Remastered")) - ShowMessage("Skipped Remastered File: " + Path.GetFileName(srcFilePath), MessageType.Warning); - } - } - } - } - - private static int ShowMessage(string message, MessageType msgType = MessageType.Default, bool writeLog = false, bool prefixLine = false, bool postfixLine = false) - { - if (prefixLine) - Console.WriteLine(); - - Console.ForegroundColor = GetMessageColor(msgType); - Console.WriteLine(message); - Console.ForegroundColor = DefaultForeColor; - - if (postfixLine) - Console.WriteLine(); - - if (writeLog || msgType == MessageType.Error) - sbErrors.AppendLine(message); - - return GetMessageReturnValue(msgType); - } - - /// - /// Splits a text string so that it wraps to specified line length - /// - /// - /// - /// - /// - private static string SplitString(string inputText, int lineLength, bool splitOnSpace = true) - { - var finalString = String.Empty; - - if (splitOnSpace) - { - var delimiters = new[] { " " }; // , "\\" }; - var stringSplit = inputText.Split(delimiters, StringSplitOptions.None); - var charCounter = 0; - - for (int i = 0; i < stringSplit.Length; i++) - { - finalString += stringSplit[i] + " "; - charCounter += stringSplit[i].Length; - - if (charCounter > lineLength) - { - finalString += Environment.NewLine; - charCounter = 0; - } - } - } - else - { - for (int i = 0; i < inputText.Length; i += lineLength) - { - if (i + lineLength > inputText.Length) - lineLength = inputText.Length - i; - - finalString += inputText.Substring(i, lineLength) + Environment.NewLine; - } - finalString = finalString.TrimEnd(Environment.NewLine.ToCharArray()); - } - - return finalString; - } - - } -} - -/* Graveyard - // determine platform from the first file name in directory - var di = new DirectoryInfo(srcFolderPath); - var fileName = di.EnumerateFiles().Select(f => f.Name).FirstOrDefault(); - // check if folder is empty - if (String.IsNullOrEmpty(fileName)) - return; - - var filePlatform = fileName.GetPlatform(); - var arcExt = filePlatform.platform; - - * - * string[] extensions = { orgExt, corExt }; - var extFilePaths = Directory.EnumerateFiles(argFolderPath, "*.*", SearchOption.AllDirectories) - .Where(fi => extensions.Any(fi.ToLower().Contains)).ToList(); - -*/ \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/Program.cs.org b/RocksmithToolkitCLI/remastered/Program.cs.org deleted file mode 100644 index ca67e5041..000000000 --- a/RocksmithToolkitCLI/remastered/Program.cs.org +++ /dev/null @@ -1,391 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Xml.Linq; -using RocksmithToolkitLib.DLCPackage; -using RocksmithToolkitLib.Extensions; -using RocksmithToolkitLib.Sng; -using RocksmithToolkitLib.Xml; - -namespace remastered -{ - class Program - { - private static StringBuilder sbErrors = new StringBuilder(); - - private static int Main(string[] args) - { - Console.WindowWidth = 80; - Console.BackgroundColor = ConsoleColor.Black; - Console.ForegroundColor = ConsoleColor.Green; - -#if (DEBUG) - // give the progie some dumby file to work on - args = new string[] { "D:\\Temp\\Test\\The_Beatles-NowhereMan_p.psarc" }; - Console.WriteLine(@"Running in Debug Mode ... help is not available"); -#endif - - // catch if there are no cmd line arguments - if (args.GetLength(0) == 0) args = new string[] { "?" }; - if (args[0].Contains(@"?") || args[0].ToLower().Contains(@"help")) - { - Console.WriteLine(@"remastered DropletApp for Rocksmith 2014 CDLC"); - Console.WriteLine(@" - Now includes CDLC corruption and validation checking"); - Console.WriteLine(); - Console.WriteLine(@" - Mac/PC Version: " + ProjectVersion()); - Console.WriteLine(@" Copyright (C) 2016 Toolkit Developers"); - Console.WriteLine(); - Console.WriteLine(@" - Purpose: Converts CDLC for use with Rocksmith 2014 Remastered Version."); - Console.WriteLine(@" Repairs the 100% bug issue and improves mastery function."); - Console.WriteLine(@" Original (*.psarc) files will be renamed as (*.psarc.org)."); - Console.WriteLine(@" ODLC and CDLC that have already been repaired are skipped."); - Console.WriteLine(@" The CDLC version number is not changed by this tool."); - Console.WriteLine(@" User the toolkit CDLC Creator to change a version number."); - Console.WriteLine(); - Console.WriteLine(@" - Usage: Drag/Drop CDLC song file(s) and/or folder(s) onto the executable."); - Console.WriteLine(@" Dragged/Dropped content typically has a 132 character limit."); - Console.WriteLine(); - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine(@" - WARNING: Do not use this DroplettApp for short jingle/riff CDLC."); - Console.WriteLine(@" Audio with less than 30 seconds duration will not be synced properly."); - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine(); - Console.WriteLine(@"The more you Drag/Drop the longer it takes to process. Coffee break ;)"); - Console.Read(); - return 0; - } - - Console.WriteLine(@"Initializing Remastered CLI ..."); - sbErrors.AppendLine("remastered.exe CLI failed to repair the following files:"); - - foreach (var arg in args) - { - if (IsDirectory(arg)) - { - Console.WriteLine(); - Console.WriteLine(@"Parsing folder: " + arg); - Console.WriteLine(); - - // enumerate files *.psarc - var cdlcFiles = Directory.EnumerateFiles(arg, "*.psarc", SearchOption.TopDirectoryOnly); - if (!cdlcFiles.Any()) - return ShowHelpfulError(@"Can not find any CDLC files (*.psarc)"); - - RepairFiles(cdlcFiles); - } - else - RepairFiles(new string[] { arg }); - } - - var errorLogLines = Regex.Matches(sbErrors.ToString(), Environment.NewLine).Count; - if (errorLogLines > 1) - { - var errorLogPath = Path.Combine(Path.GetDirectoryName(args[0]), "remastered_error.log"); - File.WriteAllText(errorLogPath, sbErrors.ToString().TrimEnd('\r', '\n')); - } - - Console.WriteLine(); - Console.WriteLine(@"Done applying Remastered Repair to CDLC ..."); - Console.WriteLine(); - Console.ForegroundColor = ConsoleColor.Cyan; - Console.WriteLine(@" - 'Notice: Unrecognized line in toolkit.version'"); - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine(@" is an informational message. This indicates the"); - Console.WriteLine(@" original CDLC was produced with an older version"); - Console.WriteLine(@" of the toolkit. The Remastered CDLC has been"); - Console.WriteLine(@" updated to the current version of the toolkit."); - Console.WriteLine(); - Console.WriteLine(@" - Remember the original (buggy) CDLC has been renamed"); - Console.WriteLine(@" and it now has a backup file extension of (.org)."); - Console.WriteLine(); - Console.WriteLine(@" - The (.org) files can be archived or deleted after"); - Console.WriteLine(@" it is confirm that the Remastered CDLC is working."); - Console.WriteLine(); - Console.WriteLine(@" - Any corrupt CDLC have been renamed and now have a"); - Console.WriteLine(@" (.cor) file extension. These should be submitted to"); - Console.WriteLine(@" the original charter so they can be repaired. See"); - Console.WriteLine(@" 'remastered_error.log' for a list of corrupt files."); - Console.WriteLine(); - Console.WriteLine(@"Press any key to continue ..."); - CleanupLocalTemp(); - Console.Read(); - return 0; - } - - private static string OfficialOrRepaired(string filePath) - { - ToolkitInfo entryTkInfo; - using (var browser = new PsarcBrowser(filePath, true)) - entryTkInfo = browser.ExtractToolkitInfo(); - - if (entryTkInfo == null) - return "Official"; - - if (entryTkInfo != null && entryTkInfo.PackageAuthor != null) - if (entryTkInfo.PackageAuthor.Equals(@"Ubisoft")) - return "Official"; - - if (entryTkInfo != null && entryTkInfo.PackageComment != null) - if (entryTkInfo.PackageComment.Contains(@"Remastered")) - return "Remastered"; - - return null; - } - - private static void RemasterSong(string filePath) - { - var fileName = Path.GetFileName(filePath); - - // backup original cdlc - try - { - Console.WriteLine(); - Console.ForegroundColor = ConsoleColor.Cyan; - Console.WriteLine(@"File: " + fileName); - Console.ForegroundColor = ConsoleColor.Green; - Console.WriteLine(@" - Making a backup copy ..."); - var backupPath = String.Format(@"{0}.org", filePath); - if (!File.Exists(backupPath)) - { - File.Copy(filePath, backupPath, false); - Console.WriteLine(@" - Sucessfully created backup ..."); - } - else - Console.WriteLine(@" - Backup already exists ..."); - } - catch (Exception ex) - { - // it is critical that backup of originals was successful before proceeding - throw new Exception(@"Backup of: " + filePath + " ... FAILED" + Environment.NewLine + - ex.Message + Environment.NewLine + - "Please correct the issue and make sure you have" + Environment.NewLine + - "backup copies of your original CDLC files."); - } - - try - { - // TODO: repair in memory without extracting the files - // SNG's needs to be regenerated - // ArrangmentIDs are stored in multiple place and all need to be updated - // therefore we are going to unpack, apply repair, and repack - Console.WriteLine(@" - Extracting CDLC artifacts ..."); - DLCPackageData packageData; - - using (var psarcOld = new PsarcPackager()) - { - packageData = psarcOld.ReadPackage(filePath); - - // Update arrangement song info - foreach (Arrangement arr in packageData.Arrangements) - { - // skip vocal and showlight arrangements - if (arr.ArrangementType == ArrangementType.Vocal || arr.ArrangementType == ArrangementType.ShowLight) - continue; - - // generate new Arrangement IDs - arr.Id = IdGenerator.Guid(); - arr.MasterId = RandomGenerator.NextInt(); - - // preserve existing xml comments - arr.XmlComments = Song2014.ReadXmlComments(arr.SongXml.File); - var isCommented = false; - var commentNodes = arr.XmlComments as List ?? arr.XmlComments.ToList(); - foreach (var commentNode in commentNodes) - { - if (commentNode.ToString().Contains(@"Remastered")) - isCommented = true; - } - - // validate SongInfo - var songXml = Song2014.LoadFromFile(arr.SongXml.File); - - arr.ClearCache(); // why this comes after loading xml IDK - songXml.AlbumYear = packageData.SongInfo.SongYear.ToString().GetValidYear(); - songXml.ArtistName = packageData.SongInfo.Artist.GetValidAtaSpaceName(); - songXml.Title = packageData.SongInfo.SongDisplayName.GetValidAtaSpaceName(); - songXml.AlbumName = packageData.SongInfo.Album.GetValidAtaSpaceName(); - songXml.ArtistNameSort = packageData.SongInfo.ArtistSort.GetValidSortableName(); - songXml.SongNameSort = packageData.SongInfo.SongDisplayNameSort.GetValidSortableName(); - songXml.AlbumNameSort = packageData.SongInfo.AlbumSort.GetValidSortableName(); - songXml.AverageTempo = Convert.ToSingle(packageData.SongInfo.AverageTempo.ToString().GetValidTempo()); - - // resave the validated xml - using (var stream = File.Open(arr.SongXml.File, FileMode.Create)) - songXml.Serialize(stream, true); - - // add "Remastered" comment to saved xml to be able to identify repaired CDLC - if (!isCommented) - Song2014.WriteXmlComments(arr.SongXml.File, commentNodes, true, String.Format(@"(Remastered by CLI")); - } - - // validate packageData (important) - packageData.Name = packageData.Name.GetValidKey(); // DLC Key - - if (String.IsNullOrEmpty(packageData.PackageVersion)) - packageData.PackageVersion = "1"; - else - packageData.PackageVersion = packageData.PackageVersion.GetValidVersion(); - - // add comment to ToolkitInfo to identify Remastered CDLC - var packageComment = packageData.PackageComment; - - if (String.IsNullOrEmpty(packageComment)) - packageComment = "(Remastered by CLI)"; - - if (!packageComment.Contains(@"Remastered")) - packageComment = packageComment + " " + "(Remastered by CLI)"; - - packageData.PackageComment = packageComment; - Console.WriteLine(@" - Repackaging remastered CDLC ..."); - - // regenerates the SNG with the repair and repackages - using (var psarcNew = new PsarcPackager(true)) - psarcNew.WritePackage(filePath, packageData); - } - - Console.WriteLine(@" - Repair was sucessful ..."); - } - catch (Exception ex) - { - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine(@" - Repair failed ... " + ex.Message); - Console.ForegroundColor = ConsoleColor.Green; - - // delete backup, restore original and rename corrupt (cor) - var backupPath = String.Format(@"{0}.org", filePath); - if (File.Exists(backupPath)) - { - var corruptPath = String.Format(@"{0}.cor", filePath); - File.Copy(backupPath, corruptPath, true); - File.Delete(backupPath); - File.Delete(filePath); - } - - sbErrors.AppendLine(String.Format("{0}", filePath)); - } - - Console.WriteLine(); - } - - private static void RepairFiles(IEnumerable cdlcFiles) - { - foreach (var cdlcFile in cdlcFiles) - { - if (!cdlcFile.IsValidPSARC()) - { - Console.ForegroundColor = ConsoleColor.Yellow; - Console.WriteLine(@"File is not a valid CDLC: " + Path.GetFileName(cdlcFile)); - Console.ForegroundColor = ConsoleColor.Green; - continue; - } - - var officialOrRepaired = OfficialOrRepaired(cdlcFile); - if (!String.IsNullOrEmpty(officialOrRepaired)) - { - Console.ForegroundColor = ConsoleColor.Yellow; - - if (officialOrRepaired.Contains(@"Official")) - Console.WriteLine(@"Skipped ODLC File: " + Path.GetFileName(cdlcFile)); - else if (officialOrRepaired.Contains(@"Remastered")) - Console.WriteLine(@"Skipped Remastered File: " + Path.GetFileName(cdlcFile)); - - Console.ForegroundColor = ConsoleColor.Green; - continue; - } - - // could check for corrupt CDLC here - - RemasterSong(cdlcFile); - } - } - - private static int ShowHelpfulError(string message) - { - sbErrors.AppendLine(String.Format("{0}", message)); - Console.ForegroundColor = ConsoleColor.Yellow; - Console.Write(@"remastered: "); - Console.WriteLine(message); - Console.ForegroundColor = ConsoleColor.Green; - CleanupLocalTemp(); - Console.Read(); - return 1; - } - - private static bool IsDirectory(string path) - { - bool isDirectory = false; - - try - { - FileAttributes attr = File.GetAttributes(path); - if ((attr & FileAttributes.Directory) == FileAttributes.Directory) - isDirectory = true; - } - catch (Exception ex) - { - Console.WriteLine(@"Error: " + ex.Message); - } - - return isDirectory; - } - - private static void CleanupLocalTemp() - { -#if !DEBUG - var di = new DirectoryInfo(Path.GetTempPath()); - - // confirm this is the 'Local Settings\Temp' directory - if (di.Parent != null) - if (di.Parent.Name == "Local Settings" && di.Name == "Temp") - { - foreach (FileInfo file in di.GetFiles()) - try - { - file.Delete(); - } - catch { /*Don't worry just skip locked file*/ } - - foreach (DirectoryInfo dir in di.GetDirectories()) - try - { - dir.Delete(true); - } - catch { /*Don't worry just skip locked directory*/ } - } -#endif - } - - private static string ProjectVersion() - { - return String.Format(@"{0}.{1}.{2}", - Assembly.GetExecutingAssembly().GetName().Version.Major, - Assembly.GetExecutingAssembly().GetName().Version.Minor, - Assembly.GetExecutingAssembly().GetName().Version.Build); - } - - - } -} - -// CODE Grave Yard -// -//var dropIsDirectory = false; -//var dropCount = args.GetLength(0); -//if (dropCount > 0) -//{ -// for (int i = 0; i < dropCount; i++) -// { -// if (IsDirectory(args[i])) -// dropIsDirectory = true; - -// if (!IsDirectory(args[i]) && dropIsDirectory) -// return ShowHelpfulError(@"Please drop all files or all folders onto the executable."); -// } -//} -//else -// return ShowHelpfulError(@"Please drop either all files or all folders onto the executable."); - diff --git a/RocksmithToolkitCLI/remastered/Properties/AssemblyInfo.cs b/RocksmithToolkitCLI/remastered/Properties/AssemblyInfo.cs deleted file mode 100644 index e023d7c4f..000000000 --- a/RocksmithToolkitCLI/remastered/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Rocksmith Toolkit CLI Remastered")] -[assembly: AssemblyDescription("Converts CDLC for use with Rocksmith 2014 Remastered Version")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Rocksmith Tookit CLI")] -[assembly: AssemblyProduct("remastered")] -[assembly: AssemblyCopyright("Copyright © 2016 CST Developer Team")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("bd0efb05-5628-45f1-ae53-043f375a5805")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.10.0")] -[assembly: AssemblyFileVersion("1.0.10.0")] diff --git a/RocksmithToolkitCLI/remastered/Properties/Resources.Designer.cs b/RocksmithToolkitCLI/remastered/Properties/Resources.Designer.cs deleted file mode 100644 index 1350f6d8c..000000000 --- a/RocksmithToolkitCLI/remastered/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace remastered.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("remastered.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/RocksmithToolkitCLI/remastered/Properties/Resources.resx b/RocksmithToolkitCLI/remastered/Properties/Resources.resx deleted file mode 100644 index 1af7de150..000000000 --- a/RocksmithToolkitCLI/remastered/Properties/Resources.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/PsarcLoader/Entry.cs b/RocksmithToolkitCLI/remastered/PsarcLoader/Entry.cs deleted file mode 100644 index 8f3581521..000000000 --- a/RocksmithToolkitCLI/remastered/PsarcLoader/Entry.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using System.IO; -using System.Security.Cryptography; -using System.Text; - -namespace remastered -{ - public class Entry : IDisposable - { - #region BinaryEntry - - public byte[] MD5 { get; set; } - - public uint zIndexBegin { get; set; } - - /// - /// Original data length of this entry. - /// - /// The length. - public ulong Length { get; set; } - - /// - /// Starting offset from - /// - /// The offset. - public ulong Offset { get; set; } - - #endregion - - public string ErrMsg { get; set; } - public Stream Data { get; set; } - public int Id { get; set; } - - /// - /// Gets a value indicating whether this is compressed. - /// - /// true if compressed; otherwise, false. - /// Kinda rubbush but could be useful someday. Now inactive. - public bool Compressed { get; set; } - - public string Name { get; set; } - - public Entry() - { - Id = 0; - Name = string.Empty; - } - - #region IDisposable implementation - - public void Dispose() - { - Dispose(true); - System.GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (!disposing) return; - if (Data != null) Data.Dispose(); - MD5 = null; - } - - #endregion - - public override string ToString() - { - return Name; - } - - public void UpdateNameMD5() - { - MD5 = (Name == String.Empty) ? new byte[16] : new MD5CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(Name)); - } - } -} \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/PsarcLoader/PSARC.cs b/RocksmithToolkitCLI/remastered/PsarcLoader/PSARC.cs deleted file mode 100644 index 3dc97abb4..000000000 --- a/RocksmithToolkitCLI/remastered/PsarcLoader/PSARC.cs +++ /dev/null @@ -1,1047 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Security.Cryptography; -using RocksmithToolkitLib.PSARC; -using zlib; - -namespace remastered -{ - public class PSARC : IDisposable - { - private class Header - { - public uint MagicNumber; - public uint VersionNumber; - public uint CompressionMethod; - public uint TotalTOCSize; - public uint TOCEntrySize; - public uint NumFiles; - public uint BlockSizeAlloc; - public uint ArchiveFlags; - - public Header() - { - MagicNumber = 1347633490; //'PSAR' - VersionNumber = 65540; //1.4 - CompressionMethod = 2053925218; //'zlib' (also avalible 'lzma') - TOCEntrySize = 30; //bytes - //NumFiles = 0; - BlockSizeAlloc = 65536; //Decompression buffer size = 64kb - ArchiveFlags = 0; //It's bitfield actually, see PSARC.bt - } - } - - private Header _header; - private List _toc; - - public List TOC - { - get { return _toc; } - } - - private uint[] _zBlocksSizeList; - - private int bNum - { - get { return (int)Math.Log(_header.BlockSizeAlloc, byte.MaxValue + 1); } - } - - private bool UseMemory = false; - - public PSARC() - { - _header = new Header(); - _toc = new List { new Entry() }; - } - - public PSARC(bool Memory) - { - _header = new Header(); - _toc = new List { new Entry() }; - UseMemory = Memory; - } - - /// - /// Checks if psarc is not truncated. - /// - /// The psarc size. - private long RequiredPsarcSize() - { - if (_toc.Count > 0) - { - //get last_entry.offset+it's size - var last_entry = _toc[_toc.Count - 1]; - var TotalLen = last_entry.Offset; - var zNum = _zBlocksSizeList.Length - last_entry.zIndexBegin; - for (int z = 0; z < zNum; z++) - { - var num = _zBlocksSizeList[last_entry.zIndexBegin + z]; - TotalLen += (num == 0) ? _header.BlockSizeAlloc : num; - } - return (long)TotalLen; - } - return _header.TotalTOCSize; //already read - } - - #region IDisposable implementation - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (!disposing) return; - _header = null; - foreach (var entry in TOC.Where(entry => entry.Data != null)) - entry.Data.Dispose(); - TOC.Clear(); - - if (_reader != null) _reader.Dispose(); - if (_writer != null) _writer.Dispose(); - } - - #endregion - - #region Helpers Inflator/Deflator - /// - /// Inflates selected entry. - /// - /// Entry to unpack. - /// Destination file used instead of the temp file. - public void InflateEntry(Entry entry, string destfilepath = "") - { - entry.ErrMsg = String.Empty; - - if (entry.Length == 0) return; //skip empty files - // Decompress Entry - const int zHeader = 0x78DA; - uint zChunkID = entry.zIndexBegin; - int blockSize = (int)_header.BlockSizeAlloc; - //bool isZlib = _header.CompressionMethod == 2053925218; - - if (destfilepath.Length > 0) - entry.Data = new FileStream(destfilepath, FileMode.Create, FileAccess.Write, FileShare.Read); - else - { - if (UseMemory) - entry.Data = new MemoryStreamExtension(); - else - entry.Data = new TempFileStream(); - } - //Why won't this compile? - // entry.Data = UseMemory ? new MemoryStream() : new TempFileStream(); - - _reader.BaseStream.Position = (long)entry.Offset; - - do - { - // check for corrupt CDLC content and catch exceptions - try - { - if (_zBlocksSizeList[zChunkID] == 0U) // raw. full cluster used. - { - entry.Data.Write(_reader.ReadBytes(blockSize), 0, blockSize); - } - else - { - var num = _reader.ReadUInt16(); - _reader.BaseStream.Position -= 2L; - - var array = _reader.ReadBytes((int)_zBlocksSizeList[zChunkID]); - if (num == zHeader) - { - // compressed - try - { - RijndaelEncryptor.Unzip(array, entry.Data, false); - } - catch (Exception ex) //IOException - { - // corrupt CDLC zlib.net exception ... try to unpack - if (String.IsNullOrEmpty(entry.Name)) - entry.ErrMsg = String.Format(@"{1}CDLC contains a zlib exception.{1}Warning: {0}{1}", ex.Message, Environment.NewLine); - else - entry.ErrMsg = String.Format(@"{2}CDLC contains a broken datachunk in file '{0}'.{2}Warning: {1}{2}", entry.Name.Split('/').Last(), ex.Message, Environment.NewLine); - - Console.Write(entry.ErrMsg); - } - } - else // raw. used only for data(chunks) smaller than 64 kb - { - entry.Data.Write(array, 0, array.Length); - } - } - zChunkID += 1; - } - catch (Exception ex) // index is outside the bounds of the array - { - // corrupt CDLC data length ... try to unpack - entry.ErrMsg = String.Format(@"{2}CDLC contains a broken datachunk in file '{0}'.{2}Warning: {1}{2}", entry.Name.Split('/').Last(), ex.Message, Environment.NewLine); - Console.Write(entry.ErrMsg + Environment.NewLine); - break; - } - } while (entry.Data.Length < (long)entry.Length); - entry.Data.Seek(0, SeekOrigin.Begin); - entry.Data.Flush(); - } - - /// - /// Inflates the entry. - /// - /// Name with extension. - public void InflateEntry(string name) - { - InflateEntry(_toc.First(t => t.Name.EndsWith(name, StringComparison.Ordinal))); - } - - /// - /// Inflates all entries in current psarc. - /// - public void InflateEntries() - { - foreach (var current in _toc) - { - // We really can use Parrallel here. - InflateEntry(current); - } - } - - /// - /// Packs Entries to zStream - /// - /// zStreams - /// zBlocksSizeList - private void DeflateEntries(out Dictionary entryDeflatedData, out List zLengths) - { - // TODO: This produces perfect results for song archives (original vs repacked) - // there are slight differences in the binary of large archives (original vs repacked). WHY? - // - entryDeflatedData = new Dictionary(); - uint blockSize = _header.BlockSizeAlloc; - zLengths = new List(); - - var ndx = 0; // for debugging - // var step = Math.Round(1.0 / (_toc.Count + 2) * 100, 3); - // double progress = 0; - // GlobalExtension.ShowProgress("Deflating Entries ..."); - - foreach (Entry entry in _toc) - { - var zList = new List>(); - entry.zIndexBegin = (uint)zLengths.Count; - entry.Data.Seek(0, SeekOrigin.Begin); - - while (entry.Data.Position < entry.Data.Length) - { - var array_i = new byte[blockSize]; - var array_o = new byte[blockSize * 2]; - var memoryStream = new MemoryStream(array_o); - - int plain_len = entry.Data.Read(array_i, 0, array_i.Length); - int packed_len = (int)RijndaelEncryptor.Zip(array_i, memoryStream, plain_len, false); - - if (packed_len >= plain_len) - { - // If packed data "worse" than plain (i.e. already packed) z = 0 - zList.Add(new Tuple(array_i, plain_len)); - } - else - { - // If packed data is good - if (packed_len < (blockSize - 1)) - { - // If packed data fits maximum packed block size z = packed_len - zList.Add(new Tuple(array_o, packed_len)); - } - else - { - // Write plain. z = 0 - zList.Add(new Tuple(array_i, plain_len)); - } - } - } - - int zSisesSum = 0; - foreach (var zSize in zList) - { - zSisesSum += zSize.Item2; - zLengths.Add((uint)zSize.Item2); - } - - var array3 = new byte[zSisesSum]; - var memoryStream2 = new MemoryStream(array3); - foreach (var entryblock in zList) - { - memoryStream2.Write(entryblock.Item1, 0, entryblock.Item2); - } - - entryDeflatedData.Add(entry, array3); - // progress += step; - // GlobalExtension.UpdateProgress.Value = (int)progress; - Debug.WriteLine("Deflating: " + ndx++); - } - } - - /// - /// Reads file names from the manifest. - /// - public void ReadManifest() - { - var toc = _toc[0]; - toc.Name = "NamesBlock.bin"; - InflateEntry(toc); - using (var bReader = new StreamReader(toc.Data, true)) - { - var count = _toc.Count; - var data = bReader.ReadToEnd().Split('\n'); //0x0A - Parallel.For(0, data.Length, i => - { - if (i + 1 != count) - _toc[i + 1].Name = data[i]; - }); - } - _toc.RemoveAt(0); - } - - private void WriteManifest() - { - if (_toc.Count == 0) - { - _toc.Add(new Entry() { Name = "NamesBlock.bin" }); - } - - if (_toc[0].Name == "") - { - _toc[0].Name = "NamesBlock.bin"; - } - - if (_toc[0].Name != "NamesBlock.bin") - { - _toc.Insert(0, new Entry() { Name = "NamesBlock.bin" }); - } - - var binaryWriter = new BinaryWriter(new MemoryStream()); - for (int i = 1, len = _toc.Count; i < len; i++) - { - //'/' - unix path separator - var bytes = Encoding.ASCII.GetBytes(_toc[i].Name); - binaryWriter.Write(bytes); - //'\n' - unix line separator - if (i == len - 1) - { - binaryWriter.BaseStream.Position = 0; - continue; - } - binaryWriter.Write('\n'); //data.WriteByte(0x0A); - } - _toc[0].Data = binaryWriter.BaseStream; //dunno how to get buffer, seek is required - } - - public void AddEntry(string name, Stream data) - { - if (name == "NamesBlock.bin") - return; - - var entry = new Entry { Name = name, Data = data, Length = (ulong)data.Length }; - AddEntry(entry); - } - - public void AddEntry(Entry entry) - { - //important hierachy - _toc.Add(entry); - entry.Id = this.TOC.Count - 1; - } - - private void ParseTOC() - { - // Parse TOC Entries - for (int i = 0, tocFiles = (int)_header.NumFiles; i < tocFiles; i++) - { - _toc.Add(new Entry { Id = i, MD5 = _reader.ReadBytes(16), zIndexBegin = _reader.ReadUInt32(), Length = _reader.ReadUInt40(), Offset = _reader.ReadUInt40() }); /* FIXME: general idea was to implement parallel inflate route, still need to re-think this. - if (i == 0) continue; - if (i == tocFiles - 1) - _toc[i].zDatalen = (ulong)_reader.BaseStream.Length - _toc[i].Offset; //HACK: fails if psarc is truncated. - _toc[i-1].zDatalen = _toc[i].Offset - _toc[i-1].Offset; */ - } - } - - #endregion - - #region Binary Reader/Writer - - private BigEndianBinaryReader _reader; - - public void Read(Stream psarc, bool lazy = false) - { - _toc.Clear(); - _reader = new BigEndianBinaryReader(psarc); - _header.MagicNumber = _reader.ReadUInt32(); - if (_header.MagicNumber == 1347633490U) //PSAR (BE) - { - //Parse Header - _header.VersionNumber = _reader.ReadUInt32(); - _header.CompressionMethod = _reader.ReadUInt32(); - _header.TotalTOCSize = _reader.ReadUInt32(); - _header.TOCEntrySize = _reader.ReadUInt32(); - _header.NumFiles = _reader.ReadUInt32(); - _header.BlockSizeAlloc = _reader.ReadUInt32(); - _header.ArchiveFlags = _reader.ReadUInt32(); - //Read TOC - int tocSize = (int)(_header.TotalTOCSize - 32U); - if (_header.ArchiveFlags == 4) //TOC_ENCRYPTED - { - // Decrypt TOC - var tocStream = new MemoryStream(); - using (var decStream = new MemoryStream()) - { - RijndaelEncryptor.DecryptPSARC(psarc, decStream, _header.TotalTOCSize); - - int bytesRead; - int decSize = 0; - var buffer = new byte[_header.BlockSizeAlloc]; - while ((bytesRead = decStream.Read(buffer, 0, buffer.Length)) > 0) - { - decSize += bytesRead; - if (decSize > tocSize) - bytesRead = tocSize - (decSize - bytesRead); - tocStream.Write(buffer, 0, bytesRead); - } - } - tocStream.Position = 0; - _reader = new BigEndianBinaryReader(tocStream); - } - ParseTOC(); - //Parse zBlocksSizeList - int tocChunkSize = (int)(_header.NumFiles * _header.TOCEntrySize); //(int)_reader.BaseStream.Position //don't alter this with. causes issues - int zNum = (tocSize - tocChunkSize) / bNum; - var zLengths = new uint[zNum]; - for (int i = 0; i < zNum; i++) - { - switch (bNum) - { - case 2: //64KB - zLengths[i] = _reader.ReadUInt16(); - break; - case 3: //16MB - zLengths[i] = _reader.ReadUInt24(); - break; - case 4: //4GB - zLengths[i] = _reader.ReadUInt32(); - break; - } - } - _zBlocksSizeList = zLengths; //TODO: validate - - _reader.BaseStream.Flush(); //Free tocStream resources - _reader = new BigEndianBinaryReader(psarc); - - // Validate psarc size - // if (psarc.Length < RequiredPsarcSize()) - // throw new InvalidDataException("Truncated psarc."); - // try to unpack corrupt CDLC for now - - switch (_header.CompressionMethod) - { - case 2053925218: //zlib (BE) - ReadManifest(); - psarc.Seek(_header.TotalTOCSize, SeekOrigin.Begin); - if (!lazy) - { - // Decompress Data - InflateEntries(); - } - break; - case 1819962721: //lzma (BE) - throw new NotImplementedException("LZMA compression not supported."); - default: - throw new InvalidDataException("Unknown compression."); - } - } - psarc.Flush(); - } - - private BigEndianBinaryWriter _writer; - - public void Write(Stream inputStream, bool encrypt = false, bool seek = true) - { - _header.ArchiveFlags = encrypt ? 4U : 0U; - _header.TOCEntrySize = 30U; - WriteManifest(); - //Pack entries - List zLengths; - Dictionary zStreams; - DeflateEntries(out zStreams, out zLengths); - //Build zLengths - _writer = new BigEndianBinaryWriter(inputStream); - _header.TotalTOCSize = (uint)(32 + _toc.Count * _header.TOCEntrySize + zLengths.Count * bNum); - _toc[0].Offset = _header.TotalTOCSize; - for (int i = 1; i < _toc.Count; i++) - { - _toc[i].Offset = _toc[i - 1].Offset + (ulong)(zStreams[_toc[i - 1]].Length); - } - //Write Header - _writer.Write(_header.MagicNumber); - _writer.Write(_header.VersionNumber); - _writer.Write(_header.CompressionMethod); - _writer.Write(_header.TotalTOCSize); - _writer.Write(_header.TOCEntrySize); - _writer.Write(_toc.Count); - _writer.Write(_header.BlockSizeAlloc); - _writer.Write(_header.ArchiveFlags); - //Write Table of contents - foreach (Entry current in _toc) - { - current.UpdateNameMD5(); - _writer.Write(current.MD5); - _writer.Write(current.zIndexBegin); - _writer.WriteUInt40((ulong)current.Data.Length); //current.Length - _writer.WriteUInt40(current.Offset); - } - foreach (uint zLen in zLengths) - { - switch (bNum) - { - case 2: - _writer.Write((ushort)zLen); - break; - case 3: - _writer.WriteUInt24(zLen); - break; - case 4: - _writer.Write(zLen); - break; - } - } - zLengths = null; - - // Write zData - var ndx = 0; // for debugging - var step = Math.Round(1.0 / (this.TOC.Count + 2) * 100, 3); - double progress = 0; - // GlobalExtension.ShowProgress("Writing Zipped Data ..."); - - foreach (Entry current in _toc) - { - _writer.Write(zStreams[current]); - progress += step; - // GlobalExtension.UpdateProgress.Value = (int)progress; - Debug.WriteLine("Zipped: " + ndx++); - current.Data.Close(); - } - zStreams = null; - - if (encrypt) // Encrypt TOC - { - using (var outputStream = new MemoryStreamExtension()) - { - var encStream = new MemoryStreamExtension(); - inputStream.Position = 32L; - RijndaelEncryptor.EncryptPSARC(inputStream, outputStream, _header.TotalTOCSize); - inputStream.Position = 0L; - - // quick copy header from input stream - var buffer = new byte[32]; - encStream.Write(buffer, 0, inputStream.Read(buffer, 0, buffer.Length)); - encStream.Position = 32; //sainty check ofc - inputStream.Flush(); - - int tocSize = (int)_header.TotalTOCSize - 32; - int decSize = 0; - buffer = new byte[1024 * 16]; // more effecient use of memory - - ndx = 0; // for debuging - step = Math.Round(1.0 / ((tocSize / buffer.Length) + 2) * 100, 3); - progress = 0; - // GlobalExtension.ShowProgress("Writing Encrypted Data ..."); - - int bytesRead; - while ((bytesRead = outputStream.Read(buffer, 0, buffer.Length)) > 0) - { - decSize += bytesRead; - if (decSize > tocSize) - bytesRead = tocSize - (decSize - bytesRead); - - encStream.Write(buffer, 0, bytesRead); - - progress += step; - // GlobalExtension.UpdateProgress.Value = (int)progress; - Debug.WriteLine("Encrypted: " + ndx++); - } - - inputStream.Position = 0; - encStream.Position = 0; - encStream.CopyTo(inputStream, (int)_header.BlockSizeAlloc); - } - } - if (seek) // May be redundant - { - inputStream.Flush(); - inputStream.Position = 0; - } - // GlobalExtension.HideProgress(); - } - - #endregion - } - - public class TempFileStream : FileStream - { - private const int _buffer_size = 65536; - - public TempFileStream() - : base(Path.GetTempFileName(), FileMode.Create, FileAccess.ReadWrite, FileShare.Read, _buffer_size, FileOptions.DeleteOnClose) - { - } - - public TempFileStream(FileMode mode) // for Appending can not use FileAccess.ReadWrite - : base(Path.GetTempFileName(), mode, FileAccess.Write, FileShare.Read, _buffer_size, FileOptions.DeleteOnClose) - { - } - - public TempFileStream(FileAccess access) - : base(Path.GetTempFileName(), FileMode.Create, access, FileShare.Read, _buffer_size, FileOptions.DeleteOnClose) - { - } - - public TempFileStream(FileAccess access, FileShare share) - : base(Path.GetTempFileName(), FileMode.Create, access, share, _buffer_size, FileOptions.DeleteOnClose) - { - } - - public TempFileStream(FileAccess access, FileShare share, int bufferSize) - : base(Path.GetTempFileName(), FileMode.Create, access, share, bufferSize, FileOptions.DeleteOnClose) - { - } - - public TempFileStream(string path, FileMode mode) - : base(path, mode) - { - } - } - - /// MemoryStreamExtension is a re-implementation of MemoryStream that uses a dynamic list of byte arrays as a backing store, - /// instead of a single byte array, the allocation of which will fail for relatively small streams as it requires contiguous memory. - /// - public class MemoryStreamExtension : Stream /* http://msdn.microsoft.com/en-us/library/system.io.stream.aspx */ - { - #region Constructors - - public MemoryStreamExtension() - { - Position = 0; - } - - public MemoryStreamExtension(byte[] source) - { - this.Write(source, 0, source.Length); - Position = 0; - } - - /* length is ignored because capacity has no meaning unless we implement an artifical limit */ - - public MemoryStreamExtension(int length) - { - SetLength(length); - Position = length; - byte[] d = block; //access block to prompt the allocation of memory - Position = 0; - } - - #endregion - - #region Status Properties - - public override bool CanRead - { - get { return true; } - } - - public override bool CanSeek - { - get { return true; } - } - - public override bool CanWrite - { - get { return true; } - } - - #endregion - - #region Public Properties - - public override long Length - { - get { return length; } - } - - public override long Position { get; set; } - - #endregion - - #region Members - - protected long length = 0; - - protected long blockSize = 65536; - - protected List blocks = new List(); - - #endregion - - #region Internal Properties - - /* Use these properties to gain access to the appropriate block of memory for the current Position */ - - /// - /// The block of memory currently addressed by Position - /// - protected byte[] block - { - get - { - while (blocks.Count <= blockId) - blocks.Add(new byte[blockSize]); - return blocks[(int)blockId]; - } - } - - /// - /// The id of the block currently addressed by Position - /// - protected long blockId - { - get { return Position / blockSize; } - } - - /// - /// The offset of the byte currently addressed by Position, into the block that contains it - /// - protected long blockOffset - { - get { return Position % blockSize; } - } - - #endregion - - #region Public Stream Methods - - public override void Flush() - { - } - - public override int Read(byte[] buffer, int offset, int count) - { - long lcount = (long)count; - - if (lcount < 0) - { - throw new ArgumentOutOfRangeException("count", lcount, "Number of bytes to copy cannot be negative."); - } - - long remaining = (length - Position); - if (lcount > remaining) - lcount = remaining; - - if (buffer == null) - { - throw new ArgumentNullException("buffer", "Buffer cannot be null."); - } - if (offset < 0) - { - throw new ArgumentOutOfRangeException("offset", offset, "Destination offset cannot be negative."); - } - - int read = 0; - long copysize = 0; - do - { - copysize = Math.Min(lcount, (blockSize - blockOffset)); - Buffer.BlockCopy(block, (int)blockOffset, buffer, offset, (int)copysize); - lcount -= copysize; - offset += (int)copysize; - - read += (int)copysize; - Position += copysize; - } while (lcount > 0); - - return read; - } - - public override long Seek(long offset, SeekOrigin origin) - { - switch (origin) - { - case SeekOrigin.Begin: - Position = offset; - break; - case SeekOrigin.Current: - Position += offset; - break; - case SeekOrigin.End: - Position = Length - offset; - break; - } - return Position; - } - - public override void SetLength(long value) - { - length = value; - } - - public override void Write(byte[] buffer, int offset, int count) - { - long initialPosition = Position; - int copysize; - try - { - do - { - copysize = Math.Min(count, (int)(blockSize - blockOffset)); - - EnsureCapacity(Position + copysize); - - Buffer.BlockCopy(buffer, (int)offset, block, (int)blockOffset, copysize); - count -= copysize; - offset += copysize; - - Position += copysize; - } while (count > 0); - } - catch (Exception) - { - Position = initialPosition; - throw; - } - } - - public override int ReadByte() - { - if (Position >= length) - return -1; - - byte b = block[blockOffset]; - Position++; - - return b; - } - - public override void WriteByte(byte value) - { - EnsureCapacity(Position + 1); - block[blockOffset] = value; - Position++; - } - - protected void EnsureCapacity(long intended_length) - { - if (intended_length > length) - length = (intended_length); - } - - #endregion - - #region IDispose - - /* http://msdn.microsoft.com/en-us/library/fs2xkftw.aspx */ - - protected override void Dispose(bool disposing) - { - /* We do not currently use unmanaged resources */ - base.Dispose(disposing); - } - - #endregion - - #region Public Additional Helper Methods - - /// - /// Returns the entire content of the stream as a byte array. This is not safe because the call to new byte[] may - /// fail if the stream is large enough. Where possible use methods which operate on streams directly instead. - /// - /// A byte[] containing the current data in the stream - public byte[] ToArray() - { - long firstposition = Position; - Position = 0; - byte[] destination = new byte[Length]; - Read(destination, 0, (int)Length); - Position = firstposition; - return destination; - } - - /// - /// Reads length bytes from source into the this instance at the current position. - /// - /// The stream containing the data to copy - /// The number of bytes to copy - public void ReadFrom(Stream source, long length) - { - byte[] buffer = new byte[4096]; - int read; - do - { - read = source.Read(buffer, 0, (int)Math.Min(4096, length)); - length -= read; - this.Write(buffer, 0, read); - } while (length > 0); - } - - /// - /// Writes the entire stream into destination, regardless of Position, which remains unchanged. - /// - /// The stream to write the content of this stream to - public void WriteTo(Stream destination) - { - long initialpos = Position; - Position = 0; - this.CopyTo(destination); - Position = initialpos; - } - - #endregion - } - - public static class RijndaelEncryptor - { - #region RS2 - - public static byte[] PsarcKey = new byte[32] { 0xC5, 0x3D, 0xB2, 0x38, 0x70, 0xA1, 0xA2, 0xF7, 0x1C, 0xAE, 0x64, 0x06, 0x1F, 0xDD, 0x0E, 0x11, 0x57, 0x30, 0x9D, 0xC8, 0x52, 0x04, 0xD4, 0xC5, 0xBF, 0xDF, 0x25, 0x09, 0x0D, 0xF2, 0x57, 0x2C }; - - #endregion - - /// - /// Unpacks zipped data. - /// - /// In Stream. - /// Out stream. - /// Data size after decompress. - /// Manual control for stream seek position. - public static void Unzip(Stream str, Stream outStream, bool rewind = true) - { - int len; - var buffer = new byte[65536]; - var zOutputStream = new ZInputStream(str); - while ((len = zOutputStream.read(buffer, 0, buffer.Length)) > 0) - { - outStream.Write(buffer, 0, len); - } - zOutputStream.Close(); - buffer = null; - if (rewind) - { - outStream.Position = 0; - outStream.Flush(); - } - } - - public static void Unzip(byte[] array, Stream outStream, bool rewind = true) - { - Unzip(new MemoryStream(array), outStream, rewind); - } - - public static long Zip(Stream str, Stream outStream, long plainLen, bool rewind = true) - { - /*zlib works great, can't say that about SharpZipLib*/ - var buffer = new byte[65536]; - var zOutputStream = new ZOutputStream(outStream, 9); - while (str.Position < plainLen) - { - var size = (int)Math.Min(plainLen - str.Position, buffer.Length); - str.Read(buffer, 0, size); - zOutputStream.Write(buffer, 0, size); - } - zOutputStream.finish(); - buffer = null; - if (rewind) - { - outStream.Position = 0; - outStream.Flush(); - } - return zOutputStream.TotalOut; - } - - public static long Zip(byte[] array, Stream outStream, long plainLen, bool rewind = true) - { - return Zip(new MemoryStream(array), outStream, plainLen, rewind); - } - - public static void EncryptFile(Stream input, Stream output, byte[] key) - { - using (var rij = new RijndaelManaged()) - { - InitRijndael(rij, key, CipherMode.ECB); - Crypto(input, output, rij.CreateEncryptor(), input.Length); - } - } - - public static void DecryptFile(Stream input, Stream output, byte[] key) - { - using (var rij = new RijndaelManaged()) - { - InitRijndael(rij, key, CipherMode.ECB); - Crypto(input, output, rij.CreateDecryptor(), input.Length); - } - } - - - - public static void EncryptPSARC(Stream input, Stream output, long len) - { - using (var rij = new RijndaelManaged()) - { - InitRijndael(rij, PsarcKey, CipherMode.CFB); - Crypto(input, output, rij.CreateEncryptor(), len); - } - } - - public static void DecryptPSARC(Stream input, Stream output, long len) - { - using (var rij = new RijndaelManaged()) - { - InitRijndael(rij, PsarcKey, CipherMode.CFB); - Crypto(input, output, rij.CreateDecryptor(), len); - } - } - - private static void InitRijndael(Rijndael rij, byte[] key, CipherMode cipher) - { - rij.Padding = PaddingMode.None; - rij.Mode = cipher; - rij.BlockSize = 128; - rij.IV = new byte[16]; - rij.Key = key; // byte[32] - } - - private static void Crypto(Stream input, Stream output, ICryptoTransform transform, long len) - { - var buffer = new byte[512]; - int pad = buffer.Length - (int)(len % buffer.Length); - var coder = new CryptoStream(output, transform, CryptoStreamMode.Write); - while (input.Position < len) - { - int size = (int)Math.Min(len - input.Position, buffer.Length); - input.Read(buffer, 0, size); - coder.Write(buffer, 0, size); - } - if (pad > 0) - coder.Write(new byte[pad], 0, pad); - - coder.Flush(); - output.Seek(0, SeekOrigin.Begin); - output.Flush(); - } - - - } -} \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/PsarcLoader/PsarcExtensions.cs b/RocksmithToolkitCLI/remastered/PsarcLoader/PsarcExtensions.cs deleted file mode 100644 index d87ee98d2..000000000 --- a/RocksmithToolkitCLI/remastered/PsarcLoader/PsarcExtensions.cs +++ /dev/null @@ -1,320 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using Newtonsoft.Json.Linq; -using RocksmithToolkitLib; -using RocksmithToolkitLib.DLCPackage; -using RocksmithToolkitLib.Xml; -using RocksmithToolkitLib.XmlRepository; - -// future use code incubator - -namespace remastered -{ - public static class PsarcExtensions - { - public static string TuningToName(string tolkenTuning, List tuningXml = null) - { - var jObj = JObject.Parse(tolkenTuning); - TuningStrings songTuning = jObj.ToObject(); - - // 2X speed hack ... use preloaded TuningDefinitionRepository - if (tuningXml == null) - tuningXml = TuningDefinitionRepository.Instance.LoadTuningDefinitions(GameVersion.RS2014); - - foreach (var tuning in tuningXml) - if (tuning.Tuning.String0 == songTuning.String0 && - tuning.Tuning.String1 == songTuning.String1 && - tuning.Tuning.String2 == songTuning.String2 && - tuning.Tuning.String3 == songTuning.String3 && - tuning.Tuning.String4 == songTuning.String4 && - tuning.Tuning.String5 == songTuning.String5) - return tuning.UIName; - - return "Other"; - } - - public static string TuningStringToName(string strings, List tuningXml = null) - { - // 2X speed hack ... use preloaded TuningDefinitionRepository - if (tuningXml == null) - tuningXml = TuningDefinitionRepository.Instance.LoadTuningDefinitions(GameVersion.RS2014); - - foreach (var tuning in tuningXml) - if ((string)("" + (tuning.Tuning.String0) + (tuning.Tuning.String1) + (tuning.Tuning.String2) + (tuning.Tuning.String3) + (tuning.Tuning.String4) + (tuning.Tuning.String5)) == strings) - return tuning.UIName; - - return "Other"; - } - - - public static bool RemoveArchiveEntry(string psarcPath, string entryName) - { - if (!File.Exists(psarcPath)) - return false; - - using (PSARC archive = new PSARC(true)) - { - using (var psarcStream = File.OpenRead(psarcPath)) - archive.Read(psarcStream); - - var tocEntry = archive.TOC.FirstOrDefault(entry => entry.Name == entryName); - - if (tocEntry == null) - return true; - - archive.TOC.Remove(tocEntry); - archive.TOC.Insert(0, new Entry() { Name = "NamesBlock.bin" }); - - using (var fs = File.Create(psarcPath)) - archive.Write(fs, true); - - return true; - } - } - - public static bool InjectArchiveEntry(string psarcPath, string entryName, - string sourcePath, bool updateToolkitVersion = false, - string packageAuthor = "", string packageVersion = "1", string packageComment = "") - { - if (!File.Exists(psarcPath)) - return false; - - int injectionCount = 2; - if (!updateToolkitVersion) - injectionCount = 1; - else - { - if (String.IsNullOrEmpty(packageVersion)) - packageVersion = "1"; - if (String.IsNullOrEmpty(packageAuthor)) - packageAuthor = Assembly.GetExecutingAssembly().GetName().ToString(); - } - - using (PSARC archive = new PSARC(true)) - using (var psarcStream = File.OpenRead(psarcPath)) - { - try - { - archive.Read(psarcStream); - psarcStream.Dispose(); - - for (int i = 0; i < injectionCount; i++) - { - var entryStream = new MemoryStream(); - - switch (i) - { - case 0: - using (var sourceStream = File.OpenRead(sourcePath)) - sourceStream.CopyTo(entryStream); - break; - case 1: - DLCPackageCreator.GenerateToolkitVersion(entryStream, packageAuthor, packageVersion, packageComment); - entryName = "toolkit.version"; - break; - } - - entryStream.Position = 0; - Entry tocEntry = archive.TOC.FirstOrDefault(x => x.Name == entryName); - - if (tocEntry != null) - { - tocEntry.Data.Dispose(); - tocEntry.Data = null; - tocEntry.Data = entryStream; - } - else - { - archive.AddEntry(entryName, entryStream); - - // evil genius ... ;) => forces archive update - archive.TOC.Insert(0, new Entry() { Name = "NamesBlock.bin" }); - } - } - } - catch - { - return false; - } - - using (var fs = File.Create(psarcPath)) - archive.Write(fs, true); - - return true; - } - } - - public static string ExtractArchiveFile(string psarcPath, string entryNamePath, string outputDir) - { - if (!File.Exists(psarcPath)) - return ""; - - using (PSARC archive = new PSARC(true)) - using (var psarcStream = File.OpenRead(psarcPath)) - { - archive.Read(psarcStream, true); - var tocEntry = archive.TOC.Where(entry => entry.Name.Contains(entryNamePath)).FirstOrDefault(); - - if (tocEntry != null) - { - if (!Directory.Exists(outputDir)) - Directory.CreateDirectory(outputDir); - - archive.InflateEntry(tocEntry, Path.Combine(outputDir, Path.GetFileName(tocEntry.ToString()))); - - return tocEntry.ToString(); - } - - return ""; - } - } - - public static Stream ExtractArchiveFile(string psarcPath, string entryNamePath) - { - if (!File.Exists(psarcPath)) - return null; - - using (PSARC archive = new PSARC(true)) - using (var psarcStream = File.OpenRead(psarcPath)) - { - archive.Read(psarcStream, true); - var tocEntry = archive.TOC.FirstOrDefault(x => (x.Name.Equals(entryNamePath))); - - if (tocEntry != null) - { - archive.InflateEntry(tocEntry); - return tocEntry.Data; - } - } - - return null; - } - - - public static bool ReplaceData(this PSARC p, Func dataEntry, Stream newData) - { - var de = p.TOC.Where(dataEntry).FirstOrDefault(); - if (de != null) - { - if (de.Data != null) - { - de.Data.Dispose(); - de.Data = null; - } - else - p.InflateEntry(de); - - de.Data = newData; - return true; - } - return false; - } - - public static Stream ExtractPSARCData(this Stream stream, Func dataEntry) - { - using (PSARC p = new PSARC(true)) - { - p.Read(stream, true); - - var de = p.TOC.Where(dataEntry).FirstOrDefault(); - if (de != null) - { - MemoryStream ms = new MemoryStream(); - p.InflateEntry(de); - if (de.Data == null) - return null; - de.Data.Position = 0; - de.Data.CopyTo(ms); - ms.Position = 0; - return ms; - } - return null; - } - } - - public static Stream GetData(this PSARC p, Func dataEntry) - { - var de = p.TOC.Where(dataEntry).FirstOrDefault(); - if (de != null) - { - if (de.Data == null) - p.InflateEntry(de); - - return de.Data; - } - return null; - } - - public static bool ReplaceData(this PSARC p, Dictionary, Stream> newData) - { - bool result = true; - foreach (var d in newData) - { - if (!p.ReplaceData(d.Key, d.Value)) - result = false; - } - return result; - } - - public static NoCloseStream ReplaceData(this PSARC p, Func dataEntry, String newData) - { - NoCloseStream s = new NoCloseStream(); - using (var sr = new StreamWriter(s)) - sr.Write(newData); - s.Position = 0; - if (!ReplaceData(p, dataEntry, s)) - { - s.canClose = true; - s.Dispose(); - return null; - } - return s; - } - - - - } - - /// - /// Useful when some other class(StreamReader/StreamReader...) tries to close the stream before it's supposed to be closed. - /// - public class NoCloseStream : MemoryStream - { - public bool canClose = false; - - public void CloseEx() - { - canClose = true; - this.Close(); - } - - public override void Close() - { - if (canClose) - base.Close(); - } - } - - public class NoCloseStreamList : List, IDisposable - { - public NoCloseStream NewStream() - { - var l = new NoCloseStream(); - Add(l); - return l; - } - - public void Dispose() - { - foreach (var l in this) - l.CloseEx(); - this.Clear(); - } - - - - } -} \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/PsarcLoader/PsarcLoader.cs b/RocksmithToolkitCLI/remastered/PsarcLoader/PsarcLoader.cs deleted file mode 100644 index 189babd3e..000000000 --- a/RocksmithToolkitCLI/remastered/PsarcLoader/PsarcLoader.cs +++ /dev/null @@ -1,397 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Drawing; -using System.IO; -using System.Linq; -using System.Text; -using CFSM.AudioTools; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using RocksmithToolkitLib; -using RocksmithToolkitLib.DLCPackage; -using RocksmithToolkitLib.DLCPackage.Manifest2014; -using RocksmithToolkitLib.DLCPackage.Manifest2014.Header; -using RocksmithToolkitLib.Extensions; - -namespace remastered -{ - public sealed class PsarcLoader : IDisposable - { - private PSARC _archive; - private string _filePath; - private Stream _fileStream; - public string ErrMsg { get; set; } - - // Loads song archive file to memory. - public PsarcLoader(string fileName, bool useMemory = true) - { - _filePath = fileName; - _archive = new PSARC(useMemory); - _fileStream = File.OpenRead(_filePath); - _archive.Read(_fileStream); - } - - public Stream ExtractEntryData(Func entryLINQ) - { - var entry = _archive.TOC.Where(entryLINQ).FirstOrDefault(); - if (entry != null) - { - MemoryStream ms = new MemoryStream(); - _archive.InflateEntry(entry); - if (entry.Data == null) - return null; - - entry.Data.Position = 0; - entry.Data.CopyTo(ms); - entry.Dispose(); - ms.Position = 0; - return ms; - } - return null; - } - - public List ExtractEntryNames() - { - var sw = new Stopwatch(); - sw.Restart(); - var entryNames = new List(); - var step = Math.Round(1.0 / (_archive.TOC.Count + 2) * 100, 3); - double progress = 0; - GlobalExtension.ShowProgress("Inflating Entries ..."); - - - // this iterates through all entries in archive - foreach (var entry in _archive.TOC) - { - // do something interesting with the entry - entryNames.Add(entry.Name); - // needed to free memory (prevent crashing) - if (entry.Data != null) - entry.Data.Dispose(); - - progress += step; - GlobalExtension.UpdateProgress.Value = (int)progress; - } - - GlobalExtension.UpdateProgress.Value = 100; - return entryNames; - } - - // produces a comprehensive list of archive entry errors - public List FullErrorCheck() - { - List errorLog = new List(); - - // this iterates through all entries in archive looking for errors - foreach (var entry in _archive.TOC) - { - _archive.InflateEntry(entry); - if (!String.IsNullOrEmpty(entry.ErrMsg)) - errorLog.Add(entry.ErrMsg); - - if (entry.Data == null) - errorLog.Add("Null Entry Error: " + entry.Name); - else - { - entry.Data.Position = 0; - var ms = new MemoryStream(); - using (var reader = new StreamReader(ms, new UTF8Encoding(), false, 65536)) //4Kb is default alloc size for windows .. 64Kb is default PSARC alloc - { - try - { - var canRead = reader.ReadToEnd(); - } - catch (Exception ex) - { - errorLog.Add("Error Reading Entry: " + entry.Name + Environment.NewLine + ex.Message); - } - } - } - } - - return errorLog; - } - - - // this method will work for Song Packs too! - public IEnumerable> ExtractJsonManifests() - { - var sw = new Stopwatch(); - sw.Restart(); - - // every song contains gamesxblock but may not contain showlights.xml - var xblockEntries = _archive.TOC.Where(x => x.Name.StartsWith("gamexblocks/nsongs") && x.Name.EndsWith(".xblock")).ToList(); - if (!xblockEntries.Any()) - throw new Exception("Could not find valid xblock file in archive."); - - var jsonData = new List>(); - // this foreach loop addresses song packs otherwise it is only done one time - foreach (var xblockEntry in xblockEntries) - { - var strippedName = xblockEntry.Name.Replace(".xblock", "").Replace("gamexblocks/nsongs/", ""); - if (strippedName.Contains("_fcp_dlc")) - strippedName = strippedName.Replace("_fcp_dlc", ""); - - var jsonEntries = _archive.TOC.Where(x => x.Name.StartsWith("manifests/songs") && x.Name.EndsWith(".json") && x.Name.Contains(strippedName)).OrderBy(x => x.Name).ToList(); - - // looping through song multiple times gathering each arrangement - foreach (var jsonEntry in jsonEntries) - { - var dataObj = new Manifest2014(); - - _archive.InflateEntry(jsonEntry); - jsonEntry.Data.Position = 0; - var ms = new MemoryStream(); - using (var reader = new StreamReader(ms, new UTF8Encoding(), false, 65536)) //4Kb is default alloc size for windows .. 64Kb is default PSARC alloc - { - jsonEntry.Data.Position = 0; - jsonEntry.Data.CopyTo(ms); - ms.Position = 0; - var jsonObj = JObject.Parse(reader.ReadToEnd()); - dataObj = JsonConvert.DeserializeObject>(jsonObj.ToString()); - } - - jsonData.Add(dataObj); - } - } - - sw.Stop(); - GlobalExtension.ShowProgress(String.Format("{0} parsing json manifest entries took: {1} (msec)", Path.GetFileName(_filePath), sw.ElapsedMilliseconds)); - return jsonData; - } - - public ManifestHeader2014 ExtractHsanManifest() - { - var sw = new Stopwatch(); - sw.Restart(); - // every song and song pack contain only one hsan file - var hsanEntry = _archive.TOC.FirstOrDefault(x => x.Name.StartsWith("manifests/songs") && x.Name.EndsWith(".hsan")); - - if (hsanEntry == null) - throw new Exception("Could not find valid hsan manifest in archive."); - - var hsanData = new ManifestHeader2014(new Platform(GamePlatform.Pc, GameVersion.RS2014)); - _archive.InflateEntry(hsanEntry); - var ms = new MemoryStream(); - using (var reader = new StreamReader(ms, new UTF8Encoding(), false, 65536)) //4Kb is default alloc size for windows .. 64Kb is default PSARC alloc - { - hsanEntry.Data.Position = 0; - hsanEntry.Data.CopyTo(ms); - ms.Position = 0; - var jsonObj = JObject.Parse(reader.ReadToEnd()); - hsanData = JsonConvert.DeserializeObject>(jsonObj.ToString()); - } - - sw.Stop(); - GlobalExtension.ShowProgress(String.Format("{0} parsing hsan manifest entry took: {1} (msec)", Path.GetFileName(_filePath), sw.ElapsedMilliseconds)); - return hsanData; - } - - public ToolkitInfo ExtractToolkitInfo() - { - var tkInfo = new ToolkitInfo(); - var toolkitVersionEntry = _archive.TOC.FirstOrDefault(x => (x.Name.Equals("toolkit.version"))); - - if (toolkitVersionEntry != null) - { - _archive.InflateEntry(toolkitVersionEntry); - toolkitVersionEntry.Data.Position = 0; - tkInfo = GeneralExtensions.GetToolkitInfo(new StreamReader(toolkitVersionEntry.Data)); - } - else - { - // this helps prevent null exceptions - tkInfo.ToolkitVersion = "N/A"; - tkInfo.PackageAuthor = "Ubisoft"; - tkInfo.PackageVersion = "N/A"; - tkInfo.PackageComment = "N/A"; - } - - return tkInfo; - } - public string ExtractAppId() - { - var appId = String.Empty; - - var appIdEntry = _archive.TOC.FirstOrDefault(x => (x.Name.Equals("appid.appid"))); - if (appIdEntry != null) - { - _archive.InflateEntry(appIdEntry); - - using (var reader = new StreamReader(appIdEntry.Data)) - appId = reader.ReadLine(); - } - - return appId; - } - - // ===================== FOR FUTURE ==================== - - public Bitmap ExtractAlbumArt(bool extractTaggerOrg) - { - Bitmap imageData = null; - var sw = new Stopwatch(); - sw.Restart(); - - //Func entryLINQ; - //if (extractTaggerOrg) - // entryLINQ = entry => entry.Name == "tagger.org"; - //else - // entryLINQ = x => x.Name.Contains("256.dds"); - - //var albumArtEntry = _archive.TOC.FirstOrDefault(entryLINQ); - //if (albumArtEntry == null && extractTaggerOrg) - // RSTKTools.GlobalExtension.ShowProgress("Could not find tagger.org entry in archive."); - - //if (albumArtEntry != null) - //{ - // _archive.InflateEntry(albumArtEntry); - // var ms = new MemoryStream(); - // using (var reader = new StreamReader(ms, new UTF8Encoding(), false, 65536)) //4Kb is default alloc size for windows .. 64Kb is default PSARC alloc - // { - // albumArtEntry.Data.Position = 0; - // albumArtEntry.Data.CopyTo(ms); - // ms.Position = 0; - - // var b = ImageExtensions.DDStoBitmap(ms); - // if (b != null) - // imageData = b; - // } - //} - - sw.Stop(); - GlobalExtension.ShowProgress(String.Format("{0} parsing albumart entry took: {1} (msec)", Path.GetFileName(_filePath), sw.ElapsedMilliseconds)); - return imageData; - } - - // old slower static method - public static List ExtractAudioEntry(string archiveName, string audioName, string previewName) - { - bool result = false; - if (String.IsNullOrEmpty(audioName)) - return null; // false; - - GlobalExtension.ShowProgress("Extracting Audio ..."); - List wems; - - using (var archive = new PSARC(true)) - using (var stream = File.OpenRead(archiveName)) - { - archive.Read(stream, true); - wems = archive.TOC.Where(entry => entry.Name.StartsWith("audio/windows") && entry.Name.EndsWith(".wem")).ToList(); - - if (wems.Count > 1) - { - wems.Sort((e1, e2) => - { - if (e1.Length < e2.Length) - return 1; - if (e1.Length > e2.Length) - return -1; - return 0; - }); - } - - if (wems.Count > 0) - { - var top = wems[0]; // wem audio with internal TOC path - archive.InflateEntry(top); - top.Data.Position = 0; - using (var FS = File.Create(audioName)) - { - WwiseToOgg w2o = new WwiseToOgg(top.Data, FS); - result = w2o.ConvertToOgg(); - } - } - - if (!String.IsNullOrEmpty(previewName) && result && wems.Count > 0) - { - var bottom = wems.Last(); - archive.InflateEntry(bottom); - bottom.Data.Position = 0; - using (var FS = File.Create(previewName)) - { - WwiseToOgg w2o = new WwiseToOgg(bottom.Data, FS); - result = w2o.ConvertToOgg(); - } - } - } - - // confirmed this output is same as old exe converter method both are 44KHz VBR - if (!result) - return null; - - return wems; - } - - /// - /// Convert wem archive entries to ogg files - /// - /// - /// - /// - /// - public bool ConvertWemEntries(List wems, string audioOggPath, string previewOggPath = "") - { - bool result = false; - - if (wems.Count > 1) - { - wems.Sort((e1, e2) => - { - if (e1.Length < e2.Length) - return 1; - if (e1.Length > e2.Length) - return -1; - return 0; - }); - } - - if (wems.Count > 0) - { - var top = wems[0]; // wem audio with internal TOC path - top.Data.Position = 0; - using (var FS = File.Create(audioOggPath)) - { - WwiseToOgg w2o = new WwiseToOgg(top.Data, FS); - result = w2o.ConvertToOgg(); - } - } - - if (!String.IsNullOrEmpty(previewOggPath) && result && wems.Count > 0) - { - var bottom = wems.Last(); - bottom.Data.Position = 0; - using (var FS = File.Create(previewOggPath)) - { - WwiseToOgg w2o = new WwiseToOgg(bottom.Data, FS); - result = w2o.ConvertToOgg(); - } - } - - return result; - } - - - public void Dispose() - { - if (_fileStream != null) - { - _fileStream.Dispose(); - _fileStream = null; - } - if (_archive != null) - { - _archive.Dispose(); - _archive = null; - } - - GC.SuppressFinalize(this); - } - - - - - } -} \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/PsarcLoader/PsarcPackager.cs b/RocksmithToolkitCLI/remastered/PsarcLoader/PsarcPackager.cs deleted file mode 100644 index 5f6d0ae91..000000000 --- a/RocksmithToolkitCLI/remastered/PsarcLoader/PsarcPackager.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using RocksmithToolkitLib; -using RocksmithToolkitLib.DLCPackage; -using RocksmithToolkitLib.Extensions; - -namespace remastered -{ - public class PsarcPackager : IDisposable - { - private string packageDir; - private bool _deleteOnClose; - - public PsarcPackager(bool deleteOnClose = false) - { - _deleteOnClose = deleteOnClose; - } - - public DLCPackageData ReadPackage(string inputPath) - { - // UNPACK - packageDir = Packer.Unpack(inputPath, Path.GetTempPath(), true); - - // REORGANIZE - packageDir = DLCPackageData.DoLikeProject(packageDir); - - // LOAD DATA - DLCPackageData info = new DLCPackageData(); - var packagePlatform = inputPath.GetPlatform(); - info = DLCPackageData.LoadFromFolder(packageDir, packagePlatform, packagePlatform); - var foundShowlights = Directory.EnumerateFiles(packageDir, "*_showlights.xml", SearchOption.AllDirectories).Any(); - - // toolkit will generate showlights if none was found - if (!foundShowlights) - info.Showlights = true; - - return info; - } - - public void WritePackage(string outputPath, DLCPackageData packageData) - { - Platform platform = outputPath.GetPlatform(); - DLCPackageCreator.Generate(outputPath, packageData, platform); - } - - protected virtual void Dispose(Boolean disposing) - { - if (disposing) - if (_deleteOnClose) - DirectoryExtension.SafeDelete(packageDir); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - } -} \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/remastered.csproj b/RocksmithToolkitCLI/remastered/remastered.csproj deleted file mode 100644 index d9c0b7da7..000000000 --- a/RocksmithToolkitCLI/remastered/remastered.csproj +++ /dev/null @@ -1,168 +0,0 @@ - - - - Debug - x86 - 8.0.30703 - 2.0 - {88A34EB4-10FE-495C-9A54-97DBBBA37D2D} - Exe - Properties - remastered - remastered - v4.0 - - - 512 - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - x86 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\Debug\ - DEBUG;TRACE - full - AnyCPU - prompt - false - false - - - bin\Release\ - TRACE - true - pdbonly - AnyCPU - prompt - false - false - - - CLI.ico - - - - true - - - - False - ..\..\lib\AudioTools\CFSM.AudioTools.dll - - - ..\..\lib\MiscUtil\MiscUtil.dll - - - ..\..\lib\NDesk\NDesk.Options.dll - - - - - - - - - - - - - - False - ..\..\lib\X360\X360.dll - - - False - ..\..\lib\ZLib\zlib.net.dll - - - - - - - True - True - Resources.resx - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - revorb.exe - Always - - - ww2ogg.exe - Always - - - - - - packed_codebooks.bin - Always - - - packed_codebooks_aoTuV_603.bin - Always - - - - - {2231C13A-14F6-478A-96D7-D1D3E1094CD6} - RocksmithToolkitLib - - - - - Always - - - Always - - - Always - - - Always - - - - - Always - - - - - - - - - \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/remastered.exe -org -pre.bat b/RocksmithToolkitCLI/remastered/remastered.exe -org -pre.bat deleted file mode 100644 index a7135a8c0..000000000 --- a/RocksmithToolkitCLI/remastered/remastered.exe -org -pre.bat +++ /dev/null @@ -1,34 +0,0 @@ -@ECHO OFF - -COLOR 0A - -ECHO This batch runs remastered.exe with the -org -pre options -ECHO. -ECHO CDCL with (.org) extensions will be repaired and -ECHO song stats are preserved. Be aware that if this option is -ECHO used on files located in the "My Documents\Remastered_CLI" -ECHO folder that the remastered CDLC needs to be manually move -ECHO back to the Rocksmith 2014 'dlc' folder. -ECHO. -ECHO Song stats are preserved only for CDLC that have -ECHO not been played in Rocksmith 2014 Remastered -ECHO. -ECHO If a song has been played and has the 100%% bug then the -ECHO CDLC must be repaired and song stats must be reset using -ECHO remastered.exe with no options or just the [-org] option -ECHO. -ECHO Drag/Drop CDLC files and directories onto this batch -ECHO. -ECHO A shortcut to the batch can be put anywhere - -TITLE remastered.exe -org -pre - -IF "%~1"=="" GOTO done - -cd /d "%~dp0" -START "" "remastered.exe" "-org" "-pre" "%~1" - -:done -pause -exit /b -@ECHO ON \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/remastered.exe -org.bat b/RocksmithToolkitCLI/remastered/remastered.exe -org.bat deleted file mode 100644 index 8b72f1f9e..000000000 --- a/RocksmithToolkitCLI/remastered/remastered.exe -org.bat +++ /dev/null @@ -1,27 +0,0 @@ -@ECHO OFF - -COLOR 0A - -ECHO This batch runs remastered.exe with the -org option -ECHO. -ECHO CDCL with (.org) extensions will be repaired and -ECHO song stats are reset. Be aware that if this option is -ECHO used on files located in the "My Documents\Remastered_CLI" -ECHO folder that the remastered CDLC needs to be manually move -ECHO back to the Rocksmith 2014 'dlc' folder. -ECHO. -ECHO Drag/Drop CDLC files and directories onto this batch -ECHO. -ECHO A shortcut to the batch can be put anywhere - -TITLE remastered.exe -org - -IF "%~1"=="" GOTO done - -cd /d "%~dp0" -START "" "remastered.exe" "-org" "%~1" - -:done -pause -exit /b -@ECHO ON \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/remastered.exe -pre.bat b/RocksmithToolkitCLI/remastered/remastered.exe -pre.bat deleted file mode 100644 index d49c307de..000000000 --- a/RocksmithToolkitCLI/remastered/remastered.exe -pre.bat +++ /dev/null @@ -1,28 +0,0 @@ -@ECHO OFF - -COLOR 0A - -ECHO This batch runs remastered.exe with the -pre option -ECHO. -ECHO Song stats are preserved only for CDLC that have -ECHO not been played in Rocksmith 2014 Remastered -ECHO. -ECHO If a song has been played and has the 100%% bug then the -ECHO CDLC must be repaired and song stats must be reset using -ECHO remastered.exe with no options or just the [-org] option -ECHO. -ECHO Drag/Drop CDLC files and directories onto this batch -ECHO. -ECHO A shortcut to the batch can be put anywhere - -TITLE remastered.exe -pre - -IF "%~1"=="" GOTO done - -cd /d "%~dp0" -START "" "remastered.exe" "-pre" "%~1" - -:done -pause -exit /b -@ECHO ON \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/remastered.exe -ren.bat b/RocksmithToolkitCLI/remastered/remastered.exe -ren.bat deleted file mode 100644 index 8f33b5fe0..000000000 --- a/RocksmithToolkitCLI/remastered/remastered.exe -ren.bat +++ /dev/null @@ -1,25 +0,0 @@ -@ECHO OFF - -COLOR 0A - -ECHO This batch runs remastered.exe with the -ren option -ECHO. -ECHO CDCL with (.org) extensions will be copied to (.psarc) -ECHO This restores the original unrepaired CDLC. For -ECHO safety (.org) files are not deleted by the CLI. -ECHO. -ECHO Drag/Drop CDLC files and directories onto this batch -ECHO. -ECHO A shortcut to the batch can be put anywhere - -TITLE remastered.exe -ren - -IF "%~1"=="" GOTO done - -cd /d "%~dp0" -START "" "remastered.exe" "-ren" "%~1" - -:done -pause -exit /b -@ECHO ON \ No newline at end of file diff --git a/RocksmithToolkitCLI/remastered/remastered.exe.bat b/RocksmithToolkitCLI/remastered/remastered.exe.bat deleted file mode 100644 index cda6c6e88..000000000 --- a/RocksmithToolkitCLI/remastered/remastered.exe.bat +++ /dev/null @@ -1,25 +0,0 @@ -@ECHO OFF - -COLOR 0A - -ECHO This batch runs remastered.exe with no options -ECHO. -ECHO CDLC that have the 100%% bug will be repaired -ECHO and Song Stats are reset. The original buggy -ECHO CDLC is renamed with (.org) file extesion. -ECHO. -ECHO Drag/Drop CDLC files and directories onto this batch -ECHO. -ECHO A shortcut to the batch can be put anywhere - -TITLE remastered.exe Repairs 100% Bug and Resets Song Stats - -IF "%~1"=="" GOTO done - -cd /d "%~dp0" -START "" "remastered.exe" "%~1" - -:done -pause -exit /b -@ECHO ON \ No newline at end of file diff --git a/VersionInfo.txt b/VersionInfo.txt index d326a5755..3472f46ad 100644 --- a/VersionInfo.txt +++ b/VersionInfo.txt @@ -1 +1 @@ -58d8e070 +7b2192c8