public void Add(UInt32 key, UInt32 value) { if (Keys.IndexOf(key) > -1) { ExceptionMethods.Throw(new FOS_System.Exception("Cannot add duplicate key to the dictionary!")); } Keys.Add(key); Values.Add(value); }
/// <summary> /// Reads the cluster numbers in a cluster chain starting at the specified cluster number. /// </summary> /// <param name="fileSize">The size of file being read (used only for estimating number of clusters). Must be non-zero.</param> /// <param name="FirstClusterNum">The first cluster number in the chain.</param> /// <returns>The list of cluster numbers in the chain.</returns> public UInt32List ReadClusterChain(UInt64 fileSize, UInt32 FirstClusterNum) { //The capacity calculation is designed to make the internal array of the list exactly // the correct size (or one bigger) for the number of cluster numbers in the chain. UInt32List Result = new UInt32List((int)((UInt32)fileSize / (SectorsPerCluster * BytesPerSector)) + 1); //Preallocated array for a sector of data. Used to store table data byte[] SectorBuffer = new byte[BytesPerSector]; //The sector number of the sector which contains the cluster chain information // for the current cluster number UInt64 SectorNum = 0; //Whether the current sector has been loaded or not. This allows us to load a given sector // the minimum number of times. If the cluster chain stays all within one sector, then // there's no need to keep reloading the sector. bool SectorLoaded = false; //The current cluster number in the chain UInt32 ClusterNum = FirstClusterNum; //The sector number and offset for the next entry in the cluster chain UInt64 NextSectorNum; UInt32 NextSectorOffset; //We need to do this at least once to read in the value for the starting cluster number do { //Get the sector number and offset for the current cluster num in the table. NextSectorNum = GetFATTableSectorPosition_SectorNum(ClusterNum); NextSectorOffset = GetFATTableSectorPosition_Offset(ClusterNum); //Load the sector if it hasn't already been loaded if (SectorLoaded == false || SectorNum != NextSectorNum) { ReadFATSector(NextSectorNum, SectorBuffer); SectorNum = NextSectorNum; SectorLoaded = true; } //Add the current cluster number Result.Add(ClusterNum); //Read the entry in the table for the current cluster number ClusterNum = ReadFATEntry(SectorBuffer, ClusterNum, NextSectorOffset); } //Keep looping reading the chain until we reach the end of the file. while (!FATEntryIndicatesEOF(ClusterNum)); return Result; }
/// <summary> /// Pushes the specified object onto the stack. /// </summary> /// <param name="obj">The object to push.</param> public void Push(UInt32 obj) { internalList.Add(obj); }