示例#1
0
        public static TOCInformation GetTocInformationByIndex(int index)
        {
            TOCInformation   res = new TOCInformation();
            SQLiteConnection con = GetConnection();

            con.Open();
            SQLiteDataReader reader = getAllWhere("tocfiles", "id = " + index, con);

            if (reader.Read())
            {
                res.index = index;
                res.path  = reader.GetString(1);
                res.md5   = reader.GetString(2);
                res.incas = reader.GetString(3) == "True";
                res.type  = reader.GetString(4);
            }
            con.Close();
            return(res);
        }
示例#2
0
 public static TOCInformation GetTocInformationByIndex(int index)
 {
     TOCInformation res = new TOCInformation();
     SQLiteConnection con = GetConnection();
     con.Open();
     SQLiteDataReader reader = getAllWhere("tocfiles", "id = " + index, con);
     if (reader.Read())
     {
         res.index = index;
         res.path = reader.GetString(1);
         res.md5 = reader.GetString(2);
         res.incas = reader.GetString(3) == "True";
         res.type = reader.GetString(4);
     }
     con.Close();
     return res;
 }
示例#3
0
        public static void AddBundle(int tocid, bool incas, Bundle b, TOCFile.TOCBundleInfoStruct info, SQLiteConnection con)
        {
            Debug.LogLn(" EBX:" + b.ebx.Count + " RES:" + b.res.Count + " CHUNK:" + b.chunk.Count, true);
            SQLCommand("INSERT INTO bundles (tocfile, frostid, offset, size, base, delta) VALUES (" + tocid + ",'" + info.id + "'," + info.offset + ", " + info.size + ", '" + info.isbase + "', '" + info.isdelta + "' )", con);
            int            bundleid    = (int)GetLastRowId(con);
            TOCInformation toci        = GetTocInformationByIndex(tocid);
            var            transaction = con.BeginTransaction();
            int            counter     = 0;

            if (b.ebx != null)
            {
                foreach (Bundle.ebxtype ebx in b.ebx)
                {
                    try
                    {
                        if (ebx.name != null && ebx.originalSize != null && ebx.size != null)
                        {
                            EBXInformation inf = new EBXInformation();
                            inf.basesha1     = Helpers.ByteArrayToHexString(ebx.baseSha1);
                            inf.bundlepath   = b.path;
                            inf.casPatchType = ebx.casPatchType;
                            inf.deltasha1    = Helpers.ByteArrayToHexString(ebx.deltaSha1);
                            inf.ebxname      = ebx.name;
                            inf.incas        = incas;
                            inf.isbase       = info.isbase;
                            inf.isdelta      = info.isdelta;
                            if (toci.type == TYPE_BASEGAME)
                            {
                                inf.isbasegamefile = true;
                            }
                            if (toci.type == TYPE_UPDATE)
                            {
                                inf.isDLC = true;
                            }
                            if (toci.type == TYPE_PATCH)
                            {
                                inf.isPatch = true;
                            }
                            inf.offset      = info.offset;
                            inf.sha1        = Helpers.ByteArrayToHexString(ebx.Sha1);
                            inf.size        = info.size;
                            inf.tocfilepath = toci.path;
                            byte[] data = new byte[0];
                            if (inf.incas)
                            {
                                data = SHA1Access.GetDataBySha1(ebx.Sha1, 0x38);
                            }
                            else
                            {
                                BinaryBundle bb = null;
                                foreach (AddEBXHelpStruct h in aehelp)
                                {
                                    if (h.tocpath == inf.tocfilepath && h.bpath == inf.bundlepath)
                                    {
                                        bb = h.b;
                                        break;
                                    }
                                }
                                if (bb == null)
                                {
                                    TOCFile toc        = new TOCFile(inf.tocfilepath);
                                    byte[]  bundledata = toc.ExportBundleDataByPath(inf.bundlepath);
                                    bb = new BinaryBundle(new MemoryStream(bundledata));
                                    AddEBXHelpStruct h = new AddEBXHelpStruct();
                                    h.tocpath = inf.tocfilepath;
                                    h.bpath   = inf.bundlepath;
                                    h.b       = bb;
                                    if (aehelp.Count > 10)
                                    {
                                        aehelp.RemoveAt(0);
                                    }
                                }
                                foreach (BinaryBundle.EbxEntry ebx2 in bb.EbxList)
                                {
                                    if (inf.ebxname == ebx2._name)
                                    {
                                        data = ebx2._data;
                                    }
                                }
                            }
                            inf.guid = Helpers.ByteArrayToHexString(data, 0x28, 0x10);
                            AddEBXLUTFile(inf, con);
                            if ((counter++) % 100 == 0)
                            {
                                transaction.Commit();
                                transaction = con.BeginTransaction();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            transaction.Commit();
            transaction = con.BeginTransaction();
            if (b.res != null)
            {
                foreach (Bundle.restype res in b.res)
                {
                    try
                    {
                        if (res.name != null)
                        {
                            AddRESFile(res.name, res.SHA1, res.rtype, bundleid, con);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            transaction.Commit();
            transaction = con.BeginTransaction();
            if (b.chunk != null)
            {
                foreach (Bundle.chunktype chunk in b.chunk)
                {
                    try
                    {
                        AddChunk(chunk.id, chunk.SHA1, bundleid, con);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            transaction.Commit();
        }