예제 #1
0
        // export the file list to a CSV file
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (listView1.FocusedItem == null)
            {
                return;
            }
            if (listView1.FocusedItem.Tag == null)
            {
                return;
            }
            iPhoneApp app = (iPhoneApp)listView1.FocusedItem.Tag;

            SaveFileDialog fd = new SaveFileDialog();

            fd.Filter           = "CSV file (*.csv)|*.csv|All files (*.*)|*.*";
            fd.FilterIndex      = 1;
            fd.RestoreDirectory = true;
            fd.Title            = "Export the file list of '" + app.Key + "' application";

            if (fd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                using (StreamWriter fs = new StreamWriter(fd.FileName))
                {
                    fs.WriteLine("Path;FileLength;ModificationTime;Domain;Key");

                    foreach (string f in app.Files)
                    {
                        mbdb.MBFileRecord x = files92[Int32.Parse(f)];

                        fs.Write(x.Path);
                        fs.Write(';');
                        fs.Write(x.FileLength);
                        fs.Write(';');
                        fs.Write(x.aTime.ToString());
                        fs.Write(';');
                        fs.Write(x.Domain);
                        fs.Write(';');
                        fs.Write(x.key);
                        fs.WriteLine();
                    }
                }
            }
            finally
            {
            }
        }
예제 #2
0
        private void listView1_Click(object sender, EventArgs e)
        {
            listView2.Items.Clear();
            buttonCSVExport.Enabled = true;

            listView2.BeginUpdate();
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                foreach (ListViewItem item in listView1.SelectedItems)
                {
                    iPhoneApp app = (iPhoneApp)item.Tag;

                    if (app.Files == null)
                    {
                        break;
                    }

                    ListViewItem[] lvic = new ListViewItem[app.Files.Count];
                    int            idx  = 0;

                    foreach (string f in app.Files)
                    {
                        iPhoneFile ff;

                        ff = new iPhoneFile();

                        mbdb.MBFileRecord x = files92[Int32.Parse(f)];

                        ff.Key              = x.key;
                        ff.Domain           = x.Domain;
                        ff.Path             = x.Path;
                        ff.ModificationTime = x.aTime;
                        ff.FileLength       = x.FileLength;



                        ListViewItem lvi = new ListViewItem();
                        lvi.Tag  = ff;
                        lvi.Text = ff.Path;
                        lvi.SubItems.Add(ff.FileLength.ToString("N0"));
                        lvi.SubItems.Add(ff.ModificationTime.ToString());
                        lvi.SubItems.Add(ff.Domain);
                        lvi.SubItems.Add(ff.Key);

                        lvi.SubItems[1].Tag = (long)ff.FileLength;
                        lvi.SubItems[2].Tag = (long)ff.ModificationTime.ToBinary();

                        lvic[idx++] = lvi;
                    }

                    listView2.Items.AddRange(lvic);
                }
            }
            finally
            {
                listView2.EndUpdate();
                Cursor.Current = Cursors.Default;
            }

            toolStripButton4.Enabled = (listView2.Items.Count > 0);
        }
예제 #3
0
        public List <IPhoneApp> GetApps()
        {
            if (File.Exists(System.IO.Path.Combine(Path, "Manifest.mbdb")))
            {
                List <IPhoneApp>    list  = new List <IPhoneApp>();
                mbdb.MBFileRecord[] files = mbdb.ReadMBDB(Path, false, true);
                PListRoot           root  = PListRoot.Load(System.IO.Path.Combine(Path, "Manifest.plist"));
                PListDict           di    = root.Root as PListDict;

                PListDict apps = null;
                if ((apps = di["Applications"] as PListDict) == null)
                {
                    return(list);
                }

                Dictionary <string, List <int> > filesByDomain = new Dictionary <string, List <int> >();
                for (int i = 0; i < files.Length; ++i)
                {
                    if ((files[i].Mode & 0xF000) == 0x8000)
                    {
                        string d = files[i].Domain;
                        if (!filesByDomain.ContainsKey(d))
                        {
                            filesByDomain.Add(d, new List <int>());
                        }

                        filesByDomain[d].Add(i);
                    }
                }

                foreach (var p in apps)
                {
                    IPhoneApp app = new IPhoneApp();

                    app.Key = p.Key;

                    PListDict appd = p.Value as PListDict;

                    KeyValuePair <string, IPListElement> name = appd.FirstOrDefault(x => x.Key == "CFBundleDisplayName");
                    if (name.Value != null)
                    {
                        app.DisplayName = name.Value.Value().ToString();
                    }

                    KeyValuePair <string, IPListElement> bname = appd.FirstOrDefault(x => x.Key == "CFBundleName");
                    if (bname.Value != null)
                    {
                        app.Name = bname.Value.Value().ToString();
                    }

                    KeyValuePair <string, IPListElement> ident = appd.FirstOrDefault(x => x.Key == "CFBundleIdentifier");
                    if (ident.Value != null)
                    {
                        app.Identifier = ident.Value.Value().ToString();
                    }

                    KeyValuePair <string, IPListElement> cont = appd.FirstOrDefault(x => x.Key == "Container");
                    if (cont.Value != null)
                    {
                        app.Container = cont.Value.Value().ToString();
                    }

                    if (app.Name == null)
                    {
                        app.Name = app.Key;
                    }
                    if (app.DisplayName == null)
                    {
                        app.DisplayName = app.Name;
                    }

                    if (filesByDomain.ContainsKey("AppDomain-" + app.Key))
                    {
                        app.Files = new List <IPhoneFile>();

                        foreach (int i in filesByDomain["AppDomain-" + app.Key])
                        {
                            IPhoneFile        ff = new IPhoneFile();
                            mbdb.MBFileRecord x  = files[i];
                            ff.Key              = x.key;
                            ff.Domain           = x.Domain;
                            ff.Path             = x.Path;
                            ff.ModificationTime = x.aTime.ToString();
                            ff.FileLength       = x.FileLength;
                            app.Files.Add(ff);
                        }

                        filesByDomain.Remove("AppDomain-" + app.Key);
                    }
                    list.Add(app);
                }

                IPhoneApp system = new IPhoneApp();
                system.Name        = "System";
                system.DisplayName = "---";
                system.Identifier  = "---";
                system.Container   = "---";
                system.Files       = new List <IPhoneFile>();

                foreach (List <int> i in filesByDomain.Values)
                {
                    foreach (int j in i)
                    {
                        IPhoneFile        ff = new IPhoneFile();
                        mbdb.MBFileRecord x  = files[j];
                        ff.Key              = x.key;
                        ff.Domain           = x.Domain;
                        ff.Path             = x.Path;
                        ff.ModificationTime = x.aTime.ToString();
                        ff.FileLength       = x.FileLength;
                        system.Files.Add(ff);
                    }
                }
                list.Add(system);
                return(list);
            }
            else
            {
                throw new FileLoadException("Can only handle iTunes <= v9.2");
            }
        }