Skip to content

Commit

Permalink
Revert "Code cleanup."
Browse files Browse the repository at this point in the history
This reverts commit 571aadf.
  • Loading branch information
quajak committed Oct 2, 2018
1 parent 571aadf commit d5352d1
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
56 changes: 56 additions & 0 deletions source/Cosmos.Build.Common/IsoMaker.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using System.IO;
using System.Text;

namespace Cosmos.Build.Common
{
public class IsoMaker
{
static public string Generate(string imageFile, string isoFilename)
{
var destinationDirectory = Path.GetDirectoryName(imageFile);

string isoDirectory = Path.Combine(destinationDirectory, "iso");

if (Directory.Exists(isoDirectory))
{
Directory.Delete(isoDirectory, true);
}

Directory.CreateDirectory(isoDirectory);

var buildISO = Path.Combine(CosmosPaths.Build, "ISO");

File.Copy(Path.Combine(buildISO, "isolinux.bin"), Path.Combine(isoDirectory, "isolinux.bin"));
File.Copy(Path.Combine(buildISO, "mboot.c32"), Path.Combine(isoDirectory, "mboot.c32"));
File.Copy(Path.Combine(buildISO, "syslinux.cfg"), Path.Combine(isoDirectory, "syslinux.cfg"));
File.Copy(Path.Combine(buildISO, "ldlinux.c32"), Path.Combine(isoDirectory, "ldlinux.c32"));
File.Copy(Path.Combine(buildISO, "libcom32.c32"), Path.Combine(isoDirectory, "libcom32.c32"));
File.Copy(imageFile, Path.Combine(isoDirectory, "Cosmos.bin"));

string arg =
"-relaxed-filenames" +
" -J -R" +
" -o " + Quote(isoFilename) +
" -b isolinux.bin" +
" -no-emul-boot" +
" -boot-load-size 4" +
" -boot-info-table " +
Quote(isoDirectory);

var output = ProcessExtension.LaunchApplication(
Path.Combine(Path.Combine(CosmosPaths.Tools, "mkisofs"), "mkisofs.exe"),
arg,
true
);

return output;
}

protected static string Quote(string location)
{
return '"' + location + '"';
}

}
}
32 changes: 32 additions & 0 deletions source/Cosmos.Build.Common/ProcessExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Diagnostics;

namespace Cosmos.Build.Common
{
public static class ProcessExtension
{
public static string LaunchApplication(string app, string args, bool waitForExit)
{
var start = new ProcessStartInfo();
start.FileName = app;
start.Arguments = args;
start.UseShellExecute = false;
start.CreateNoWindow = true;
start.RedirectStandardOutput = true;
start.RedirectStandardError = true;

var process = Process.Start(start);

if (waitForExit)
{
var output = process.StandardOutput.ReadToEnd();

process.WaitForExit();

var error = process.StandardError.ReadToEnd();
return output + error;
}

return string.Empty;
}
}
}

0 comments on commit d5352d1

Please sign in to comment.