diff --git a/BUILDING.MD b/BUILDING.MD index 954d3f0..38ae20d 100644 --- a/BUILDING.MD +++ b/BUILDING.MD @@ -1,3 +1,4 @@ + # Building cdcrush dot NET @@ -9,20 +10,42 @@ https://www.visualstudio.com/downloads/ ### Running Requirements -These tools are needed to run cdcrush: +These tools are needed to **run** cdcrush: - **FreeArc**, an open source archiver. **Included** in the project files.\ Project Site : https://sourceforge.net/projects/freearc - **Ecmtools**, open source CD tools. **Included** in the project files. \ Project Site : https://github.com/kidoz/ecm -- **FFmpeg**, open source video/audio codecs. **NOT INCLUDED** \ +- **FFmpeg**, open source video/audio codecs. :warning: **NOT INCLUDED** \ Project Site : https://www.ffmpeg.org ### Building `release` -Create a subfolder named `tools` and put all the external executables there `[Arc.exe , ecm.exe , unecm.exe, ffmpeg.exe ]` +Create a subfolder named `tools` and put all the external executables there `[Arc.exe , ecm.exe , unecm.exe, ffmpeg.exe ]` *ffmpeg is optional* + ### Building `debug` The tool executables are fetched from the root repo folder `/tools/`. All the tools are provided in the repo except `FFmpeg` which you need to download and place it on your system/user path. + + + +### `cdinfos.dll` + + +This file was build using **HAXE**, compiled code from [**cdcrush nodejs**](https://github.com/johndimi/cdcrush) version. +Basically it's 2 classes, `CDInfo` and `CDTrack` compiled into a DLL so that I can have a single codebase for the CueParse for both cdcursh versions + +You can find the [source code for there files here.](https://github.com/johndimi/cdcrush/tree/master/src/cd) + +> :warning: You don't really have to build it yourself, you can just grab `cdinfos.dll` that is inside the project folder. + +#### To compile the cdinfos DLL with HAXE run this command: +```haxe +haxe -cp src/cd -D dll -D no-root -cs cdinfos cd.CDInfos cd.CDTrack +``` + +- `src/cd` must point to the nodejs version folder where the CD classes are +- It will create a directory `cdinfos/` and in there you can find the .dll file + diff --git a/CHANGELOG.MD b/CHANGELOG.MD index fa90870..01b5698 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,5 +1,13 @@ ## CHANGELOG +### V1.4 +- New CD Parser class + - Fixed times bug when converting multifile CD images to a single .bin + - built with **HAXE** and is included as a DLL file + - is the exact same class used in the **nodejs** version of cdcrush *(same codebase)* +- Fixed bug, when setting a custom TEMP folder, it now sets and restores it correctly. +- When **crushing** and the output archive already exists, it doesn't overwrite it, instead it renames the new archive by adding a `_` to the end of the file. + ### V1.3 - Added LOG window. You can now see a realtime log by pressing the "LOG" button on the bottom right of the window - Upgraded version to 1.3, because many new features were added since 1.2 @@ -28,4 +36,4 @@ - Calculate and display the **MD5** of the first data track, useful to quickly identify the validity of the CD - Ability to add an image cover to a CD archive. The image will then be displayed when restoring a CD. - MultiThreaded. Background FFmpeg and ECM operations can execute in parallel. *(Custom amount of threads in the options tab)* - - Temporary files will be deleted upon user program exit. \ No newline at end of file + - Temporary files will be deleted upon user program exit. diff --git a/README.MD b/README.MD index 37f9aa1..cf9d3c5 100644 --- a/README.MD +++ b/README.MD @@ -1,10 +1,12 @@ + # CDCRUSH dot NET **Name**: cdcrush, *Highy compress cd-image games*\ **Author:** John Dimi, *twitter*: [@jondmt](https://twitter.com/jondmt)\ **Project Page and Sources:** [https://github.com/johndimi/cdcrush.net](https://github.com/johndimi/cdcrush.net)\ **Language:** C# .NET 4.5, **Licence:** MIT\ -**Version:** 1.3 **Platform:** Windows +**Version:** 1.3 **Platform:** Windows\ +**Sister Project** : [cdcrush nodejs](https://www.npmjs.com/package/cdcrush) ## Download @@ -129,9 +131,15 @@ See [`CHANGELOG.MD`](CHANGELOG.MD) **A** : FFmpeg.exe is a small beast ( *around 36 megabytes*) and in some cases users already have it on their pc. So I am publishing a version with and a version without it. -## Npm Version +## NodeJS Version + +This project is a continuation of [**cdcrush nodeJS**](https://www.npmjs.com/package/cdcrush). + +**NEW APRIL 2018** :: I updated the **nodejs** version of **cdcrush** and it's compatible with the **.net** version. Meaning that archives created with **.net** can be opened with **.nodejs** and vice versa. + +> :stars: **nodejs** version support **batches** , so you can restore/compress multiple CD with one command. -This project is a continuation of [**cdcrush npm**](https://www.npmjs.com/package/cdcrush). You can check it out if you want, but **note** :warning: that the NPM version is old and **NOT RECOMMENDED TO USE** until I update it. +You can checkout **nodejs** version over at NPM : https://www.npmjs.com/package/cdcrush ## About diff --git a/cdcrush/Properties/AssemblyInfo.cs b/cdcrush/Properties/AssemblyInfo.cs index dab9cc3..3b6f21e 100644 --- a/cdcrush/Properties/AssemblyInfo.cs +++ b/cdcrush/Properties/AssemblyInfo.cs @@ -33,7 +33,7 @@ // 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.2.3.0")] -[assembly: AssemblyFileVersion("1.2.3.0")] +[assembly: AssemblyVersion("1.4.0.0")] +[assembly: AssemblyFileVersion("1.4.0.0")] [assembly: NeutralResourcesLanguage("en")] diff --git a/cdcrush/cdcrush.csproj b/cdcrush/cdcrush.csproj index 7ec7aef..7fc0e8b 100644 --- a/cdcrush/cdcrush.csproj +++ b/cdcrush/cdcrush.csproj @@ -25,7 +25,7 @@ false true 0 - 1.2.0.0 + 1.4.0.0 false true @@ -62,6 +62,10 @@ icon.ico + + False + .\cdinfos.dll + ..\packages\WindowsAPICodePack-Core.1.1.2\lib\Microsoft.WindowsAPICodePack.dll @@ -125,7 +129,6 @@ - diff --git a/cdcrush/cdinfos.dll b/cdcrush/cdinfos.dll new file mode 100644 index 0000000..06c92eb Binary files /dev/null and b/cdcrush/cdinfos.dll differ diff --git a/cdcrush/forms/FormChecksums.cs b/cdcrush/forms/FormChecksums.cs index 6b63ae3..43ff2c3 100644 --- a/cdcrush/forms/FormChecksums.cs +++ b/cdcrush/forms/FormChecksums.cs @@ -9,12 +9,12 @@ namespace cdcrush.forms public partial class FormChecksums: Form { // -- - CueReader cd; + cd.CDInfos cd; static public bool ISOPEN = false; // -- - public FormChecksums(CueReader _cd) + public FormChecksums(cd.CDInfos _cd) { cd = _cd; InitializeComponent(); diff --git a/cdcrush/forms/FormMain.cs b/cdcrush/forms/FormMain.cs index b0066a0..e8b9b77 100644 --- a/cdcrush/forms/FormMain.cs +++ b/cdcrush/forms/FormMain.cs @@ -33,7 +33,7 @@ public partial class FormMain : Form // Send whole form LOCK status from components internal static Action sendLock; // Request to open CD INFO popup - internal static Action showCdInfo; + internal static Action showCdInfo; // VARS :: // --------------- @@ -181,7 +181,7 @@ void loadAndSetupSettings() // -- // Show a popup with some CD infos like checksums - public void form_showCdInfo(CueReader cd) + public void form_showCdInfo(cd.CDInfos cd) { if(FormChecksums.ISOPEN) return; var f = new FormChecksums(cd); @@ -386,7 +386,7 @@ private void btn_selectTemp_Click(object sender, EventArgs e) if(CDCRUSH.setTempFolder(path)) { info_tempFolder.Text = CDCRUSH.TEMP_FOLDER; - Properties.Settings.Default.tempFolder = CDCRUSH.TEMP_FOLDER; // A valid folder + Properties.Settings.Default.tempFolder = path; // A valid folder } } }// ----------------------------------------- diff --git a/cdcrush/forms/PanelCompress.cs b/cdcrush/forms/PanelCompress.cs index 866a429..2432073 100644 --- a/cdcrush/forms/PanelCompress.cs +++ b/cdcrush/forms/PanelCompress.cs @@ -13,7 +13,7 @@ public partial class PanelCompress : UserControl string preparedCover; string loadedCuePath; // This holds the info of the CD that was just compressed. Set AFTER crushing - CueReader postCdInfo; + cd.CDInfos postCdInfo; // Hold the number of tracks of the quickloadedCD int numberOfTracks; @@ -27,7 +27,7 @@ public PanelCompress() private void PanelCompress_Load(object sender, EventArgs e) { // -- Some Tooltips - ToolTip tt = new ToolTip(); + ToolTip tt = new ToolTip(); tt.SetToolTip(chk_encodedCue, "Encodes audio tracks and creates a .CUE file that handles data and encoded audio tracks. Doesn't create a final archive. This format can be used in some emulators."); tt.SetToolTip(pictureBox1,"You can optionally set an image cover for this CD and it will be stored in the archive."); @@ -208,7 +208,7 @@ public void handle_dropped_file(string file) else if (ext == ".jpg") form_set_cover(file); else { - FormMain.sendMessage("Unsupported file extension. Drop a .CUE file",3); + FormMain.sendMessage("Unsupported file extension. Drop a .CUE file, or .JPG for a cover",3); } }// ----------------------------------------- @@ -220,7 +220,7 @@ private void btn_CRUSH_Click(object sender, EventArgs e) Tuple audioQ = Tuple.Create(combo_audio_c.SelectedIndex,combo_audio_q.SelectedIndex); // Since I can fire 2 jobs from here, have a common callback - Action jobCallback = (complete, newSize, cd) => { + Action jobCallback = (complete, newSize, cd) => { FormTools.invoke(this, () =>{ form_lockSection("all", false); diff --git a/cdcrush/forms/PanelRestore.cs b/cdcrush/forms/PanelRestore.cs index 9d50273..f86abaf 100644 --- a/cdcrush/forms/PanelRestore.cs +++ b/cdcrush/forms/PanelRestore.cs @@ -18,7 +18,7 @@ public partial class PanelRestore : UserControl // CD Info of the CD prepared to be restored // Primarily used to getting the checksum data - CueReader loadedCDInfo; + cd.CDInfos loadedCDInfo; // ----------------------------------------- @@ -93,7 +93,7 @@ void form_setCdInfo(dynamic cdInfo = null) loadedCDInfo = cdInfo.cd; btn_chksm.Enabled = true; - int numberOfTracks = loadedCDInfo.tracks.Count; + int numberOfTracks = loadedCDInfo.tracks.length; info_cdtitle.Text = loadedCDInfo.CD_TITLE; info_size0.Text = String.Format("{0}MB", FormTools.bytesToMB(cdInfo.sizeArc)); @@ -205,7 +205,7 @@ private void btn_RESTORE_Click(object sender, EventArgs e) FormMain.sendMessage("", 1); // Send the nuber of tracks for proper progress reporting - CDCRUSH.HACK_CD_TRACKS = loadedCDInfo.tracks.Count; + CDCRUSH.HACK_CD_TRACKS = loadedCDInfo.tracks.length; // Start the job // Note, Progress updates are automatically being handled by the main FORM diff --git a/cdcrush/lib/CueReader.cs b/cdcrush/lib/CueReader.cs index 68abca0..a0d94c8 100644 --- a/cdcrush/lib/CueReader.cs +++ b/cdcrush/lib/CueReader.cs @@ -1,4 +1,19 @@ -using System; +/** + * CueReader.cs + * CD .cue file parser and saver + * ----------------------- + * Author : John Dimi + * + * ATTENTION: + * ---------- + * This class is DEPRECATED! AND NOT USED + * In favor of the CDINFO DLL object which was generated from HAXE code. + * The reason is to have a single codebase for both this C# version + * and the nodejs version of CDCRUSH. + * + * ================================================= */ + +using System; using System.Collections.Generic; using System.Linq; using System.IO; @@ -9,9 +24,7 @@ namespace cdcrush.lib { -/** - * CueReader is the main class to read and operate CUE files - */ + public class CueReader { // :: STATICS diff --git a/cdcrush/prog/CDCRUSH.cs b/cdcrush/prog/CDCRUSH.cs index 7211410..7632a12 100644 --- a/cdcrush/prog/CDCRUSH.cs +++ b/cdcrush/prog/CDCRUSH.cs @@ -18,7 +18,7 @@ public static class CDCRUSH // -- Program Infos public const string AUTHORNAME = "John Dimi"; public const string PROGRAM_NAME = "cdcrush"; - public const string PROGRAM_VERSION = "1.3"; + public const string PROGRAM_VERSION = "1.4"; public const string PROGRAM_SHORT_DESC = "Highy compress cd-image games"; public const string LINK_DONATE = "https://www.paypal.me/johndimi"; public const string LINK_SOURCE = "https://github.com/johndimi/cdcrush.net"; @@ -79,7 +79,7 @@ public static class CDCRUSH // Hacky way of pushing number of expected tracks on the jobs. // MUST BE SET RIGHT BEFORE CREATING AJOB. // Until I implement progress reporting in a better way, this works fine. - public static int HACK_CD_TRACKS=0; + public static int HACK_CD_TRACKS = 0; // ----------------------------------------- // :: AUDIO QUALITY :: @@ -220,7 +220,7 @@ public static string getAudioQualityString(Tuple A) /// Completed (completeStatus,final Size) /// public static bool startJob_ConvertCue(string _Input, string _Output, Tuple _Audio, - string _Title, Action onComplete) + string _Title, Action onComplete) { if (LOCKED) { ERROR="Engine is working"; return false; } if (!FFMPEG_OK) { ERROR="FFmpeg is not set"; return false; } @@ -261,7 +261,7 @@ public static bool startJob_ConvertCue(string _Input, string _Output, TupleCompleted (completeStatus,CrushedSize) /// public static bool startJob_CrushCD(string _Input, string _Output, Tuple _Audio, - string _Cover, string _Title, int compressionLevel, Action onComplete) + string _Cover, string _Title, int compressionLevel, Action onComplete) { if (LOCKED) { ERROR="Engine is working"; return false; } if (!FFMPEG_OK) { ERROR="FFmpeg is not set"; return false; } @@ -361,20 +361,20 @@ public static object loadQuickCUE(string cueFile) if (!check_file_(cueFile,".cue")) return false; // Load the CUE file and try to parse it - var cd = new CueReader(); - - if(!cd.load(cueFile)) - { - ERROR = cd.ERROR; return null; + var cd = new cd.CDInfos(); + try { + cd.cueLoad(cueFile); + }catch(haxe.lang.HaxeException e) { + ERROR = e.Message; return null; } - - LOG.log("= QuickLoaded `{0}' - [OK]",cueFile); + + LOG.log("= QuickLoaded `{0}' - [OK]", cueFile); var info = new { title = cd.CD_TITLE, size1 = cd.CD_TOTAL_SIZE, - tracks = cd.tracks.Count + tracks = cd.tracks.length }; return info; @@ -419,9 +419,11 @@ public static bool loadQuickInfo(string arcFile, Action onComplete) if(success) // OK { // Continue - var cd = new CueReader(); - if(!cd.loadJson(Path.Combine(TEMP_FOLDER,CDCRUSH_SETTINGS))) { - ERROR = cd.ERROR; + var cd = new cd.CDInfos(); + try{ + cd.jsonLoad(Path.Combine(TEMP_FOLDER,CDCRUSH_SETTINGS)); + }catch(haxe.lang.HaxeException e){ + ERROR = e.Message; onComplete(null); return; } @@ -505,5 +507,12 @@ public static string checkCreateUniqueOutput(string partA, string partB = "") return path; }// ----------------------------------------- - }// -- -}// -- + /// Get a unique named temp folder ( inside the main temp folder ) + public static string getSubTempDir() + { + return Path.Combine(CDCRUSH.TEMP_FOLDER,Guid.NewGuid().ToString().Substring(0, 12)); + }// ----------------------------------------- + + }// -- end class + +}// -- end namespace diff --git a/cdcrush/prog/JobConvertCue.cs b/cdcrush/prog/JobConvertCue.cs index 33c5b43..a22cf62 100644 --- a/cdcrush/prog/JobConvertCue.cs +++ b/cdcrush/prog/JobConvertCue.cs @@ -10,7 +10,7 @@ namespace cdcrush.prog /// -/// A collection of tasks, that will CRUSH a cd, +/// A collection of tasks, that will CONVERT a cd, /// Tasks will run in order, and some will run in parallel /// class JobConvertCue:CJob @@ -39,7 +39,7 @@ public JobConvertCue(CrushParams p):base("Convert CD") } // - - p.tempDir = Path.Combine(CDCRUSH.TEMP_FOLDER,Guid.NewGuid().ToString().Substring(0, 12)); + p.tempDir = CDCRUSH.getSubTempDir(); if(!FileTools.createDirectory(p.tempDir)) { fail(msg: "Can't create TEMP dir"); return; @@ -57,32 +57,33 @@ public JobConvertCue(CrushParams p):base("Convert CD") // - Read the CUE file :: add(new CTask((t) => { - var cd = new CueReader(); - jobData.cd = cd; + var CD = new cd.CDInfos(); + jobData.cd = CD; - if(!cd.load(p.inputFile)) { - t.fail(msg:cd.ERROR); - return; + try{ + CD.cueLoad(p.inputFile); + }catch(haxe.lang.HaxeException e){ + t.fail(msg:e.Message); return; } // -- - if(cd.tracks.Count==1) + if(CD.tracks.length==1) { t.fail(msg:"No point in converting. No audio tracks on the cd."); return; } // Meaning the tracks are going to be extracted in the temp folder - jobData.flag_sourceTracksOnTemp = (!cd.MULTIFILE && cd.tracks.Count>1); + jobData.flag_sourceTracksOnTemp = (!CD.MULTIFILE && CD.tracks.length > 1); // In case user named the CD, otherwise it's going to be the same if(!string.IsNullOrWhiteSpace(p.cdTitle)) { - cd.CD_TITLE = FileTools.sanitizeFilename(p.cdTitle); + CD.CD_TITLE = FileTools.sanitizeFilename(p.cdTitle); } // Real quality to string name - cd.CD_AUDIO_QUALITY = CDCRUSH.getAudioQualityString(p.audioQuality); + CD.CD_AUDIO_QUALITY = CDCRUSH.getAudioQualityString(p.audioQuality); t.complete(); @@ -93,12 +94,15 @@ public JobConvertCue(CrushParams p):base("Convert CD") // --------------------------- add(new TaskCutTrackFiles()); - // - Compress tracks + // - Encode tracks // --------------------- add(new CTask((t) => { // Only encode the audio tracks - foreach(CueTrack tr in (jobData.cd as CueReader).tracks) { + cd.CDInfos CD = jobData.cd; + for(int i=0;i { - CueReader cd = jobData.cd; + cd.CDInfos CD = jobData.cd; // DEV: So far : // track.trackFile is UNSET. cd.saveCue needs it to be set. // track.workingFile points to a valid file, some might be in TEMP folder and some in input folder (data tracks) - int stepProgress = (int)Math.Round(100.0f/cd.tracks.Count); + int stepProgress = (int)Math.Round(100.0f/CD.tracks.length); // -- Move files to output folder - foreach(var track in cd.tracks) + for(int i=0;i( new [] { + "CDCRUSH (dotNet) version : " + CDCRUSH.PROGRAM_VERSION, + CDCRUSH.LINK_SOURCE + })); + + }catch(haxe.lang.HaxeException e){ + t.fail(msg:e.Message); return; } t.complete(); diff --git a/cdcrush/prog/JobCrush.cs b/cdcrush/prog/JobCrush.cs index 307a4ef..d39f560 100644 --- a/cdcrush/prog/JobCrush.cs +++ b/cdcrush/prog/JobCrush.cs @@ -24,7 +24,7 @@ public struct CrushParams // : Internal Access : ---- // Keep the CD infos of the CD, it is going to be read later - public CueReader cd {get; internal set;} + public cd.CDInfos cd {get; internal set;} // Filesize of the final archive public int crushedSize {get; internal set;} // Temp dir for the current batch, it's autoset, is a subfolder of the master TEMP folder. @@ -64,7 +64,7 @@ public JobCrush(CrushParams p):base("Compress CD") return; } - p.tempDir = Path.Combine(CDCRUSH.TEMP_FOLDER,Guid.NewGuid().ToString().Substring(0, 12)); + p.tempDir = CDCRUSH.getSubTempDir(); if(!FileTools.createDirectory(p.tempDir)) { fail(msg: "Can't create TEMP dir"); return; @@ -83,16 +83,18 @@ public JobCrush(CrushParams p):base("Compress CD") // - Read the CUE file :: add(new CTask((t) => { - var cd = new CueReader(); + var cd = new cd.CDInfos(); + jobData.cd = cd; - if(!cd.load(p.inputFile)) { - t.fail(msg:cd.ERROR); - return; + try{ + cd.cueLoad(p.inputFile); + }catch(haxe.lang.HaxeException e) { + t.fail(msg:e.Message); return; } // Meaning the tracks are going to be extracted in the temp folder - jobData.flag_sourceTracksOnTemp = (!cd.MULTIFILE && cd.tracks.Count>1); + jobData.flag_sourceTracksOnTemp = (!cd.MULTIFILE && cd.tracks.length > 1); // In case user named the CD, otherwise it's going to be the same if(!string.IsNullOrWhiteSpace(p.cdTitle)) @@ -104,7 +106,16 @@ public JobCrush(CrushParams p):base("Compress CD") cd.CD_AUDIO_QUALITY = CDCRUSH.getAudioQualityString(p.audioQuality); // Generate the final arc name now that I have the CD TITLE - jobData.finalArcPath = Path.Combine(p.outputDir, cd.CD_TITLE + ".arc"); + jobData.finalArcPath = Path.Combine(p.outputDir, cd.CD_TITLE + CDCRUSH.CDCRUSH_EXTENSION); + + // Try to create a new archive in case it exists? + while(File.Exists(jobData.finalArcPath)) + { + LOG.log("{0} already exists, adding (_) until unique", jobData.finalArcPath); + String S = jobData.finalArcPath; + jobData.finalArcPath = S.Substring(S.Length-4) + "_" + CDCRUSH.CDCRUSH_EXTENSION; + } + LOG.log("- Destination Archive : {0}", jobData.finalArcPath); t.complete(); @@ -119,9 +130,10 @@ public JobCrush(CrushParams p):base("Compress CD") // --------------------- add(new CTask((t) => { - CueReader cd = jobData.cd; - foreach(CueTrack tr in cd.tracks) { - addNextAsync(new TaskCompressTrack(tr)); + cd.CDInfos CD = jobData.cd; + //foreach(cd.CDInfos tr in CD.tracks) { + for(var i=0;i { - CueReader cd = jobData.cd; - + cd.CDInfos CD = jobData.cd; + // -- Get list of files:: System.Collections.ArrayList files = new System.Collections.ArrayList(); - foreach(var tr in cd.tracks) { - files.Add(tr.workingFile); // Working file is valid, was set earlier + for(var i=0;i { - CueReader cd = jobData.cd; - + cd.CDInfos CD = jobData.cd; + LOG.log("== Detailed CD INFOS =="); - LOG.log(cd.getDetailedInfo()); + LOG.log(CD.getDetailedInfo()); string path_settings = Path.Combine(p.tempDir, CDCRUSH.CDCRUSH_SETTINGS); - if(!cd.saveJson(path_settings)) - { - t.fail(msg: cd.ERROR); - return; + try{ + CD.jsonSave(path_settings); + }catch(haxe.lang.HaxeException e){ + t.fail(msg:e.Message); return; } // - Cover Image Set? diff --git a/cdcrush/prog/JobRestore.cs b/cdcrush/prog/JobRestore.cs index 6558d97..b4dba5a 100644 --- a/cdcrush/prog/JobRestore.cs +++ b/cdcrush/prog/JobRestore.cs @@ -25,7 +25,7 @@ public struct RestoreParams // Temp dir for the current batch, it's autoset by this object, // is a subfolder of the master TEMP folder internal string tempDir; - internal CueReader cd; + internal cd.CDInfos cd; }// -- @@ -67,7 +67,7 @@ public JobRestore(RestoreParams p) : base("Restore CD") } // -- - p.tempDir = Path.Combine(CDCRUSH.TEMP_FOLDER, Guid.NewGuid().ToString().Substring(0, 12)); + p.tempDir = CDCRUSH.getSubTempDir(); if(!FileTools.createDirectory(p.tempDir)) { fail(msg: "Can't create TEMP dir"); return; @@ -103,22 +103,25 @@ public JobRestore(RestoreParams p) : base("Restore CD") // - Restore tracks // - JOIN if it has to // ----------------------- - add(new CTask((t) => { - var cd = new CueReader(); jobData.cd = cd; + add(new CTask((t) => + { + var CD = new cd.CDInfos(); jobData.cd = CD; - // -- - if(!cd.loadJson(Path.Combine(p.tempDir, CDCRUSH.CDCRUSH_SETTINGS))) { - t.fail(msg: cd.ERROR); - return; + try{ + CD.jsonLoad(Path.Combine(p.tempDir, CDCRUSH.CDCRUSH_SETTINGS)); + }catch(haxe.lang.HaxeException e){ + t.fail(msg:e.Message); return; } + LOG.log("== Detailed CD INFOS =="); - LOG.log(cd.getDetailedInfo()); + LOG.log(CD.getDetailedInfo()); - // - Push TASK RESTORE tasks right after this one - foreach(CueTrack tr in cd.tracks) + for(int i=0;i { - CueReader cd = jobData.cd; + add(new CTask((t) => + { + cd.CDInfos cd = jobData.cd; // -- Join tracks if(p.flag_forceSingle || !cd.MULTIFILE) { // The task will read data from the shared job data var @@ -151,38 +155,41 @@ public JobRestore(RestoreParams p) : base("Restore CD") // - Create CUE files // - Delete Temp Files // ----------------------- - add(new CTask((t) => { - CueReader cd = jobData.cd; + add(new CTask((t) => + { + cd.CDInfos CD = jobData.cd; - int progressStep = (int)Math.Round(100.0f/cd.tracks.Count); + int progressStep = (int)Math.Round(100.0f/CD.tracks.length); // -- - foreach(var track in cd.tracks) { + for(int i=0;i( new [] { + "CDCRUSH (dotNet) version : " + CDCRUSH.PROGRAM_VERSION, + CDCRUSH.LINK_SOURCE + })); + }catch(haxe.lang.HaxeException e) { + t.fail(msg:e.Message); return; } t.complete(); diff --git a/cdcrush/prog/TaskCompressTrack.cs b/cdcrush/prog/TaskCompressTrack.cs index 583b812..eef9668 100644 --- a/cdcrush/prog/TaskCompressTrack.cs +++ b/cdcrush/prog/TaskCompressTrack.cs @@ -22,12 +22,12 @@ class TaskCompressTrack : lib.task.CTask // Copy of JOB restore parameters CrushParams p; // Pointer to working track - CueTrack track; + cd.CDTrack track; // Temp name, Autogenerated string sourceTrackFile; // -- - public TaskCompressTrack(CueTrack tr):base(null,"Encoding") + public TaskCompressTrack(cd.CDTrack tr):base(null,"Encoding") { name = "Compress"; desc = string.Format("Encoding track {0}", tr.trackNo); diff --git a/cdcrush/prog/TaskCutTrackFiles.cs b/cdcrush/prog/TaskCutTrackFiles.cs index 67c14d3..5eaae15 100644 --- a/cdcrush/prog/TaskCutTrackFiles.cs +++ b/cdcrush/prog/TaskCutTrackFiles.cs @@ -32,37 +32,37 @@ public override void start() base.start(); // Get the global cd object - CueReader cd = jobData.cd; - input = cd.tracks[0].workingFile; + cd.CDInfos CD = jobData.cd; + input = (CD.tracks[0] as cd.CDTrack).workingFile; // No need to cut an already cut CD // Multifiles `workingfile` is already set to proper - if(cd.MULTIFILE) + if(CD.MULTIFILE) { complete(); return; } // No need to copy the bytes to the temp folder, just work from the source - if(cd.tracks.Count==1) + if(CD.tracks.length==1) { complete(); return; } - int progressStep = (int)Math.Round((double) (100 / cd.tracks.Count)); + int progressStep = (int)Math.Round((double) (100 / CD.tracks.length)); // -- Cut the tracks :: FileStream inStr = new FileStream(input, FileMode.Open, FileAccess.Read); - for (int i = 0; i < cd.tracks.Count; i++) + for (int i = 0; i < CD.tracks.length; i++) { - var track = cd.tracks[i]; + cd.CDTrack track = (CD.tracks[i] as cd.CDTrack); - int byteStart = track.sectorStart * cd.SECTOR_SIZE; - int byteLen = track.sectorSize * cd.SECTOR_SIZE; + int byteStart = track.sectorStart * CD.SECTOR_SIZE; + int byteLen = track.sectorSize * CD.SECTOR_SIZE; // New filename for the tracks track.workingFile = Path.Combine(jobData.tempDir,track.getFilenameRaw()); diff --git a/cdcrush/prog/TaskJoinTrackFiles.cs b/cdcrush/prog/TaskJoinTrackFiles.cs index b22da69..fdccd14 100644 --- a/cdcrush/prog/TaskJoinTrackFiles.cs +++ b/cdcrush/prog/TaskJoinTrackFiles.cs @@ -31,24 +31,24 @@ public override void start() { base.start(); - CueReader cd = jobData.cd; + cd.CDInfos CD = jobData.cd; // -- - if(cd.tracks.Count==1) + if(CD.tracks.length==1) { complete(); return; } // -- - inputs = new string[cd.tracks.Count-1]; - for(int i=1;i