当前位置: 首页>>代码示例>>C#>>正文


C# SparseStream类代码示例

本文整理汇总了C#中SparseStream的典型用法代码示例。如果您正苦于以下问题:C# SparseStream类的具体用法?C# SparseStream怎么用?C# SparseStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SparseStream类属于命名空间,在下文中一共展示了SparseStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HostedSparseExtentStream

        public HostedSparseExtentStream(Stream file, Ownership ownsFile, long diskOffset, SparseStream parentDiskStream, Ownership ownsParentDiskStream)
        {
            _fileStream = file;
            _ownsFileStream = ownsFile;
            _diskOffset = diskOffset;
            _parentDiskStream = parentDiskStream;
            _ownsParentDiskStream = ownsParentDiskStream;

            file.Position = 0;
            byte[] headerSector = Utilities.ReadFully(file, Sizes.Sector);
            _hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0);
            if (_hostedHeader.GdOffset == -1)
            {
                // Fall back to secondary copy that (should) be at the end of the stream, just before the end-of-stream sector marker
                file.Position = file.Length - Sizes.OneKiB;
                headerSector = Utilities.ReadFully(file, Sizes.Sector);
                _hostedHeader = HostedSparseExtentHeader.Read(headerSector, 0);

                if (_hostedHeader.MagicNumber != HostedSparseExtentHeader.VmdkMagicNumber)
                {
                    throw new IOException("Unable to locate valid VMDK header or footer");
                }
            }

            _header = _hostedHeader;

            if (_hostedHeader.CompressAlgorithm != 0 && _hostedHeader.CompressAlgorithm != 1)
            {
                throw new NotSupportedException("Only uncompressed and DEFLATE compressed disks supported");
            }

            _gtCoverage = _header.NumGTEsPerGT * _header.GrainSize * Sizes.Sector;

            LoadGlobalDirectory();
        }
开发者ID:AnotherAltr,项目名称:Rc.Core,代码行数:35,代码来源:HostedSparseExtentStream.cs

示例2: ContentStream

 public ContentStream(SparseStream fileStream, BlockAllocationTable bat, long length, SparseStream parentStream, Ownership ownsParent)
 {
     _fileStream = fileStream;
     _bat = bat;
     _length = length;
     _parentStream = parentStream;
     _ownsParent = ownsParent;
 }
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:8,代码来源:ContentStream.cs

示例3: OpenContent

        public override SparseStream OpenContent(SparseStream parent, Ownership ownsParent)
        {
            if (ownsParent == Ownership.Dispose && parent != null)
            {
                parent.Dispose();
            }

            return SparseStream.FromStream(Content, Ownership.None);
        }
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:9,代码来源:DiscImageFile.cs

示例4: Chunk

        public Chunk(Stream bat, SparseStream file, FreeSpaceTable freeSpace, FileParameters fileParameters, int chunk, int blocksPerChunk)
        {
            _bat = bat;
            _file = file;
            _freeSpace = freeSpace;
            _fileParameters = fileParameters;
            _chunk = chunk;
            _blocksPerChunk = blocksPerChunk;

            _bat.Position = _chunk * (_blocksPerChunk + 1) * 8;
            _batData = Utilities.ReadFully(bat, (_blocksPerChunk + 1) * 8);
        }
开发者ID:easymetadata,项目名称:DiscUtils,代码行数:12,代码来源:Chunk.cs

示例5: ContentStream

        public ContentStream(SparseStream fileStream, Stream batStream, FreeSpaceTable freeSpaceTable, Metadata metadata, long length, SparseStream parentStream, Ownership ownsParent)
        {
            _fileStream = fileStream;
            _batStream = batStream;
            _freeSpaceTable = freeSpaceTable;
            _metadata = metadata;
            _fileParameters = _metadata.FileParameters;
            _length = length;
            _parentStream = parentStream;
            _ownsParent = ownsParent;

            _chunks = new ObjectCache<int, Chunk>();
        }
