当前位置: 首页>>代码示例>>C#>>正文


C# IPluginHost.ChangeFile方法代码示例

本文整理汇总了C#中IPluginHost.ChangeFile方法的典型用法代码示例。如果您正苦于以下问题:C# IPluginHost.ChangeFile方法的具体用法?C# IPluginHost.ChangeFile怎么用?C# IPluginHost.ChangeFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPluginHost的用法示例。


在下文中一共展示了IPluginHost.ChangeFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Pack_PKH2

        public static void Pack_PKH2(ref sFolder unpacked, sFile pkh, string fileOut, IPluginHost pluginHost)
        {
            string fileOut2 = pluginHost.Get_TempFile();

            BinaryReader br = new BinaryReader(File.OpenRead(pkh.path));
            BinaryWriter bwPkb = new BinaryWriter(File.OpenWrite(fileOut));
            BinaryWriter bwPkh = new BinaryWriter(File.OpenWrite(fileOut2));

            int num_files = (int)br.BaseStream.Length / 0x10;

            // Get the PKH info
            uint[,] info = new uint[num_files, 5];
            for (int i = 0; i < num_files; i++)
            {
                info[i, 2] = br.ReadUInt32();   // ID
                info[i, 0] = br.ReadUInt32();   // old offset, used to get the file order
                info[i, 1] = br.ReadUInt32();   // old size
                br.BaseStream.Position += 4;    // Skip LZSS header
            }
            br.Close();
            br = null;

            File_Order2(ref info);  // Get the file order

            // Create PKB file, we write it in order
            uint offset = 0;
            for (int i = 0; i < num_files; i++)
            {
                // Get the index of the next file to write
                int index = 0;
                for (; index < num_files; index++)
                    if (info[index, 4] == i)
                        break;
                if (info[index, 4] != i)
                    Console.WriteLine("Error searching index file!");

                sFile cfile = unpacked.files[index];

                // Write PKB file
                BinaryReader br_file = new BinaryReader(File.OpenRead(cfile.path));
                br_file.BaseStream.Position = cfile.offset;

                bwPkb.Write(br_file.ReadBytes((int)cfile.size));        //Write File in new PKB
                while (bwPkb.BaseStream.Position % 0x10 != 0)           // Padding
                    bwPkb.Write((byte)0xFF);
                bwPkb.Flush();

                // Get LZSS header
                br_file.BaseStream.Position = cfile.offset;
                info[index, 3] = br_file.ReadUInt32();
                if ((info[index, 3] & 0xFF) != 0x10 || ((info[index, 3] >> 8) == 0))         // File no compressed, it can be a PAC file
                    info[index, 3] = 0;

                br_file.Close();
                br_file = null;

                // Set new values
                cfile.offset = offset;
                cfile.path = fileOut;
                offset += cfile.size;
                if (offset % 0x10 != 0)                 // Padding offset
                    offset += 0x10 - (offset % 0x10);

                unpacked.files[index] = cfile;
            }

            for (int i = 0; i < num_files; i++)
            {
                // Write PKH file
                bwPkh.Write(info[i, 2]);           // Unknown ID
                bwPkh.Write(unpacked.files[i].offset);
                bwPkh.Write(unpacked.files[i].size);
                bwPkh.Write(info[i, 3]);
            }

            // The file is padded
            while (bwPkh.BaseStream.Position % 0x10 != 0)
                bwPkh.Write((byte)0xFF);

            // Flush and close files
            bwPkh.Flush();

            bwPkh.Close();
            bwPkb.Close();

            pluginHost.ChangeFile(pkh.id, fileOut2);
        }
开发者ID:MetLob,项目名称:tinke,代码行数:87,代码来源:Packs.cs

示例2: Pack_PKH1

        public static void Pack_PKH1(ref sFolder unpacked, sFile pkh, string fileOut, IPluginHost pluginHost)
        {
            string pkh_out = pluginHost.Get_TempFile();

            BinaryReader br = new BinaryReader(File.OpenRead(pkh.path));
            BinaryWriter bwPkb = new BinaryWriter(File.OpenWrite(fileOut));
            BinaryWriter bwPkh = new BinaryWriter(File.OpenWrite(pkh_out));

            // Write header
            bwPkh.Write(Encoding.ASCII.GetChars(br.ReadBytes(16))); // Header
            bwPkh.Write(br.ReadUInt16());                           //File_Size
            ushort type = br.ReadUInt16();
            bwPkh.Write(type);                                      //Type
            bwPkh.Write(br.ReadUInt16());                           //Unknown
            ushort num_files = br.ReadUInt16();
            bwPkh.Write(num_files);                                 //Num_files
            bwPkh.Write(br.ReadUInt32());                           //Unknown

            if (type == 0)
                bwPkh.Write(br.ReadUInt32());                       //Block_Length
            else if (type == 2 || type == 3)
            {
                bwPkh.Write(unpacked.files[0].size);
                br.BaseStream.Position += 4;
            }

            bwPkh.Write(br.ReadBytes(0x10));                        // Unknown, usually 0x00 but not always

            uint offset = 0;
            for (int i = 0; i < num_files; i++)
            {
                BinaryReader br_file = new BinaryReader(File.OpenRead(unpacked.files[i].path));
                br_file.BaseStream.Position = unpacked.files[i].offset;
                bwPkb.Write(br_file.ReadBytes((int)unpacked.files[i].size));  //Write File in new PKB
                while (bwPkb.BaseStream.Position % 0x10 != 0)       // Padding
                    bwPkb.Write((byte)0xFF);
                br_file.Close();
                bwPkb.Flush();

                if (type == 0)
                {
                    bwPkh.Write(br.ReadUInt32());           // Unknown, ID¿?
                    bwPkh.Write(offset);                    // Offset
                    bwPkh.Write(unpacked.files[i].size);    //Size File

                    sFile cfile = unpacked.files[i];
                    cfile.offset = offset;
                    cfile.path = fileOut;
                    unpacked.files[i] = cfile;

                    br.BaseStream.Position += 8;
                    offset += unpacked.files[i].size;
                    if (offset % 0x10 != 0)
                        offset += 0x10 - (offset % 0x10);
                }
                else if (type == 2)
                    bwPkh.Write(br.ReadUInt64());
                else if (type == 3)
                    bwPkh.Write(br.ReadUInt32());
            }

            while (bwPkh.BaseStream.Position % 0x10 != 0)
                bwPkh.Write((byte)0xFF);

            bwPkh.Flush();

            bwPkb.Close();
            bwPkh.Close();

            br.Close();

            pluginHost.ChangeFile(pkh.id, pkh_out);
        }
开发者ID:MetLob,项目名称:tinke,代码行数:73,代码来源:Packs.cs


注:本文中的IPluginHost.ChangeFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。