if (header.difatSectorsNumber != 0) { validationCount = (int)header.difatSectorsNumber; Sector s = sectors[header.FirstDIFATSectorID] as Sector; if (s == null) //Lazy loading { s = new Sector(GetSectorSize(), sourceStream); s.Type = SECTORTYPE.DIFAT; s.Id = header.FirstDIFATSectorID; sectors[header.FirstDIFATSectorID] = s; } result.Add(s); while (true && validationCount >= 0) { nextSecID = BitConverter.ToInt32(s.GetData(), GetSectorSize() - 4); EnsureUniqueSectorIndex(nextSecID, processedSectors); // Strictly speaking, the following condition is not correct from // a specification point of view: // only ENDOFCHAIN should break DIFAT chain but // a lot of existing compound files use FREESECT as DIFAT chain termination if (nextSecID == Sector.FREESECT || nextSecID == Sector.ENDOFCHAIN) break; validationCount--; if (validationCount < 0) { if (this.closeStream) this.Close(); if (this.validationExceptionEnabled) throw new CFCorruptedFileException("DIFAT sectors count mismatched. Corrupted compound file"); } s = sectors[nextSecID] as Sector; if (s == null) { s = new Sector(GetSectorSize(), sourceStream); s.Id = nextSecID; sectors[nextSecID] = s; } result.Add(s); } }这段代码是什么意思
时间: 2024-02-10 18:07:29 浏览: 179
dtc2.slx.rar_.slx_12 sector_12 sector DTC_dtc 12_pmsm dtc
这段代码是用来验证复合文件的 DIFAT(分配表)的。它首先检查 DIFAT 所使用的扇区数是否为零,如果不是,那么就需要对 DIFAT 链进行验证。在验证过程中,它会从第一个 DIFAT 扇区开始,将 DIFAT 链上的每个扇区加入到一个结果列表中。当遇到链的末尾时,会停止添加扇区,并退出循环。如果验证过程中发现扇区数量与记录的不一致,则会抛出异常。
阅读全文