开发者ID:JGTM2016,项目名称:discutils,代码行数:13,代码来源:ContentStream.cs

示例6: DiskImageFile

        /// <summary>
        /// Initializes a new instance of the DiskImageFile class.
        /// </summary>
        /// <param name="stream">The stream to interpret</param>
        /// <param name="ownsStream">Indicates if the new instance should control the lifetime of the stream.</param>
        /// <param name="geometry">The emulated geometry of the disk.</param>
        public DiskImageFile(Stream stream, Ownership ownsStream, Geometry geometry)
        {
            _content = stream as SparseStream;
            _ownsContent = ownsStream;

            if (_content == null)
            {
                _content = SparseStream.FromStream(stream, ownsStream);
                _ownsContent = Ownership.Dispose;
            }

            _geometry = geometry ?? DetectGeometry(_content);
        }
开发者ID:JGTM2016,项目名称:discutils,代码行数:19,代码来源:DiskImageFile.cs

示例7: ServerSparseExtentStream

        public ServerSparseExtentStream(Stream file, Ownership ownsFile, long diskOffset, SparseStream parentDiskStream, Ownership ownsParentDiskStream)
        {
            _fileStream = file;
            _ownsFileStream = ownsFile;
            _diskOffset = diskOffset;
            _parentDiskStream = parentDiskStream;
            _ownsParentDiskStream = ownsParentDiskStream;

            file.Position = 0;
            byte[] firstSectors = Utilities.ReadFully(file, Sizes.Sector * 4);
            _serverHeader = ServerSparseExtentHeader.Read(firstSectors, 0);
            _header = _serverHeader;

            _gtCoverage = _header.NumGTEsPerGT * (long)_header.GrainSize * Sizes.Sector;

            LoadGlobalDirectory();
        }
开发者ID:JGTM2016,项目名称:discutils,代码行数:17,代码来源:ServerSparseExtentStream.cs

示例8: DynamicStream

        public DynamicStream(Stream fileStream, DynamicHeader dynamicHeader, long length, SparseStream parentStream, Ownership ownsParentStream)
        {
            if (fileStream == null)
            {
                throw new ArgumentNullException("fileStream");
            }

            if (dynamicHeader == null)
            {
                throw new ArgumentNullException("dynamicHeader");
            }

            if (parentStream == null)
            {
                throw new ArgumentNullException("parentStream");
            }

            if (length < 0)
            {
                throw new ArgumentOutOfRangeException("length", length, "Negative lengths not allowed");
            }

            _fileStream = fileStream;
            _dynamicHeader = dynamicHeader;
            _length = length;
            _parentStream = parentStream;
            _ownsParentStream = ownsParentStream;

            _blockBitmaps = new byte[_dynamicHeader.MaxTableEntries][];
            _blockBitmapSize = (int)Utilities.RoundUp(Utilities.Ceil(_dynamicHeader.BlockSize, Utilities.SectorSize * 8), Utilities.SectorSize);

            ReadBlockAllocationTable();

            // Detect where next block should go (cope if the footer is missing)
            _fileStream.Position = Utilities.RoundDown(_fileStream.Length, Utilities.SectorSize) - Utilities.SectorSize;
            byte[] footerBytes = Utilities.ReadFully(_fileStream, Utilities.SectorSize);
            Footer footer = Footer.FromBytes(footerBytes, 0);
            _nextBlockStart = _fileStream.Position - (footer.IsValid() ? Utilities.SectorSize : 0);
        }
开发者ID:easymetadata,项目名称:DiscUtils,代码行数:39,代码来源:DynamicStream.cs

示例9: DynamicDiskBuilder

 public DynamicDiskBuilder(SparseStream content, Footer footer, uint blockSize)
 {
     _content = content;
     _footer = footer;
     _blockSize = blockSize;
 }
开发者ID:easymetadata,项目名称:DiscUtils,代码行数:6,代码来源:DynamicDiskBuilder.cs

