public Fat16Partition(PartitionInfo info) { _info = base.info = info; diskFileName = String.Format("\\\\.\\{0}:", info.Letter); rootDirectoryName = String.Format("{0}:\\", info.Letter); bytesPerSector = GetBytesPerSector(); diskFile = new UnmanagedFile(diskFileName); byte[] fatInfo = diskFile.ReadFile((uint)bytesPerSector); fatCopiesNumber = fatInfo.AsWord(16); fatSize = fatInfo.AsWord(22); reservedAreaSize = fatInfo.AsWord(14); sectorsPerCluster = fatInfo.AsByte(13); fatAddress = reservedAreaSize; rootDirectoryEntities = fatInfo.AsWord(17); rootDirectorySector = reservedAreaSize + (fatCopiesNumber * fatSize); bitsPerSector = GetBitsNumber(bytesPerSector); bytesPerCluster = bytesPerSector * sectorsPerCluster; fatContentSize = (uint)(fatSize * bytesPerSector); fatContent = LoadFatContent(); info.FreeSpace = GetFreeDiskSpace(); currentDirectory = new FatDirectoryObject { Name = String.Empty, Type = DirectoryObjectType.Directory, Cluster = 0 }; directoryStack.Push(currentDirectory); LoadCurrentDirectoryObjects(); }
public Fat32Partition(PartitionInfo info) { _info = base.info = info; diskFileName = String.Format("\\\\.\\{0}:", info.Letter); rootDirectoryName = String.Format("{0}:\\", info.Letter); bytesPerSector = GetBytesPerSector(); diskFile = new UnmanagedFile(diskFileName); byte[] fatInfo = diskFile.ReadFile(bytesPerSector); fatCopiesNumber = fatInfo.AsWord(16); fatSize = fatInfo.AsWord(36); reservedAreaSize = fatInfo.AsWord(14); sectorsPerCluster = fatInfo.AsByte(13); fatAddress = reservedAreaSize; rootDirectoryCluster = fatInfo.AsInt32(44); bitsPerSector = GetBitsNumber(bytesPerSector); bytesPerCluster = bytesPerSector * sectorsPerCluster; fatContentSize = (uint)(fatSize * bytesPerSector); fatContent = LoadFatContent(); info.FreeSpace = GetFreeDiskSpace(); currentDirectory = new FatDirectoryObject { Name = String.Empty, Type = DirectoryObjectType.Directory, Cluster = rootDirectoryCluster }; directoryStack.Push(currentDirectory); LoadCurrentDirectoryObjects(); }
protected void GoRootDirectory() { if (directoryStack.Count > 1) { directoryStack.Pop(); currentDirectory = (FatDirectoryObject)directoryStack.Peek(); } }
protected void GoSubDirectory(string name) { var subDirectories = contents.Where(x => (x.Type == DirectoryObjectType.Directory) && (x.Name == name)); if (subDirectories.Any()) { var subDirectory = subDirectories.First(); currentDirectory = subDirectory; directoryStack.Push(currentDirectory); } }