public CompressedClusterStream(INtfsContext context, NtfsAttribute attr, RawClusterStream rawStream)
        {
            _context = context;
            _attr = attr;
            _rawStream = rawStream;
            _bytesPerCluster = _context.BiosParameterBlock.BytesPerCluster;

            _cacheBuffer = new byte[_attr.CompressionUnitSize * context.BiosParameterBlock.BytesPerCluster];
            _ioBuffer = new byte[_attr.CompressionUnitSize * context.BiosParameterBlock.BytesPerCluster];
        }
        public NonResidentAttributeBuffer(File file, NtfsAttribute attribute)
            : base(file.Context, CookRuns(attribute), file.IndexInMft == MasterFileTable.MftIndex)
        {
            _file = file;
            _attribute = attribute;

            switch (attribute.Flags & (AttributeFlags.Compressed | AttributeFlags.Sparse))
            {
                case AttributeFlags.Sparse:
                    _activeStream = new SparseClusterStream(_attribute, _rawStream);
                    break;

                case AttributeFlags.Compressed:
                    _activeStream = new CompressedClusterStream(_context, _attribute, _rawStream);
                    break;

                case AttributeFlags.None:
                    _activeStream = _rawStream;
                    break;

                default:
                    throw new NotImplementedException("Unhandled attribute type '" + attribute.Flags + "'");
            }
        }
Esempio n. 3
0
 public SparseClusterStream(NtfsAttribute attr, RawClusterStream rawStream)
 {
     _attr = attr;
     _rawStream = rawStream;
 }
        private static CookedDataRuns CookRuns(NtfsAttribute attribute)
        {
            CookedDataRuns result = new CookedDataRuns();

            foreach (NonResidentAttributeRecord record in attribute.Records)
            {
                if (record.StartVcn != result.NextVirtualCluster)
                {
                    throw new IOException("Invalid NTFS attribute - non-contiguous data runs");
                }

                result.Append(record.DataRuns, record);
            }

            return result;
        }
Esempio n. 5
0
        internal void RemoveAttributeExtents(NtfsAttribute attr)
        {
            attr.GetDataBuffer().SetCapacity(0);

            foreach (var extentRef in attr.Extents.Keys)
            {
                RemoveAttributeExtent(extentRef);
            }
        }
Esempio n. 6
0
 public FileStream(File file, NtfsAttribute attr, FileAccess access)
 {
     _file = file;
     _attr = attr;
     _wrapped = attr.Open(access);
 }
Esempio n. 7
0
        private void RemoveAttribute(NtfsAttribute attr)
        {
            if (attr != null)
            {
                if (attr.PrimaryRecord.AttributeType == AttributeType.IndexRoot)
                {
                    _indexCache.Remove(attr.PrimaryRecord.Name);
                }

                RemoveAttributeExtents(attr);

                _attributes.Remove(attr);

                UpdateAttributeList();
            }
        }
Esempio n. 8
0
 public NtfsAttributeBuffer(File file, NtfsAttribute attribute)
 {
     _file = file;
     _attribute = attribute;
 }