コード例 #1
0
ファイル: VirtualFile.cs プロジェクト: FrannyRed/wabbajack
        private static bool TryGetFromCache(Context context, VirtualFile parent, IPath path, IStreamFactory extractedFile, Hash hash, out VirtualFile found)
        {
            var result = _vfsCache.Get(hash.ToArray());

            if (result == null)
            {
                found = null;
                return(false);
            }

            var data = IndexedVirtualFile.Read(new MemoryStream(result));

            found      = ConvertFromIndexedFile(context, data, path, parent, extractedFile);
            found.Name = path;
            found.Hash = hash;
            return(true);
        }
コード例 #2
0
        private static bool TryGetFromCache(Context context, VirtualFile parent, IPath path, IStreamFactory extractedFile, Hash hash, out VirtualFile found)
        {
            using var cmd   = new SQLiteCommand(_conn);
            cmd.CommandText = @"SELECT Contents FROM VFSCache WHERE Hash = @hash";
            cmd.Parameters.AddWithValue("@hash", (long)hash);

            using var rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                var data = IndexedVirtualFile.Read(rdr.GetStream(0));
                found      = ConvertFromIndexedFile(context, data, path, parent, extractedFile);
                found.Name = path;
                found.Hash = hash;
                return(true);
            }

            found = default;
            return(false);
        }