public File(byte[] buffer, FAT fat, int ParentClusterNumber, Directory parent) : base(buffer, fat, ParentClusterNumber, parent) { }
public Directory(byte[] Buffer, FAT fat, int ParentClusterNumber, Directory parent) : base(Buffer, fat, ParentClusterNumber, parent) { subFiles = new List<File>(); subDirectories = new List<Directory>(); }
private void getSubEntities() { uint length; List<int> clusters = fat.getClusterTail(FirstClusterOfFile); int numberOfBytesPerCluster = fat.SectorsPerCluster * fat.BytesPerSector; byte[] buffer = new byte[clusters.Count() * numberOfBytesPerCluster]; subDirectories.Clear(); subFiles.Clear(); for (int i = 0; i < clusters.Count(); i++) { byte[] temp = IO.read(fat.HandleFile, clusters[i], fat.ClusterSize, fat); for (int j = 0; j < temp.Length; j++) { buffer[i * numberOfBytesPerCluster + j] = temp[j]; } } Stack<byte[]> longName = new Stack<byte[]>(); for (int i = 0; i < buffer.Length; i += 32) { if (buffer[i] == 0) { //no more entity beyond break; } else if (buffer[i + 11] == 0x0f) { longName.Push(buffer.ToList().GetRange(i, 32).ToArray()); } else { Entity temp = new Entity(buffer.ToList().GetRange(i, 32).ToArray(), fat, clusters[(i + 1) / numberOfBytesPerCluster], this); string tempName = null; for (; longName.Count != 0; ) { var x = longName.Pop(); tempName += Encoding.Unicode.GetString(x.ToList().GetRange(1, 10).ToArray()) + Encoding.Unicode.GetString(x.ToList().GetRange(14, 12).ToArray()) + Encoding.Unicode.GetString(x.ToList().GetRange(28, 4).ToArray()); } temp.LongName = tempName != null ? tempName.Split('\0')[0] : null; if (temp.Attribute.IsDirectory) { Directory di = new Directory(buffer.ToList().GetRange(i, 32).ToArray(), fat, clusters[(i + 1) / numberOfBytesPerCluster], this); di.LongName = tempName != null ? tempName.Split('\0')[0] : null; subDirectories.Add(di); } else { File fi = new File(buffer.ToList().GetRange(i, 32).ToArray(), fat, clusters[(i + 1) / numberOfBytesPerCluster], this); fi.LongName = tempName != null ? tempName.Split('\0')[0] : null; subFiles.Add(fi); } longName.Clear(); } } }
public Entity(byte[] Buffer, FAT fat, int clusterIndex, Directory parent) { this.buffer = Buffer; this.parent = parent; this.fat = fat; this.clusterIndex = clusterIndex; }
private void fileExplorerFiller(Directory directory) { fileView.Items.Clear(); foreach (var v in directory.SubFiles) { fileView.Items.Add(v.ToListItem()); } }