private bool ValidAttribute(FATDirectoryAttributes attr) { return attr == FATDirectoryAttributes.ATTR_LONG_NAME || attr == FATDirectoryAttributes.ATTR_VOLUME_ID || (attr & (FATDirectoryAttributes.ATTR_ARCHIVE | FATDirectoryAttributes.ATTR_DIRECTORY | FATDirectoryAttributes.ATTR_HIDDEN | FATDirectoryAttributes.ATTR_READ_ONLY | FATDirectoryAttributes.ATTR_SYSTEM)) == attr; }
private bool ValidAttribute(FATDirectoryAttributes attr) { return(attr == FATDirectoryAttributes.ATTR_LONG_NAME || attr == FATDirectoryAttributes.ATTR_VOLUME_ID || (attr & (FATDirectoryAttributes.ATTR_ARCHIVE | FATDirectoryAttributes.ATTR_DIRECTORY | FATDirectoryAttributes.ATTR_HIDDEN | FATDirectoryAttributes.ATTR_READ_ONLY | FATDirectoryAttributes.ATTR_SYSTEM)) == attr); }
public DirectoryEntry(FileSystemFAT fileSystem, long offset) { byte[] data = fileSystem.Store.GetBytes((ulong)offset, DIR_ENTRY_SIZE); DIR_Name = ASCIIEncoding.ASCII.GetString(data, 0, 11); DIR_Attr = (FATDirectoryAttributes)data[11]; DIR_NTRes = data[12]; DIR_CrtTimeTenth = data[13]; DIR_CrtTime = BitConverter.ToUInt16(data, 14); DIR_CrtDate = BitConverter.ToUInt16(data, 16); DIR_LstAccDate = BitConverter.ToUInt16(data, 18); DIR_FstClusHI = BitConverter.ToUInt16(data, 20); DIR_WrtTime = BitConverter.ToUInt16(data, 22); DIR_WrtDate = BitConverter.ToUInt16(data, 24); DIR_FstClusLO = BitConverter.ToUInt16(data, 26); DIR_FileSize = BitConverter.ToUInt32(data, 28); Free = data[0] == 0x0 || data[0] == 0x05 || data[0] == 0xE5; Last = data[0] == 0x0; string filename = DIR_Name.Substring(0, 8).Trim().ToLower(); string ext = DIR_Name.Substring(8).Trim().ToLower(); FileName = filename; if (ext != "") { if ((Attributes & FATDirectoryAttributes.ATTR_VOLUME_ID) == 0) { FileName += "."; } FileName += ext; } Offset = fileSystem.GetDiskOffsetOfFATCluster(ClusterNum); if (LongNameEntry) { LongName = string.Concat(Encoding.Unicode.GetString(data, 1, 10), Encoding.Unicode.GetString(data, 14, 12), Encoding.Unicode.GetString(data, 28, 4)); } }