Ejemplo n.º 1
0
        /*
         * Query if given packed file can be decoded.
         * Is not entirely reliable because it only reads the header and checks if a
         * type definition is available for the given GUID and/or type name and version.
         * The actual decode tries out all available type infos for that type name
         * but that is less efficient because it has to read the whole file at least once
         * if successful.
         */
        public static bool CanDecode(PackedFile packedFile, out string display)
        {
            bool   result = true;
            string key    = DBFile.Typename(packedFile.FullPath);

            if (DBTypeMap.IsSupported(key))
            {
                try
                {
                    DBFileHeader header     = PackedFileDbCodec.readHeader(packedFile);
                    int          maxVersion = DBTypeMap.MaxVersion(key);
                    if (maxVersion != 0 && header.Version > maxVersion)
                    {
                        display = string.Format("{0}: needs {1}, has {2}", key, header.Version, DBTypeMap.MaxVersion(key));
                        result  = false;
                    }
                    else
                    {
                        display = string.Format("Version: {0}", header.Version);
                    }
                }
                catch (Exception x)
                {
                    display = string.Format("{0}: {1}", key, x.Message);
                }
            }
            else
            {
                display = string.Format("{0}: no definition available", key);
                result  = false;
            }
            return(result);
        }
Ejemplo n.º 2
0
        private static DataTable GetDataTable(String tableKey)
        {
            PackedFile currentPackedFile     = currentPackFile.Files[0];
            PackedFile replacementPackedFile = currentPackedFile;

            DBFile test = PackedFileDbCodec.Decode(currentPackedFile);

            test.Entries[0][0].Value = "dicks and or butts";

            Encode(new MemoryStream(replacementPackedFile.Data), test);

            //currentPackFile.Files[0] = currentPackedFile;

            //currentPackFile.Files[0] = null;

            currentPackFile.Files.Remove(currentPackedFile);
            currentPackFile.Files.Add(replacementPackedFile);

            return(new DataTable());
        }
Ejemplo n.º 3
0
        /*
         * Create DBFile from the given PackedFile.
         */
        public static DBFile Decode(PackedFile file)
        {
            PackedFileDbCodec codec = FromFilename(file.FullPath);

            return(codec.Decode(file.Data));
        }