~ubuntu-branches/ubuntu/quantal/ipod-sharp/quantal

« back to all changes in this revision

Viewing changes to tools/DmgIsoExtract.cs

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-11-13 12:36:39 UTC
  • mfrom: (1.1.4 upstream) (6.1.5 edgy)
  • Revision ID: james.westby@ubuntu.com-20061113123639-cynm2axegef1etff
* New upstream release
* debian/patches/01_fix-playcounts.patch:
  + Dropped, merged upstream
* debian/control:
  + Build depend on mono-gmcs, libmono-sharpzip2.84-cil, libmono2.0-cil,
    libglib2.0-dev and libipoddevice >= 0.5.0
  + Bumped Standards-Version to 3.7.2
  + Add ${misc:Depends} to Depends
  + Let libipodui-cil depend on libipod-cil
* debian/libipod-cil.install:
  + Add ipod-sharp-firmware.dll
* debian/patches/01_dllmap.patch:
  + Add dllmap to libgobject-2.0.so.0 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.IO;
 
3
using Dmg;
 
4
 
 
5
public static class DmgIsoExtract
 
6
{
 
7
    public static int Main(string [] args)
 
8
    {
 
9
        string dmg_file = null;
 
10
        string iso_file = null;
 
11
        string plist_file = null;
 
12
        bool list_partitions = false;
 
13
    
 
14
        if(args.Length < 1) {
 
15
            ShowHelp();
 
16
            return 1;
 
17
        }
 
18
        
 
19
        for(int i = 0; i < args.Length; i++) {
 
20
            switch(args[i]) {
 
21
                case "--list-partitions":
 
22
                    list_partitions = true;
 
23
                    break;
 
24
                case "--dump-plist":
 
25
                    plist_file = args[++i];
 
26
                    break;
 
27
                case "--help":
 
28
                    ShowHelp();
 
29
                    return 1;
 
30
                default:
 
31
                    if(dmg_file == null) {
 
32
                        dmg_file = args[i];
 
33
                    } else if(iso_file == null) {
 
34
                        iso_file = args[i];
 
35
                    } else {
 
36
                        Console.Error.WriteLine("Invalid argument: `{0}'", args[0]);
 
37
                        return 1;
 
38
                    }
 
39
                    break;
 
40
            }
 
41
        }
 
42
        
 
43
        if(!File.Exists(dmg_file)) {
 
44
            Console.Error.WriteLine("DMG file `{0}' does not exist", dmg_file);
 
45
            return 1;
 
46
        }
 
47
        
 
48
        FileStream dmg_stream = new FileStream(dmg_file, FileMode.Open);
 
49
        Image image = new Image(dmg_stream);
 
50
        
 
51
        if(list_partitions) {
 
52
            foreach(Partition partition in image) {
 
53
                Console.WriteLine("ID = {0}, Name = {1}, Attributes = 0x{2:x2}", 
 
54
                    partition.ID, partition.Name, partition.AttributesNumeric);
 
55
            }
 
56
        }
 
57
        
 
58
        if(plist_file != null) {
 
59
            image.SavePartitionsXml(new FileStream(plist_file, FileMode.Create));
 
60
        }
 
61
        
 
62
        if(iso_file != null) {
 
63
            image.Extract(new FileStream(iso_file, FileMode.Create));
 
64
        }
 
65
    
 
66
        return 0;
 
67
    }
 
68
    
 
69
    private static void ShowHelp()
 
70
    {
 
71
        Console.Error.WriteLine("Usage: dmg-iso-extract <dmg-file> [<iso-file>] [--list-partitions]");
 
72
        Console.Error.WriteLine("         [--dump-plist <plist-file>]\n");
 
73
        Console.Error.WriteLine("   <dmg-file>                 DMG input file to read (required)");
 
74
        Console.Error.WriteLine("   <iso-file>                 HFS+ ISO file to output (optional)");
 
75
        Console.Error.WriteLine("   --list-partitions          Show the partitions in the DMG image");
 
76
        Console.Error.WriteLine("   --dump-plist <plist-file>  Dump the raw plist XML to file\n");
 
77
        Console.Error.WriteLine("   --help                     Show this help\n");
 
78
    }
 
79
}