public XlsStream(XlsHeader hdr, uint startSector, bool isMini, XlsRootDirectory rootDir) { m_fileStream=hdr.FileStream; m_fat=hdr.FAT; m_hdr=hdr; m_startSector=startSector; m_isMini=isMini; m_rootDir=rootDir; CalculateMiniFat(rootDir); }
public void CalculateMiniFat(XlsRootDirectory rootDir) { m_minifat=m_hdr.GetMiniFAT(rootDir); }
public void CalculateMiniFat(XlsRootDirectory rootDir) { m_minifat = m_hdr.GetMiniFAT(rootDir); }
/// <summary> /// Returns mini FAT table /// </summary> public XlsFat GetMiniFAT(XlsRootDirectory rootDir) { if (m_minifat!=null) return m_minifat; //if no minifat then return null if (MiniFatSectorCount==0) //TODO(fanfeilong): ||MiniSectorSize==0xFFFFFFFE return null; var sectors=new List<uint>(MiniFatSectorCount); //find the sector where the minifat starts uint miniFatStartSector=BitConverter.ToUInt32(m_bytes, 0x3c); sectors.Add(miniFatStartSector); //lock (m_file) //{ // //work out the file location of minifat then read each sector // var miniFatStartOffset = (miniFatStartSector + 1)*SectorSize; // var miniFatSize = MiniFatSectorCount * SectorSize; // m_file.Seek(miniFatStartOffset, SeekOrigin.Begin); // byte[] sectorBuff = new byte[SectorSize]; // for (var i = 0; i < MiniFatSectorCount; i += SectorSize) // { // m_file.Read(sectorBuff, 0, 4); // var secId = BitConverter.ToUInt32(sectorBuff, 0); // sectors.Add(secId); // } //} m_minifat=new XlsFat(this, sectors, MiniSectorSize, true, rootDir); return m_minifat; }