Ejemplo n.º 1
0
        static int Main(string [] args)
        {
            UpdaterOptions opts             = new UpdaterOptions(args);
            bool           debuggerAttached = false;

            if (opts.RemainingArguments.Length == 2)
            {
                Console.Error.WriteLine("Usage: DiskImageUpdater -i <kernel> -o <disk image>");
                Console.Error.WriteLine("Run `DiskImageUpdater -help` for more information.");
                return(1);
            }

            // Prevent a Mono error if one occurs.
            try {
                debuggerAttached = System.Diagnostics.Debugger.IsAttached;
            } catch {
            }

            if (debuggerAttached)
            {
                Ext2FS ext2fs = new Ext2FS();
                ext2fs.UpdateKernel(opts.DiskImg, opts.SharpOSKernelBin, opts.HasMBR);
            }
            else
            {
                try {
                    Ext2FS ext2fs = new Ext2FS();
                    ext2fs.UpdateKernel(opts.DiskImg, opts.SharpOSKernelBin, opts.HasMBR);

                    Console.WriteLine(string.Format("'{0}' has been updated.", opts.DiskImg));
                } catch (FileNotFoundException exception) {
                    Console.WriteLine(string.Format("Could not find '{0}'.", exception.FileName));
                    return(1);
                } catch (Exception exception) {
                    Console.WriteLine(exception.Message);
                    return(1);
                }
            }

            if (opts.OutputVHD != string.Empty)
            {
                try {
                    MsVhd.CreateFromImage(opts.DiskImg, opts.OutputVHD);

                    Console.WriteLine(string.Format("'{0}' virtual disk has been created.", opts.OutputVHD));
                } catch (Exception exception) {
                    Console.WriteLine(exception.Message);
                    return(1);
                }
            }

            return(0);
        }
Ejemplo n.º 2
0
		static int Main (string [] args)
		{
			UpdaterOptions opts = new UpdaterOptions (args);
			bool debuggerAttached = false;

			if (opts.RemainingArguments.Length == 2) {
				Console.Error.WriteLine ("Usage: DiskImageUpdater -i <kernel> -o <disk image>");
				Console.Error.WriteLine ("Run `DiskImageUpdater -help` for more information.");
				return 1;
			}

			// Prevent a Mono error if one occurs.
			try {
				debuggerAttached = System.Diagnostics.Debugger.IsAttached;
			} catch {
			}

			if (debuggerAttached) {
				Ext2FS ext2fs = new Ext2FS ();
				ext2fs.UpdateKernel (opts.DiskImg, opts.SharpOSKernelBin, opts.HasMBR);

			} else {
				try {
					Ext2FS ext2fs = new Ext2FS ();
					ext2fs.UpdateKernel (opts.DiskImg, opts.SharpOSKernelBin, opts.HasMBR);

					Console.WriteLine (string.Format ("'{0}' has been updated.", opts.DiskImg));

				} catch (FileNotFoundException exception) {
					Console.WriteLine (string.Format ("Could not find '{0}'.", exception.FileName));
					return 1;
				} catch (Exception exception) {
					Console.WriteLine (exception.Message);
					return 1;
				}
			}

			if (opts.OutputVHD!=string.Empty)
			{
				try {
					MsVhd.CreateFromImage (opts.DiskImg, opts.OutputVHD);

					Console.WriteLine (string.Format ("'{0}' virtual disk has been created.", opts.OutputVHD));

				} catch (Exception exception) {
					Console.WriteLine (exception.Message);
					return 1;
				}
			}

			return 0;
		}