Пример #1
0
    public bool DeleteFileInfo(PathHashInfo hash_info)
    {
        string del_sql = string.Format("delete from file_info where hash0 = '{0}' and hash1 = '{1}' and hash2 = '{2}'", hash_info.hash0, hash_info.hash1, hash_info.hash2);
        int    result  = this.m_sqlite_db.ExcuteQueryNoResult(del_sql);

        return(result == 0);
    }
Пример #2
0
    public bool QueryFileVersionByHashInfo(string file_path, out int file_version)
    {
        PathHashInfo hash_info = DataEncrypt.GetPathHashInfo(file_path);
        bool         is_suc    = false;

        file_version = 0;
        bool flag = this.m_sqlite_db != null;

        if (flag)
        {
            string      sql = string.Format("select version from file_info where hash0 = '{0}' and hash1 = '{1}' and hash2 = '{2}'", hash_info.hash0, hash_info.hash1, hash_info.hash2);
            SQLiteQuery qr  = new SQLiteQuery(this.m_sqlite_db, sql);
            if (qr.Step())
            {
                file_version = qr.GetInteger("version");
                is_suc       = true;
            }
        }
        return(is_suc);
    }
Пример #3
0
    private static void ExportCyMzq(string file_name)
    {
        string _name = Path.GetFileNameWithoutExtension(file_name);
        string _dir  = Path.GetDirectoryName(file_name);
        string _file = string.Format("{0}/{1}.txt", _dir, _name);

        if (File.Exists(_file))
        {
            return;
        }
        StringBuilder log_sb = new StringBuilder();

        FileStream   fs         = new FileStream(file_name, FileMode.Open);
        int          nLength    = (int)fs.Length;
        BinaryReader tmp_reader = new BinaryReader(fs);
        int          unzip      = tmp_reader.ReadInt32();

        log_sb.Append("unzip = " + unzip + "\n");
        if (unzip != 0)
        {
            int md5_data_size     = 4;
            int version_data_size = 4;
            int len_data_size     = 4;

            byte[] buffs       = tmp_reader.ReadBytes(nLength - 4);
            int    len         = 0;
            byte[] DecompBuffs = Sqlite3tool.DecompNetBuffer(buffs, nLength, unzip, out len);
            if (unzip != len)
            {
                LogMgr.LogError("error: unzip != len");
            }
            MemoryStream decomp_ms     = new MemoryStream(DecompBuffs);
            BinaryReader decomp_reader = new BinaryReader(decomp_ms);

            int    file_path_count = decomp_reader.ReadInt32();
            int    file_count      = decomp_reader.ReadInt32();
            byte[] file_path_byte  = decomp_reader.ReadBytes(file_path_count);
            byte[] md5_code_byte   = decomp_reader.ReadBytes(file_count * md5_data_size);
            byte[] version_byte    = decomp_reader.ReadBytes(file_count * version_data_size);
            byte[] len_byte        = decomp_reader.ReadBytes(file_count * len_data_size);

            MemoryStream md5_code_mem = new MemoryStream(md5_code_byte);
            BinaryReader md5_code_all = new BinaryReader(md5_code_mem);
            MemoryStream version_mem  = new MemoryStream(version_byte);
            BinaryReader version_all  = new BinaryReader(version_mem);
            MemoryStream len_mem      = new MemoryStream(len_byte);
            BinaryReader len_all      = new BinaryReader(len_mem);

            int file_path_begin_pos = 0;
            for (int index = 0; index < file_count; index++)
            {
                string        file_path = "";
                byte[]        md5       = md5_code_all.ReadBytes(4);
                StringBuilder sb        = new StringBuilder();
                for (int i = 0; i < md5.Length; i++)
                {
                    sb.Append(md5[i].ToString("X2"));
                }

                int version = version_all.ReadInt32();
                int length  = len_all.ReadInt32();
                int end_pos = 0;
                Sqlite3tool.ParseFilePath(ref file_path_byte, file_path_begin_pos, file_path_count, out end_pos, out file_path);
                file_path_begin_pos = end_pos;

                PathHashInfo _hash = DataEncrypt.GetPathHashInfo(file_path);
                log_sb.Append("hash0: ");
                log_sb.Append(_hash.hash0);
                log_sb.Append(", ");
                log_sb.Append("hash1: ");
                log_sb.Append(_hash.hash1);
                log_sb.Append(", ");
                log_sb.Append("hash2: ");
                log_sb.Append(_hash.hash1);
                log_sb.Append(", ");
                log_sb.Append("version: ");
                log_sb.Append(version);
                log_sb.Append(", ");
                log_sb.Append("file_name: ");
                log_sb.Append(Util.GetAssetsBundlePathFromBase64(file_path));
                log_sb.Append(", ");
                log_sb.Append("file_mds: ");
                log_sb.Append(sb.ToString());
                log_sb.Append(", ");
                log_sb.Append("data_len: ");
                log_sb.Append(length);
                log_sb.Append(", ");
                log_sb.Append("unzip_len: ");
                log_sb.Append(length);
                log_sb.Append("\n");
            }
            fs.Close();
            fs.Dispose();
        }

        System.IO.File.WriteAllText(_file, log_sb.ToString());
        log_sb.Clear();
    }
Пример #4
0
    public override bool Equals(object obj)
    {
        PathHashInfo v = obj as PathHashInfo;

        return(v.hash0 == this.hash0 && v.hash1 == this.hash1 && v.hash2 == this.hash2);
    }