static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine(helptext); Environment.Exit(0); } else if (args.Length >= 1 || args.Length == 3) { var src = args[0]; var dest = args.Length >= 2 ? args[1] : Path.GetFileName(src); var vol = args.Length >= 3 ? args[2] : Path.GetFileName(src); if (Path.GetExtension(dest) == "") { dest += ".iso"; } Console.WriteLine($"About writing {src} to {dest} with volume name '{vol}'"); var creator = new IsoCreator(); var lastAct = ""; var lastMax = 1; creator.Progress += delegate(object sender, ProgressEventArgs e) { if (e.Maximum >= 0) { if (e.Action != null && e.Action != lastAct) { if (lastAct != "") { Console.Write(NiceProgress(lastAct, lastMax, lastMax) + "\r"); } lastAct = e.Action; Console.WriteLine(); } lastMax = e.Maximum; } Console.Write(NiceProgress(lastAct, e.Current, lastMax) + "\r"); }; creator.Finish += delegate(object sender, FinishEventArgs e) { Console.WriteLine($"Finished: {e.Message}"); Environment.Exit(0); }; creator.Abort += delegate(object sender, AbortEventArgs e) { Console.WriteLine($"Aborted: {e.Message}"); Environment.Exit(1); }; new Thread(new ParameterizedThreadStart(creator.Folder2Iso)) .Start(new IsoCreatorFolderArgs(src, dest, vol)); } else { Console.WriteLine("Invalid argument length!"); Environment.Exit(1); } }
public VirtualIsoCreator() { InitializeComponent(); // textBoxIsoPath.Text = @"C:\MyIso.iso"; textBoxVolumeName.Text = "BUNNY-WABBIT"; // m_creator = new IsoCreator(); m_creator.Progress += new ProgressDelegate( creator_Progress ); m_creator.Finish += new FinishDelegate( creator_Finished ); m_creator.Abort += new AbortDelegate( creator_Abort ); // this.Icon = Properties.Resources.CDCat; }
public VirtualIsoCreator() { InitializeComponent(); // textBoxIsoPath.Text = @"C:\MyIso.iso"; textBoxVolumeName.Text = "BUNNY-WABBIT"; // m_creator = new IsoCreator(); m_creator.Progress += new ProgressDelegate(creator_Progress); m_creator.Finish += new FinishDelegate(creator_Finished); m_creator.Abort += new AbortDelegate(creator_Abort); // this.Icon = Properties.Resources.CDCat; }
public MainForm() { InitializeComponent(); // textBoxFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); textBoxIsoPath.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "bunny-wabbit.iso"); textBoxVolumeName.Text = "BUNNY-WABBIT"; // m_creator = new IsoCreator(); m_creator.Progress += new ProgressDelegate( creator_Progress ); m_creator.Finish += new FinishDelegate( creator_Finished ); m_creator.Abort += new AbortDelegate( creator_Abort ); // this.Icon = Properties.Resources.CDCat; }
public MainForm() { InitializeComponent(); // textBoxFolder.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); textBoxIsoPath.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "bunny-wabbit.iso"); textBoxVolumeName.Text = "BUNNY-WABBIT"; // m_creator = new IsoCreator(); m_creator.Progress += new ProgressDelegate(creator_Progress); m_creator.Finish += new FinishDelegate(creator_Finished); m_creator.Abort += new AbortDelegate(creator_Abort); // this.Icon = Properties.Resources.CDCat; }
public void ShouldCreateAnIsoWithAFile() { var testFileName = Path.GetRandomFileName(); var testDir = Path.GetRandomFileName(); var testFile = $"{Path.GetTempPath()}{Path.DirectorySeparatorChar}{testDir}{Path.DirectorySeparatorChar}{testFileName}"; var testOutFile = $"{Path.GetTempPath()}{Path.DirectorySeparatorChar}{testDir}{Path.DirectorySeparatorChar}{testFileName}.iso"; if (!Directory.Exists($"{Path.GetTempPath()}{Path.DirectorySeparatorChar}{testDir}")) { Directory.CreateDirectory($"{Path.GetTempPath()}{Path.DirectorySeparatorChar}{testDir}"); } File.WriteAllText(testFile, "0x0abad1d3a"); var builder = new IsoCreator(_fixture.CakeEnvironmentMock.Object, _fixture.CakeLogMock.Object); builder.CreateIso($"{Path.GetTempPath()}{testDir}", testOutFile, "TEST_ISO"); Assert.True(File.Exists(testOutFile)); }
public void ShouldCreateNestedFilesAndDirectories() { var testDir = Path.GetRandomFileName(); var inputPath = $"{Path.GetTempPath()}{testDir}"; var isoDirs = $"{Path.GetTempPath()}{testDir}{Path.DirectorySeparatorChar}nestedOne{Path.DirectorySeparatorChar}nestedTwo{Path.DirectorySeparatorChar}"; if (!Directory.Exists(isoDirs)) { Directory.CreateDirectory(isoDirs); } var testFile = $"{isoDirs}{Path.DirectorySeparatorChar}test.txt"; File.WriteAllText(testFile, "I'm a little file!"); var builder = new IsoCreator(_fixture.CakeEnvironmentMock.Object, _fixture.CakeLogMock.Object); builder.CreateIso(inputPath, $"{inputPath}{Path.DirectorySeparatorChar}dirTest.iso", "DIR_TEST_ISO"); Assert.True(File.Exists($"{inputPath}{Path.DirectorySeparatorChar}dirTest.iso")); }
void StartJob(string input, string output, string label) { var builder = new IsoCreator(); builder.Progress += delegate(object sender, ProgressEventArgs e) { Dispatcher.Invoke(() => { if (e.Maximum < 0) { if (e.Current >= _hotprog.Maximum) { // undetermined? _hottxt.Content = e.Action + " " + (e.Current).ToString("0"); _hotprog.IsIndeterminate = true; } else { // use cache (weird?) _hottxt.Content = e.Action + " " + (e.Current / _hotprog.Maximum).ToString("P1"); _hotprog.Value = e.Current; _hotprog.IsIndeterminate = false; } } else { _hottxt.Content = e.Action + " " + (e.Current / (double)e.Maximum).ToString("P1"); _hotprog.Value = e.Current; _hotprog.Maximum = e.Maximum; _hotprog.IsIndeterminate = false; } }); }; builder.Abort += delegate(object sender, AbortEventArgs e) { Dispatcher.Invoke(() => { _hottxt.Content = e.Message; _hotprog.Value = 0; _hotprog.Maximum = 1; _hotbtn.Content = "Start"; _hotprog.IsIndeterminate = false; hotthread = null; }); }; builder.Finish += delegate(object sender, FinishEventArgs e) { Dispatcher.Invoke(() => { _hottxt.Content = e.Message; _hotprog.Value = 1; _hotprog.Maximum = 1; _hotprog.IsIndeterminate = false; _hotbtn.Content = "Start"; hotthread = null; }); }; _hotbtn.Content = "Abort"; hotthread = new Thread(new ParameterizedThreadStart(builder.Folder2Iso)); hotthread.IsBackground = true; hotthread.Start(new IsoCreator.IsoCreatorFolderArgs(input, output, label)); }