示例10: DataBlockExtent

 public DataBlockExtent(long start, SparseStream content, Ownership ownership)
     : base(start, Utilities.RoundUp(Utilities.Ceil(content.Length, Sizes.Sector) / 8, Sizes.Sector) + Utilities.RoundUp(content.Length, Sizes.Sector))
 {
     _content = content;
     _ownership = ownership;
 }
开发者ID:easymetadata,项目名称:DiscUtils,代码行数:6,代码来源:DynamicDiskBuilder.cs

示例11: OpenExtent

        private SparseStream OpenExtent(ExtentDescriptor extent, long extentStart, SparseStream parent, Ownership ownsParent)
        {
            FileAccess access = FileAccess.Read;
            FileShare share = FileShare.Read;
            if(extent.Access == ExtentAccess.ReadWrite && _access != FileAccess.Read)
            {
                access = FileAccess.ReadWrite;
                share = FileShare.None;
            }

            if (extent.Type != ExtentType.Sparse && extent.Type != ExtentType.VmfsSparse)
            {
                if (ownsParent == Ownership.Dispose && parent != null)
                {
                    parent.Dispose();
                }
            }

            switch (extent.Type)
            {
                case ExtentType.Flat:
                case ExtentType.Vmfs:
                    return SparseStream.FromStream(
                        _fileLocator.Open(extent.FileName, FileMode.Open, access, share),
                        Ownership.Dispose);

                case ExtentType.Zero:
                    return new ZeroStream(extent.SizeInSectors * Utilities.SectorSize);

                case ExtentType.Sparse:
                    return new HostedSparseExtentStream(
                        _fileLocator.Open(extent.FileName, FileMode.Open, access, share),
                        Ownership.Dispose,
                        extentStart,
                        parent,
                        ownsParent);

                case ExtentType.VmfsSparse:
                    return new ServerSparseExtentStream(
                        _fileLocator.Open(extent.FileName, FileMode.Open, access, share),
                        Ownership.Dispose,
                        extentStart,
                        parent,
                        ownsParent);

                default:
                    throw new NotSupportedException();
            }
        }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:49,代码来源:DiskImageFile.cs

示例12: VmfsSparseExtentBuilder

 public VmfsSparseExtentBuilder(SparseStream content)
 {
     _content = content;
 }
开发者ID:easymetadata,项目名称:discutils_Ewf-POC,代码行数:4,代码来源:VmfsSparseExtentBuilder.cs

示例13: NtfsFileStream

        public NtfsFileStream(NtfsFileSystem fileSystem, DirectoryEntry entry, AttributeType attrType, string attrName, FileAccess access)
        {
            _entry = entry;

            _file = fileSystem.GetFile(entry.Reference);
            _baseStream = _file.OpenStream(attrType, attrName, access);
        }
开发者ID:marinehero,项目名称:ThinkAway.net,代码行数:7,代码来源:NtfsFileStream.cs

示例14: DiskImageFile

 /// <summary>
 /// Represents a single EWF file.
 /// </summary>
 /// <param name="path">Path to the ewf file.</param>
 /// <param name="access">Desired access.</param>
 public DiskImageFile(string path, FileAccess access)
 {
     if (_content == null)
     {
         _content = new EWFStream(path);
     }
 }
开发者ID:easymetadata,项目名称:discutils_Ewf-POC,代码行数:12,代码来源:DiskImageFile.cs

示例15: Dispose

 /// <summary>
 /// Disposes of this instance, freeing underlying resources.
 /// </summary>
 /// <param name="disposing"><c>true</c> if running inside Dispose(), indicating
 /// graceful cleanup of all managed objects should be performed, or <c>false</c>
 /// if running inside destructor.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_content != null)
         {
             _content.Dispose();
             _content = null;
         }
     }
     base.Dispose(disposing);
 }
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:18,代码来源:Disk.cs


注:本文中的SparseStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。