public Index(File file, string name, BiosParameterBlock bpb, UpperCase upCase) { _file = file; _name = name; _bpb = bpb; _isFileIndex = name == "$I30"; _blockCache = new ObjectCache <long, IndexBlock>(); _root = _file.GetStream(AttributeType.IndexRoot, _name).GetContent <IndexRoot>(); _comparer = _root.GetCollator(upCase); using (Stream s = _file.OpenStream(AttributeType.IndexRoot, _name, FileAccess.Read)) { byte[] buffer = Utilities.ReadFully(s, (int)s.Length); _rootNode = new IndexNode(WriteRootNodeToDisk, 0, this, true, buffer, IndexRoot.HeaderOffset); // Give the attribute some room to breathe, so long as it doesn't squeeze others out // BROKEN, BROKEN, BROKEN - how to figure this out? Query at the point of adding entries to the root node? _rootNode.TotalSpaceAvailable += _file.MftRecordFreeSpace(AttributeType.IndexRoot, _name) - 100; } if (_file.StreamExists(AttributeType.IndexAllocation, _name)) { _indexStream = _file.OpenStream(AttributeType.IndexAllocation, _name, FileAccess.ReadWrite); } if (_file.StreamExists(AttributeType.Bitmap, _name)) { _indexBitmap = new Bitmap(_file.OpenStream(AttributeType.Bitmap, _name, FileAccess.ReadWrite), long.MaxValue); } }
public IComparer <byte[]> GetCollator(UpperCase upCase) { switch (_collationRule) { case AttributeCollationRule.Filename: return(new FileNameComparer(upCase)); case AttributeCollationRule.SecurityHash: return(new SecurityHashComparer()); case AttributeCollationRule.UnsignedLong: return(new UnsignedLongComparer()); case AttributeCollationRule.MultipleUnsignedLongs: return(new MultipleUnsignedLongComparer()); case AttributeCollationRule.Sid: return(new SidComparer()); default: throw new NotImplementedException(); } }
public FileNameComparer(UpperCase upCase) { _stringComparer = upCase; }
public FileNameQuery(string query, UpperCase upperCase) { _query = Encoding.Unicode.GetBytes(query); _upperCase = upperCase; }