예제 #1
0
        /// <summary>
        /// Reads stream data from file
        /// </summary>
        /// <returns>Stream data</returns>
        public byte[] ReadStream()
        {
            uint sector = m_startSector, prevSector = 0;
            int  sectorSize = m_hdr.SectorSize;

            byte[] buff = new byte[sectorSize];
            byte[] ret;

            using (MemoryStream ms = new MemoryStream(sectorSize * 8))
            {
                lock (m_fileStream)
                {
                    do
                    {
                        if (prevSector == 0 || (sector - prevSector) != 1)
                        {
                            m_fileStream.Seek((sector + 1) * sectorSize, SeekOrigin.Begin);
                        }
                        prevSector = sector;
                        m_fileStream.Read(buff, 0, sectorSize);
                        ms.Write(buff, 0, sectorSize);
                    } while ((sector = m_fat.GetNextSector(sector)) != (uint)FATMARKERS.FAT_EndOfChain);
                }

                ret = ms.ToArray();
            }

            return(ret);
        }
예제 #2
0
파일: XlsStream.cs 프로젝트: q425163005/GF
        public byte[] ReadStream()
        {
            uint   startSector = this.m_startSector;
            uint   num2        = 0;
            int    count       = this.m_isMini ? this.m_hdr.MiniSectorSize : this.m_hdr.SectorSize;
            XlsFat fat         = this.m_isMini ? this.m_minifat : this.m_fat;
            long   num4        = 0L;

            if (this.m_isMini && (this.m_rootDir != null))
            {
                num4 = (this.m_rootDir.RootEntry.StreamFirstSector + 1) * this.m_hdr.SectorSize;
            }
            byte[] buffer = new byte[count];
            using (MemoryStream stream = new MemoryStream(count * 8))
            {
                lock (this.m_fileStream)
                {
                    do
                    {
                        if ((num2 == 0) || ((startSector - num2) != 1))
                        {
                            uint num5 = this.m_isMini ? startSector : (startSector + 1);
                            this.m_fileStream.Seek((num5 * count) + num4, SeekOrigin.Begin);
                        }
                        num2 = startSector;
                        this.m_fileStream.Read(buffer, 0, count);
                        stream.Write(buffer, 0, count);
                    }while ((startSector = fat.GetNextSector(startSector)) != 0xfffffffe);
                }
                return(stream.ToArray());
            }
        }