Exemplo n.º 1
0
        public DbCachedDataId Open(DbRecordId dbRecordId)
        {
            if (!_indices.TryGetResourcePath(dbRecordId, out var resourcePath))
            {
                throw new FileNotFoundException($"Cannot load unknown resource: {dbRecordId}");
            }

            DbCachedDataId dbRecordIndex;

            Byte[] fileContent = NativeFormatProvider.ReadAllBytes(resourcePath);
            lock (_byId)
            {
                dbRecordIndex = new DbCachedDataId(_currentIndex++);
                DbCachedData data = new DbCachedData(dbRecordId, resourcePath, fileContent);
                _byId[dbRecordIndex] = data;
            }

            Log.Message($"Loaded resource {dbRecordIndex}: [0x{dbRecordId}, {resourcePath}].");
            return(dbRecordIndex);
        }
Exemplo n.º 2
0
        public unsafe Int32 Read(DbCachedDataId dbRecordIndex, Byte *output, Int32 outputSize)
        {
            DbCachedData data = GetCachedData(dbRecordIndex);

            return(data.Read(output, outputSize));
        }
Exemplo n.º 3
0
        public void Seek(DbCachedDataId dbRecordIndex, Int32 offset)
        {
            DbCachedData data = GetCachedData(dbRecordIndex);

            data.Seek(offset);
        }
Exemplo n.º 4
0
        public Int32 GetDecompressedSize(DbCachedDataId dbRecordIndex)
        {
            DbCachedData data = GetCachedData(dbRecordIndex);

            return(data.Size);
        }