Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            if (args[0] == "--help")
            {
                Console.WriteLine("usage:\r\nvget image-file filename [newname]\r\nvget --help");
                return(0);
            }
            switch (args.Length)
            {
            case 2:
            case 3:
                if (!System.IO.File.Exists(args[0]))
                {
                    Console.Error.WriteLine("vget: Disk image file does not exist.");
                    return(1);
                }
                try
                {
                    FATVolume fv = new FATVolume(args[0]);
                    if (!fv.Exists(args[1]))
                    {
                        Console.Error.WriteLine("vget: File does not exist on image.");
                        return(1);
                    }
                    args[1] = args[1].Replace('/', '\\');
                    string name =
                        args.Length == 3 ?
                        args[2] :
                        args[1].Contains("\\") ?
                        args[1].Substring(args[1].LastIndexOf('\\') + 1) :
                        args[1];

                    System.IO.Stream sw = new System.IO.FileStream(name, System.IO.FileMode.Create);
                    System.IO.Stream sr = fv.OpenFile(args[1], System.IO.FileAccess.Read, System.IO.FileMode.Open);
                    byte[]           x  = new byte[1024];
                    while (sr.Position < sr.Length)
                    {
                        sw.Write(x, 0, sr.Read(x, 0, (int)Math.Min(1024, sr.Length - sr.Position)));
                    }
                    sr.Close();
                    sw.Close();
                    fv.Close();
                }
                catch (Exception e)
                {
                    System.Console.Error.WriteLine("vget: error: {0}", e.Message);
                    return(1);
                }
                return(0);

            default:
                Console.Error.WriteLine("vget: wrong number of arguments given");
                Console.WriteLine("usage:\r\nvget image-file filename newname\r\nvget --help");
                return(1);
            }
        }
Ejemplo n.º 2
0
 private void listView1_ItemActivate(object sender, EventArgs e)
 {
     if (listView1.SelectedItems[0].ImageIndex == 1)
     {
         SetDir((FileInfo)listView1.SelectedItems[0].Tag);
     }
     else
     {
         string t = statusStrip1.Items[0].Text;
         statusStrip1.Items[0].Text = string.Format("Extracting '{0}'...", ((FileInfo)listView1.SelectedItems[0].Tag).FileName);
         statusStrip1.Refresh();
         string           fname = tempFol + "\\" + ((FileInfo)listView1.SelectedItems[0].Tag).FileName;
         System.IO.Stream s     = vol.OpenFile(((FileInfo)listView1.SelectedItems[0].Tag).FullPath, System.IO.FileAccess.Read, System.IO.FileMode.Open);
         byte[]           b     = new byte[s.Length];
         s.Read(b, 0, b.Length);
         System.IO.File.WriteAllBytes(fname, b);
         System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo(fname);
         si.UseShellExecute = true;
         si.ErrorDialog     = true;
         FormWindowState            ws = WindowState;
         System.Diagnostics.Process p;
         try
         {
             p           = System.Diagnostics.Process.Start(fname);
             WindowState = FormWindowState.Minimized;
             p.WaitForExit();
             WindowState = ws;
         }
         catch (Win32Exception ex)
         {
             MessageBox.Show(ex.Message, "vgui", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         finally
         {
             statusStrip1.Items[0].Text = t;
         }
     }
 }
Ejemplo n.º 3
0
        static int Main(string[] args)
        {
            if (args[0] == "--help")
            {
                Console.WriteLine("usage:\r\nvput image-file file newname\r\nvput --help");
                return(0);
            }
            switch (args.Length)
            {
            case 3:
                if (!System.IO.File.Exists(args[0]) || !System.IO.File.Exists(args[1]))
                {
                    Console.Error.WriteLine("vput: File does not exist.");
                    return(1);
                }
                try
                {
                    FATVolume        fv = new FATVolume(args[0]);
                    System.IO.Stream sr = new System.IO.FileStream(args[1], System.IO.FileMode.Open);
                    System.IO.Stream sw = fv.OpenFile(args[2], System.IO.FileAccess.Write, System.IO.FileMode.Create);
                    byte[]           x  = new byte[1024];
                    while (sr.Position < sr.Length)
                    {
                        sw.Write(x, 0, sr.Read(x, 0, (int)Math.Min(1024, sr.Length - sr.Position)));
                    }
                    sw.Close();
                    sr.Close();
                    fv.Close();
                }
                catch (Exception e)
                {
                    System.Console.Error.WriteLine("vput: error: {0}", e.Message);
                    return(1);
                }
                return(0);

            default:
                Console.Error.WriteLine("vput: wrong number of arguments given");
                Console.WriteLine("usage:\r\nvput image-file file newname\r\nvput --help");
                return(1);
            }
        }
Ejemplo n.º 4
0
        static int Main(string[] args)
        {
            if (args[0] == "--help")
            {
                Console.WriteLine("usage:\r\nvout image-file filename\r\nvout --help");
                return(0);
            }
            switch (args.Length)
            {
            case 2:
                if (!System.IO.File.Exists(args[0]))
                {
                    Console.Error.WriteLine("vout: Disk image file does not exist.");
                    return(1);
                }
                try
                {
                    FATVolume fv = new FATVolume(args[0]);
                    if (!fv.Exists(args[1]))
                    {
                        Console.Error.WriteLine("vout: File does not exist on image.");
                        return(1);
                    }
                    System.IO.StreamReader tr = new System.IO.StreamReader(fv.OpenFile(args[1], System.IO.FileAccess.Read, System.IO.FileMode.Open));
                    System.Console.Out.Write(tr.ReadToEnd());
                    tr.Close();
                    fv.Close();
                }
                catch (Exception e)
                {
                    System.Console.Error.WriteLine("vout: error: {0}", e.Message);
                    return(1);
                }
                return(0);

            default:
                Console.Error.WriteLine("vout: wrong number of arguments given");
                Console.WriteLine("usage:\r\nvout image-file filename\r\nvout --help");
                return(1);
            }
        }
Ejemplo n.º 5
0
        static int Main(string[] args)
        {
            if (args[0] == "--help")
            {
                Console.WriteLine("usage:\r\nvin image-file newfile\r\nvin --help");
                return(0);
            }
            switch (args.Length)
            {
            case 2:
                if (!System.IO.File.Exists(args[0]))
                {
                    Console.Error.WriteLine("vin: Disk image file does not exist.");
                    return(1);
                }
                try
                {
                    FATVolume fv = new FATVolume(args[0]);
                    System.IO.StreamWriter sw = new System.IO.StreamWriter(fv.OpenFile(args[1], System.IO.FileAccess.Write, System.IO.FileMode.Create));
                    sw.Write(Console.In.ReadToEnd());
                    sw.Close();
                    fv.Close();
                }
                catch (Exception e)
                {
                    System.Console.Error.WriteLine("vin: error: {0}", e.Message);
                    return(1);
                }
                return(0);

            default:
                Console.Error.WriteLine("vin: wrong number of arguments given");
                Console.WriteLine("usage:\r\nvin image-file newfile\r\nvin --help");
                return(1);
            }
        }