Exemple #1
0
        public static byte[] GetDataBySha1(byte[] sha1, int maxsize = 0x7FFFFFFF)
        {
            CATFile cat = null;

            if (cat_base == null)
            {
                string path = GlobalStuff.FindSetting("gamepath") + "Data\\cas.cat";
                cat_base = new CATFile(path);
            }
            List <uint> casline = cat_base.FindBySHA1(sha1);

            if (casline.Count == 9)
            {
                cat = cat_base;
            }
            else
            {
                if (cat_patch == null)
                {
                    string path = GlobalStuff.FindSetting("gamepath") + "Update\\Patch\\Data\\cas.cat";
                    cat_patch = new CATFile(path);
                }
                cat     = cat_patch;
                casline = cat_patch.FindBySHA1(sha1);
            }
            if (casline.Count == 9)
            {
                if (cas == null || cas.casnumber != casline[7])
                {
                    string[] files = Directory.GetFiles(Path.GetDirectoryName(cat.MyPath));
                    foreach (string file in files)
                    {
                        if (Path.GetFileName(file) == CASFile.GetCASFileName(casline[7]))
                        {
                            cas = new CASFile(file);
                            break;
                        }
                    }
                }
                if (cas != null && cas.casnumber == casline[7])
                {
                    CASFile.CASEntry ce = cas.ReadEntry(casline.ToArray(), maxsize);
                    return(ce.data);
                }
            }
            return(new byte[0]);
        }
Exemple #2
0
        private static void ScanFiles()
        {
            Debug.LogLn("Saving file paths into db...");
            SQLiteConnection con = GetConnection();

            con.Open();
            var transaction = con.BeginTransaction();

            string[] files = Directory.GetFiles(GlobalStuff.FindSetting("gamepath"), "*.sb", SearchOption.AllDirectories);
            Debug.LogLn("SB files...");
            foreach (string file in files)
            {
                if (!file.ToLower().Contains("\\update\\"))
                {
                    AddSBFile(file, TYPE_BASEGAME, con);
                }
                else if (!file.ToLower().Contains("\\update\\patch\\"))
                {
                    AddSBFile(file, TYPE_UPDATE, con);
                }
                else
                {
                    AddSBFile(file, TYPE_PATCH, con);
                }
            }
            transaction.Commit();
            transaction = con.BeginTransaction();
            Debug.LogLn("TOC files...");
            files = Directory.GetFiles(GlobalStuff.FindSetting("gamepath"), "*.toc", SearchOption.AllDirectories);
            foreach (string file in files)
            {
                if (!file.ToLower().Contains("\\update\\"))
                {
                    AddTOCFile(file, TYPE_BASEGAME, con);
                }
                else if (!file.ToLower().Contains("\\update\\patch\\"))
                {
                    AddTOCFile(file, TYPE_UPDATE, con);
                }
                else
                {
                    AddTOCFile(file, TYPE_PATCH, con);
                }
            }
            transaction.Commit();
            con.Close();
        }
Exemple #3
0
        public static string[] GetFiles(string type, bool withBase, bool withDLC, bool withPatch)
        {
            string[]      list     = DBAccess.GetGameFiles(type);
            string        basepath = GlobalStuff.FindSetting("gamepath");
            List <string> tmp      = new List <string>(list);

            for (int i = 0; i < tmp.Count; i++)
            {
                if (!withBase)
                {
                    if (!tmp[i].Contains("Update"))
                    {
                        tmp.RemoveAt(i--);
                        continue;
                    }
                }
                if (!withDLC)
                {
                    if (tmp[i].Contains("Update") && !tmp[i].Contains("Patch"))
                    {
                        tmp.RemoveAt(i--);
                        continue;
                    }
                }
                if (!withPatch)
                {
                    if (tmp[i].Contains("Update") && tmp[i].Contains("Patch"))
                    {
                        tmp.RemoveAt(i--);
                        continue;
                    }
                }
            }
            list = tmp.ToArray();
            for (int i = 0; i < list.Length; i++)
            {
                list[i] = list[i].Substring(basepath.Length, list[i].Length - basepath.Length);
            }
            return(list);
        }
Exemple #4
0
        public static void StartScan(string path)
        {
            Debug.LogLn("Starting Scan...");
            Stopwatch sp = new Stopwatch();

            sp.Start();
            try
            {
                GlobalStuff.AssignSetting("isNew", "0");
                GlobalStuff.settings.Add("gamepath", path);
                SaveSettings();
                ScanFiles();
                ScanTOCsForBundles();
            }
            catch (Exception ex)
            {
                sp.Stop();
                Debug.LogLn("\n\n====ERROR======\nTime : " + sp.Elapsed.ToString() + "\n" + ex.Message);
            }
            sp.Stop();
            Debug.LogLn("\n\n===============\nTime : " + sp.Elapsed.ToString() + "\n");
        }
Exemple #5
0
 public static bool CheckIfScanIsNeeded()
 {
     return(GlobalStuff.FindSetting("isNew") == "1");
 }