Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
     {
         m_Pack = PackResourceSet.CreateFromFile(openFileDialog1.FileName);
         if (m_Pack != null)
         {
             m_Tree.BeginUpdate();
             m_Tree.Nodes.Clear();
             m_Root = m_Tree.Nodes.Add("data");
             for (uint i = 0; i < m_Pack.GetFileCount(); ++i)
             {
                 PackResource pr = m_Pack.GetFileByIndex(i);
                 if (pr != null)
                 {
                     InsertFileNode(pr.GetName());
                 }
             }
             m_Root.Expand();
             m_Tree.EndUpdate();
         }
     }
 }
Exemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
     {
         m_Pack = PackResourceSet.CreateFromFile(openFileDialog1.FileName);
         if (m_Pack != null)
         {
             m_Tree.BeginUpdate();
             m_Tree.Nodes.Clear();
             m_Root = m_Tree.Nodes.Add("data");
             for (uint i = 0; i < m_Pack.GetFileCount(); ++i)
             {
                 PackResource pr = m_Pack.GetFileByIndex(i);
                 if (pr != null)
                 {
                     InsertFileNode(pr.GetName());
                 }
             }
             m_Root.Expand();
             m_Tree.EndUpdate();
         }
     }
 }
Exemplo n.º 3
0
        /***********************************************************************************************/
        /// <summary>
        /// Draw file tree (Left panel)
        /// </summary>
        /// <param name="id"></param>
        private void InsertFileNode(uint id)
        {
            PackResource pr = m_Pack.GetFileByIndex(id);

            if (pr != null)
            {
                string filePath = pr.GetName();
                this.pd.Detail = filePath;
                string[] paths = filePath.Split('\\');
                TreeNode node  = m_Root;
                for (uint i = 0; i < paths.Length; ++i)
                {
                    int index = node.Nodes.IndexOfKey(paths[i]);
                    if (index < 0)
                    {
                        // Add( name , text)
                        string Ext = Path.GetExtension(@paths[i]);
                        if (Ext != "")
                        {
                            switch (Ext)
                            {
                            case ".txt":
                                node = node.Nodes.Add(paths[i], paths[i], 2, 2);
                                if (@paths[i] == "!Readme.txt")
                                {
                                    PreviewById(id);
                                }
                                break;

                            case ".xml":
                            case ".trn":
                                node = node.Nodes.Add(paths[i], paths[i], 3, 3);
                                break;

                            case ".jpg":
                            case ".psd":
                            case ".bmp":
                            case ".dds":
                            case ".tga":
                            case ".gif":
                            case ".png":
                                node = node.Nodes.Add(paths[i], paths[i], 4, 4);
                                break;

                            case ".ttf":
                            case ".ttc":
                                node = node.Nodes.Add(paths[i], paths[i], 5, 5);
                                break;

                            case ".wav":
                            case ".mp3":
                                node = node.Nodes.Add(paths[i], paths[i], 6, 6);
                                break;

                            default:
                                if (@paths[i] == "vf.dat")
                                {
                                    node = node.Nodes.Add(paths[i], paths[i], 3, 3);
                                    PreviewById(id);
                                }
                                else
                                {
                                    node = node.Nodes.Add(paths[i], paths[i], 1, 1);
                                }
                                break;
                            }
                        }
                        else
                        {
                            node = node.Nodes.Add(paths[i], paths[i]);
                        }
                        node.Tag = id;
                    }
                    else
                    {
                        node = node.Nodes[index];
                    }
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Unpacking Package file process.
        /// </summary>
        /// <param name="InputFile">Set filename of unpack file..</param>
        /// <param name="OutputDir">Set output distnation of Unpacked files.</param>
        public void Unpack(string InputFile, string OutputDir)
        {
            if (!isCLI)
            {
                this.pd.Caption = Properties.Resources.Str_Unpack;
                this.pd.ShowDialog(ProgressDialog.PROGDLG.Normal);
            }
            Console.WriteLine("Unpack");

            m_Unpack = PackResourceSet.CreateFromFile(InputFile);

            uint packed_files = m_Unpack.GetFileCount();

            if (!isCLI)
            {
                pd.Maximum = packed_files;
                if (this.pd.HasUserCancelled)
                {
                    m_Unpack.Dispose();
                    this.pd.CloseDialog();
                    return;
                }
            }
            for (uint i = 0; i < packed_files; ++i)
            {
                PackResource Res          = m_Unpack.GetFileByIndex(i);
                String       InternalName = Res.GetName();
                if (!isCLI)
                {
                    this.pd.Message = String.Format(Properties.Resources.Str_Unpacking, i, packed_files);
                    this.pd.Detail  = "data\\" + InternalName;
                    this.pd.Value   = i;
                    if (pd.HasUserCancelled)
                    {
                        m_Unpack.Dispose();
                        Interrupt();
                        return;
                    }
                }
                Console.WriteLine(String.Format("{0}/{1} {2}", i, packed_files, InternalName));
                // loading file content.
                byte[] buffer = new byte[Res.GetSize()];
                Res.GetData(buffer);
                Res.Close();
                // Get output Directory Name
                String outputPath = @OutputDir + "\\data\\" + InternalName;
                // Create directory
                String DirPath = Regex.Replace(outputPath, @"([^\\]*?)$", "");
                if (!Directory.Exists(DirPath))
                {
                    Directory.CreateDirectory(DirPath);
                }
                // Delete old
                if (File.Exists(outputPath))
                {
                    //DateTime dtUpdate = System.IO.File.GetLastWriteTime(outputPath);
                    //if (dtUpdate > Res.GetModified()){
                    File.Delete(@outputPath);
                    //}else{
                    //Todo Overwrite confirm dialog
                    //}
                }
                if (Directory.Exists(outputPath))
                {
                    Directory.Delete(@outputPath);
                }
                // Write to file.
                FileStream fs = new FileStream(outputPath, System.IO.FileMode.Create);
                fs.Write(buffer, 0, buffer.Length);
                fs.Close();
                // Modify File time
                File.SetCreationTime(outputPath, Res.GetCreated());
                File.SetLastAccessTime(outputPath, Res.GetAccessed());
                File.SetLastWriteTime(outputPath, Res.GetModified());
            }
            m_Unpack.Dispose();
            if (!isCLI)
            {
                this.pd.CloseDialog();
            }
            Console.WriteLine("Finish.");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Unpacking Package file process.
        /// </summary>
        /// <param name="InputFile">Set filename of unpack file..</param>
        /// <param name="OutputDir">Set output distnation of Unpacked files.</param>
        public void Unpack(string InputFile, string OutputDir)
        {
            if (!isCLI)
            {
                this.pd.Caption = Properties.Resources.Str_Unpack;
                this.pd.ShowDialog(ProgressDialog.PROGDLG.Normal);
            }
            Console.WriteLine("Unpack");

            m_Unpack = PackResourceSet.CreateFromFile(InputFile);

            uint packed_files = m_Unpack.GetFileCount();
            if (!isCLI)
            {
                pd.Maximum = packed_files;
                if (this.pd.HasUserCancelled)
                {
                    m_Unpack.Dispose();
                    this.pd.CloseDialog();
                    return;
                }
            }
            for (uint i = 0; i < packed_files; ++i)
            {
                PackResource Res = m_Unpack.GetFileByIndex(i);
                String InternalName = Res.GetName();
                if (!isCLI)
                {
                    this.pd.Message = String.Format(Properties.Resources.Str_Unpacking, i, packed_files);
                    this.pd.Detail = "data\\" + InternalName;
                    this.pd.Value = i;
                    if (pd.HasUserCancelled)
                    {
                        m_Unpack.Dispose();
                        Interrupt();
                        return;
                    }
                }
                Console.WriteLine(String.Format("{0}/{1} {2}", i, packed_files, InternalName));
                // loading file content.
                byte[] buffer = new byte[Res.GetSize()];
                Res.GetData(buffer);
                Res.Close();
                // Get output Directory Name
                String outputPath = @OutputDir + "\\data\\" + InternalName;
                // Create directory
                String DirPath = Regex.Replace(outputPath, @"([^\\]*?)$", "");
                if (!Directory.Exists(DirPath))
                {
                    Directory.CreateDirectory(DirPath);
                }
                // Delete old
                if (File.Exists(outputPath))
                {
                    //DateTime dtUpdate = System.IO.File.GetLastWriteTime(outputPath);
                    //if (dtUpdate > Res.GetModified()){
                        File.Delete(@outputPath);
                    //}else{
                        //Todo Overwrite confirm dialog
                    //}
                }
                if (Directory.Exists(outputPath))
                {
                    Directory.Delete(@outputPath);
                }
                // Write to file.
                FileStream fs = new FileStream(outputPath, System.IO.FileMode.Create);
                fs.Write(buffer, 0, buffer.Length);
                fs.Close();
                // Modify File time
                File.SetCreationTime(outputPath, Res.GetCreated());
                File.SetLastAccessTime(outputPath, Res.GetAccessed());
                File.SetLastWriteTime(outputPath, Res.GetModified());
            }
            m_Unpack.Dispose();
            if (!isCLI)
            {
                this.pd.CloseDialog();
            }
            Console.WriteLine("Finish.");
        }