Exemplo n.º 1
0
        private void UpdateFolders()
        {
            this.listView1.Items.Clear();
            this.toolStripTextBox1.Text = BaseJMDFile.NowPath;
            List <ListViewItem> lists = new List <ListViewItem>();

            foreach (IPackedObject ipo in BaseJMDFile.NowFolderContent)
            {
                ListViewItem lvi;
                if (ipo.Type == ObjectType.File)
                {
                    JMDPackedFileInfo jpfi = (JMDPackedFileInfo)ipo;
                    lvi          = new ListViewItem(new string[] { jpfi.FileName + '.' + jpfi.Extension, $"0x{Convert.ToString(jpfi.Index, 16).PadLeft(8, '0')}", ("listview_item2_file").GetStringBag() });
                    lvi.ImageKey = "file";
                    if (BaseJMDFile.ModifiedFileInfos.Exists(x => x.FileIndex == jpfi.Index))
                    {
                        lvi.BackColor = Color.Red;
                    }
                }
                else
                {
                    JMDPackedFolderInfo jpfi = (JMDPackedFolderInfo)ipo;
                    lvi          = new ListViewItem(new string[] { jpfi.FolderName, $"0x{Convert.ToString(jpfi.Index, 16).PadLeft(8, '0')}", ("listview_item2_folder").GetStringBag() });
                    lvi.ImageKey = "folder";
                    if (BaseJMDFile.ModifiedFileInfos.Exists(x => x.FolderIndex == jpfi.Index))
                    {
                        lvi.BackColor = Color.Orange;
                    }
                }
                lists.Add(lvi);
            }
            listView1.Items.AddRange(lists.ToArray());
        }
Exemplo n.º 2
0
        private void ExportAllFolder_bg(string outputPath, bool IncludeSubFolder, JMDFile file)
        {
            IPackedObject[]         ipos  = JMDPackedFilesInfoDecoder.GetJMDPackedFileInfos(file.GetStreamData(0xFFFFFFFF), file.HeaderKey, 0xFFFFFFFF);
            Stack <ExportProcessor> Stack = new Stack <ExportProcessor>();

            if (!Directory.Exists(outputPath))
            {
                throw new Exception("");
            }
            string StartPath = "";

            Stack.Push(new ExportProcessor
            {
                Path = StartPath,
                ipos = ipos
            });
            while (Stack.Count > 0 && !Canceled)
            {
                ExportProcessor ep      = Stack.Pop();
                string          outPath = outputPath + (StartPath == "" ? ep.Path : ep.Path.Replace(StartPath, ""));
                foreach (IPackedObject ipo in ep.ipos)
                {
                    if (ipo.Type == ObjectType.Folder && IncludeSubFolder)
                    {
                        JMDPackedFolderInfo jpfi = (JMDPackedFolderInfo)ipo;
                        ExportProcessor     nep  = new ExportProcessor
                        {
                            Path = ep.Path + $"\\{jpfi.FolderName}",
                            ipos = JMDPackedFilesInfoDecoder.GetJMDPackedFileInfos(file.GetStreamData(jpfi.Index), file.HeaderKey, jpfi.Index)
                        };
                        Stack.Push(nep);
                        if (!Directory.Exists($"{outPath}\\{((JMDPackedFolderInfo)ipo).FolderName}"))
                        {
                            Directory.CreateDirectory($"{outPath}\\{((JMDPackedFolderInfo)ipo).FolderName}");
                        }
                        continue;
                    }
                    if (ipo.Type == ObjectType.File)
                    {
                        JMDPackedFileInfo jfi = (JMDPackedFileInfo)ipo;
                        ChangeText(label5, $"Outputing: {ep.Path}\\{jfi.FileName}.{jfi.Extension}");
                        FileStream fs   = new FileStream($"{outPath}\\{jfi.FileName}.{jfi.Extension}", FileMode.Create);
                        byte[]     data = file.GetPackedFile(jfi);
                        fs.Write(data, 0, data.Length);
                        fs.Close();
                        data = null;
                    }
                    if (Canceled)
                    {
                        break;
                    }
                }
            }
            CloseWindow();
        }