FileNameIndexEntry.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Copyright (C) 2014 Tal Aloni <tal.aloni.il@gmail.com>. All rights reserved.
  2. *
  3. * You can redistribute this program and/or modify it under the terms of
  4. * the GNU Lesser Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Text;
  10. using Utilities;
  11. namespace DiskAccessLibrary.FileSystems.NTFS
  12. {
  13. public class FileNameIndexEntry // leaf entry
  14. {
  15. public MftSegmentReference FileReference;
  16. public ushort RecordLength;
  17. public ushort FileNameOffset;
  18. public IndexEntryFlags IndexFlags;
  19. // 2 zero bytes (padding)
  20. public FileNameRecord Record;
  21. public FileNameIndexEntry(byte[] buffer, int offset)
  22. {
  23. FileReference = new MftSegmentReference(buffer, offset + 0x00);
  24. RecordLength = LittleEndianConverter.ToUInt16(buffer, offset + 0x08);
  25. FileNameOffset = LittleEndianConverter.ToUInt16(buffer, offset + 0x0A);
  26. IndexFlags = (IndexEntryFlags)LittleEndianConverter.ToUInt16(buffer, offset + 0x0C);
  27. if (RecordLength > 16)// otherwise it's the last record
  28. {
  29. Record = new FileNameRecord(buffer, offset + 0x10);
  30. }
  31. }
  32. public bool IsLastEntry
  33. {
  34. get
  35. {
  36. return ((IndexFlags & IndexEntryFlags.LastEntryInNode) > 0);
  37. }
  38. }
  39. public string FileName
  40. {
  41. get
  42. {
  43. return Record.FileName;
  44. }
  45. }
  46. public FilenameNamespace Namespace
  47. {
  48. get
  49. {
  50. return Record.Namespace;
  51. }
  52. }
  53. }
  54. }