// // 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; /// /// Representation of an NTFS File Name attribute. /// /// /// /// Each Master File Table entry (MFT Entry) has one of these attributes for each /// hard link. Files with a long name and a short name will have at least two of /// these attributes. /// /// The details in this attribute may be inconsistent with similar information in /// the StandardInformationAttribute for a file. The StandardInformation is /// definitive, this attribute holds a 'cache' of the information. /// /// public sealed class FileNameAttribute : GenericAttribute { private FileNameRecord _fnr; internal FileNameAttribute(INtfsContext context, AttributeRecord record) : base(context, record) { byte[] content = Utilities.ReadAll(Content); _fnr = new FileNameRecord(); _fnr.ReadFrom(content, 0); } /// /// Gets the reference to the parent directory. /// /// /// This attribute stores the name of a file within a directory, this field /// provides the link back to the directory. /// public MasterFileTableReference ParentDirectory { get { return new MasterFileTableReference(_fnr.ParentDirectory); } } /// /// Gets the creation time of the file. /// public DateTime CreationTime { get { return _fnr.CreationTime; } } /// /// Gets the modification time of the file. /// public DateTime ModificationTime { get { return _fnr.ModificationTime; } } /// /// Gets the last time the Master File Table entry for the file was changed. /// public DateTime MasterFileTableChangedTime { get { return _fnr.MftChangedTime; } } /// /// Gets the last access time of the file. /// public DateTime LastAccessTime { get { return _fnr.LastAccessTime; } } /// /// Gets the amount of disk space allocated for the file. /// public long AllocatedSize { get { return (long)_fnr.AllocatedSize; } } /// /// Gets the amount of data stored in the file. /// public long RealSize { get { return (long)_fnr.RealSize; } } /// /// Gets the attributes of the file, as stored by NTFS. /// public NtfsFileAttributes FileAttributes { get { return (NtfsFileAttributes)_fnr.Flags; } } /// /// Gets the extended attributes size, or a reparse tag, depending on the nature of the file. /// public long ExtendedAttributesSizeOrReparsePointTag { get { return (long)_fnr.EASizeOrReparsePointTag; } } /// /// Gets the namespace of the FileName property. /// public NtfsNamespace FileNameNamespace { get { return (NtfsNamespace)_fnr.FileNameNamespace; } } /// /// Gets the name of the file within the parent directory. /// public string FileName { get { return _fnr.FileName; } } } }