// // Copyright (c) 2008-2011, Kenneth Bell // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, merge, publish, distribute, sublicense, // and/or sell copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. // namespace DiscUtils.Ntfs.Internals { using System.Collections.Generic; /// /// An entry within the Master File Table. /// public sealed class MasterFileTableEntry { private INtfsContext _context; private FileRecord _fileRecord; internal MasterFileTableEntry(INtfsContext context, FileRecord fileRecord) { _context = context; _fileRecord = fileRecord; } /// /// Gets the index of this entry in the Master File Table. /// public long Index { get { return _fileRecord.LoadedIndex; } } /// /// Gets the change identifier that is updated each time the file is modified by Windows, relates to the NTFS log file. /// /// /// The NTFS log file provides journalling, preventing meta-data corruption in the event of a system crash. /// public long LogFileSequenceNumber { get { return (long)_fileRecord.LogFileSequenceNumber; } } /// /// Gets the revision number of the entry. /// /// /// Each time an entry is allocated or de-allocated, this number is incremented by one. /// public int SequenceNumber { get { return _fileRecord.SequenceNumber; } } /// /// Gets the number of hard links referencing this file. /// public int HardLinkCount { get { return _fileRecord.HardLinkCount; } } /// /// Gets the flags indicating the nature of the entry. /// public MasterFileTableEntryFlags Flags { get { return (MasterFileTableEntryFlags)_fileRecord.Flags; } } /// /// Gets the identity of the base entry for files split over multiple entries. /// /// /// All entries that form part of the same file have the same value for /// this property. /// public MasterFileTableReference BaseRecordReference { get { return new MasterFileTableReference(_fileRecord.BaseFile); } } /// /// Gets the next attribute identity that will be allocated. /// public int NextAttributeId { get { return _fileRecord.NextAttributeId; } } /// /// Gets the index of this entry in the Master File Table (as stored in the entry itself). /// /// /// Note - older versions of Windows did not store this value, so it may be Zero. /// public long SelfIndex { get { return _fileRecord.MasterFileTableIndex; } } /// /// Gets the attributes contained in this entry. /// public ICollection Attributes { get { List result = new List(); foreach (var attr in _fileRecord.Attributes) { result.Add(GenericAttribute.FromAttributeRecord(_context, attr)); } return result; } } } }