private static DirectoryEntry[] GetInstances(byte[] bytes, string volume, string directoryName) { List <DirectoryEntry> list = new List <DirectoryEntry>(); List <LongDirectoryEntry> longList = new List <LongDirectoryEntry>(); for (int i = 0; i < bytes.Length; i += 0x20) { FILE_ATTR attr = (FILE_ATTR)bytes[11 + i]; // If entry is a Long File Name Entry then add it to the List if (attr == FILE_ATTR.ATTR_LONG_NAME) { LongDirectoryEntry longEntry = LongDirectoryEntry.Get(bytes, i); longList.Add(longEntry); } // Else the entry is a valid entry else { DirectoryEntry entry = DirectoryEntry.Get(bytes, i, volume, longList, directoryName); if (entry.DIR_Attribute != 0 && entry.FileName != "." && entry.FileName != "..") { list.Add(entry); } longList.Clear(); } } return(list.ToArray()); }
/// <summary> /// /// </summary> /// <param name="bytes"></param> /// <param name="index"></param> /// <param name="volume"></param> /// <param name="longNameList"></param> /// <param name="directoryName"></param> public DirectoryEntry(byte[] bytes, int index, string volume, List <LongDirectoryEntry> longNameList, string directoryName) { Volume = volume; FileName = GetShortName(bytes, index); FullName = GetLongName(FileName, longNameList, directoryName); Deleted = TestIfFree(bytes, index); DIR_Attribute = (FILE_ATTR)bytes[11 + index]; Directory = (DIR_Attribute & FILE_ATTR.ATTR_DIRECTORY) == FILE_ATTR.ATTR_DIRECTORY; Hidden = (DIR_Attribute & FILE_ATTR.ATTR_HIDDEN) == FILE_ATTR.ATTR_HIDDEN; DIR_CreationTimeTenth = bytes[13 + index]; DIR_CreationTime = BitConverter.ToUInt16(bytes, 14 + index); DIR_CreationDate = BitConverter.ToUInt16(bytes, 16 + index); CreationTime = Helper.GetFATTime(DIR_CreationDate, DIR_CreationTime, DIR_CreationTimeTenth); DIR_LastAccessDate = BitConverter.ToUInt16(bytes, 18 + index); AccessTime = Helper.GetFATTime(DIR_LastAccessDate); DIR_FirstClusterHI = BitConverter.ToUInt16(bytes, 20 + index); DIR_WriteTime = BitConverter.ToUInt16(bytes, 22 + index); DIR_WriteDate = BitConverter.ToUInt16(bytes, 24 + index); WriteTime = Helper.GetFATTime(DIR_WriteDate, DIR_WriteTime); DIR_FirstClusterLO = BitConverter.ToUInt16(bytes, 26 + index); FirstCluster = (uint)(DIR_FirstClusterHI << 16) + DIR_FirstClusterLO; FileSize = BitConverter.ToUInt32(bytes, 28 + index); }