DisableChecksum() public method

Disables the resource's checksum by changing its location flags.
public DisableChecksum ( ) : void
return void
Beispiel #1
0
        /// <summary>
        /// Adds a new resource to a cache.
        /// </summary>
        /// <param name="resource">The resource reference to initialize.</param>
        /// <param name="location">The location where the resource should be stored.</param>
        /// <param name="dataStream">The stream to read the resource data from.</param>
        /// <exception cref="System.ArgumentNullException">resource</exception>
        /// <exception cref="System.ArgumentException">The input stream is not open for reading;dataStream</exception>
        public void Add(ResourceReference resource, ResourceLocation location, Stream dataStream)
        {
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }
            if (!dataStream.CanRead)
            {
                throw new ArgumentException("The input stream is not open for reading", "dataStream");
            }

            resource.ChangeLocation(location);
            var cache = GetCache(resource);

            using (var stream = cache.File.Open(FileMode.Open, FileAccess.ReadWrite))
            {
                var dataSize = (int)(dataStream.Length - dataStream.Position);
                var data     = new byte[dataSize];
                dataStream.Read(data, 0, dataSize);
                uint compressedSize;
                resource.Index            = cache.Cache.Add(stream, data, out compressedSize);
                resource.CompressedSize   = compressedSize;
                resource.DecompressedSize = (uint)dataSize;
                resource.DisableChecksum();
            }
        }
        /// <summary>
        /// Adds raw, pre-compressed resource data to a cache.
        /// </summary>
        /// <param name="resource">The resource reference to initialize.</param>
        /// <param name="location">The location where the resource should be stored.</param>
        /// <param name="data">The pre-compressed data to store.</param>
        public void AddRaw(ResourceReference resource, ResourceLocation location, byte[] data)
        {
            if (resource == null)
                throw new ArgumentNullException("resource");

            resource.ChangeLocation(location);
            resource.DisableChecksum();
            var cache = GetCache(resource);
            using (var stream = cache.File.Open(FileMode.Open, FileAccess.ReadWrite))
                resource.Index = cache.Cache.AddRaw(stream, data);
        }
Beispiel #3
0
        /// <summary>
        /// Replaces a resource with raw, pre-compressed data.
        /// </summary>
        /// <param name="resource">The resource whose data should be replaced. On success, the reference will be adjusted to account for the new data.</param>
        /// <param name="data">The raw, pre-compressed data to use.</param>
        public void ReplaceRaw(ResourceReference resource, byte[] data)
        {
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }

            resource.DisableChecksum();
            var cache = GetCache(resource);

            using (var stream = cache.File.Open(FileMode.Open, FileAccess.ReadWrite))
                cache.Cache.ImportRaw(stream, resource.Index, data);
        }
Beispiel #4
0
        /// <summary>
        /// Adds raw, pre-compressed resource data to a cache.
        /// </summary>
        /// <param name="resource">The resource reference to initialize.</param>
        /// <param name="location">The location where the resource should be stored.</param>
        /// <param name="data">The pre-compressed data to store.</param>
        public void AddRaw(ResourceReference resource, ResourceLocation location, byte[] data)
        {
            if (resource == null)
            {
                throw new ArgumentNullException("resource");
            }

            resource.ChangeLocation(location);
            resource.DisableChecksum();
            var cache = GetCache(resource);

            using (var stream = cache.File.Open(FileMode.Open, FileAccess.ReadWrite))
                resource.Index = cache.Cache.AddRaw(stream, data);
        }
        /// <summary>
        /// Adds a new resource to a cache.
        /// </summary>
        /// <param name="resource">The resource reference to initialize.</param>
        /// <param name="location">The location where the resource should be stored.</param>
        /// <param name="dataStream">The stream to read the resource data from.</param>
        /// <exception cref="System.ArgumentNullException">resource</exception>
        /// <exception cref="System.ArgumentException">The input stream is not open for reading;dataStream</exception>
        public void Add(ResourceReference resource, ResourceLocation location, Stream dataStream)
        {
            if (resource == null)
                throw new ArgumentNullException("resource");
            if (!dataStream.CanRead)
                throw new ArgumentException("The input stream is not open for reading", "dataStream");

            resource.ChangeLocation(location);
            var cache = GetCache(resource);
            using (var stream = cache.File.Open(FileMode.Open, FileAccess.ReadWrite))
            {
                var dataSize = (int)(dataStream.Length - dataStream.Position);
                var data = new byte[dataSize];
                dataStream.Read(data, 0, dataSize);
                uint compressedSize;
                resource.Index = cache.Cache.Add(stream, data, out compressedSize);
                resource.CompressedSize = compressedSize;
                resource.DecompressedSize = (uint)dataSize;
                resource.DisableChecksum();
            }
        }
        /// <summary>
        /// Replaces a resource with raw, pre-compressed data.
        /// </summary>
        /// <param name="resource">The resource whose data should be replaced. On success, the reference will be adjusted to account for the new data.</param>
        /// <param name="data">The raw, pre-compressed data to use.</param>
        public void ReplaceRaw(ResourceReference resource, byte[] data)
        {
            if (resource == null)
                throw new ArgumentNullException("resource");

            resource.DisableChecksum();
            var cache = GetCache(resource);
            using (var stream = cache.File.Open(FileMode.Open, FileAccess.ReadWrite))
                cache.Cache.ImportRaw(stream, resource.Index, data);
        }