public bool readArchiveFileHeader(FileStream fileHandle, MByteBuffer pMByteBuffer) { pMByteBuffer.clear (); fileHandle.Read(pMByteBuffer.dynBuff.buff, 0, 4); pMByteBuffer.length = 4; string magic = pMByteBuffer.readMultiByte(4, Encoding.UTF8); if (magic != "asdf") // 检查 magic { return false; } pMByteBuffer.clear (); fileHandle.Read(pMByteBuffer.dynBuff.buff, 0, (int)calcArchiveHeaderSizeNoFileHeader() - 4); pMByteBuffer.length = calcArchiveHeaderSizeNoFileHeader() - 4; // 读取 endian m_endian = pMByteBuffer.readByte (); pMByteBuffer.setEndian((Endian)m_endian); // 读取头部大小 m_headerSize = pMByteBuffer.readUnsignedInt(); // 读取版本 m_version = pMByteBuffer.readUnsignedInt(); // 读取文件数量 m_fileCount = pMByteBuffer.readUnsignedInt(); // 读取整个头 pMByteBuffer.clear (); fileHandle.Read(pMByteBuffer.dynBuff.buff, 0, (int)(m_headerSize - calcArchiveHeaderSizeNoFileHeader())); pMByteBuffer.length = m_headerSize - calcArchiveHeaderSizeNoFileHeader (); return true; }
public bool readArchiveFileHeader(FileStream fileHandle, MByteBuffer pMByteBuffer) { pMByteBuffer.clear(); fileHandle.Read(pMByteBuffer.dynBuff.buff, 0, 4); pMByteBuffer.length = 4; string magic = pMByteBuffer.readMultiByte(4, Encoding.UTF8); if (magic != "asdf") // 检查 magic { return(false); } pMByteBuffer.clear(); fileHandle.Read(pMByteBuffer.dynBuff.buff, 0, (int)calcArchiveHeaderSizeNoFileHeader() - 4); pMByteBuffer.length = calcArchiveHeaderSizeNoFileHeader() - 4; // 读取 endian m_endian = pMByteBuffer.readByte(); pMByteBuffer.setEndian((Endian)m_endian); // 读取头部大小 m_headerSize = pMByteBuffer.readUnsignedInt(); // 读取版本 m_version = pMByteBuffer.readUnsignedInt(); // 读取文件数量 m_fileCount = pMByteBuffer.readUnsignedInt(); // 读取整个头 pMByteBuffer.clear(); fileHandle.Read(pMByteBuffer.dynBuff.buff, 0, (int)(m_headerSize - calcArchiveHeaderSizeNoFileHeader())); pMByteBuffer.length = m_headerSize - calcArchiveHeaderSizeNoFileHeader(); return(true); }
public void readHeaderFromArchiveFile(MByteBuffer ba) { m_pathLen = ba.readUnsignedByte(); m_fileNamePath = ba.readMultiByte(m_pathLen, Encoding.UTF8); m_fileOffset = ba.readUnsignedInt(); m_fileSize = ba.readUnsignedInt(); m_flags = ba.readUnsignedInt(); }
public void readArchiveFileHeader(FileStream fileHandle) { MByteBuffer pMByteBuffer = new MByteBuffer(); if (m_pArchiveHeader.readArchiveFileHeader(fileHandle, pMByteBuffer)) // 检查 magic { FileHeader pFileHeader; for (uint idx = 0; idx < m_pArchiveHeader.m_fileCount; ++idx) { pFileHeader = new FileHeader(); m_pFileVec.Add(pFileHeader); pFileHeader.readHeaderFromArchiveFile(pMByteBuffer); } } }