Bool HawkMemoryFile::SaveToDisk(const AString& sFile) { HawkDiskFile df; if (m_pData && m_iFileSize > 0 && df.Open(sFile, OPEN_WRITE)) { Int64 iSize = df.Write(m_pData, m_iFileSize); return iSize == m_iFileSize; } return false; }
UInt32 HawkOSOperator::CalcFileCrc(const AString& sFile) { UInt32 iCrc = 0; HawkDiskFile diskFile; if (diskFile.Open(sFile)) { UChar szData[DEFAULT_SIZE] = {0}; Int64 iRead = diskFile.Read(szData, DEFAULT_SIZE); while (iRead > 0) { HawkOSOperator::CalcCrc(szData, (UInt32)iRead, &iCrc); iRead = diskFile.Read(szData, DEFAULT_SIZE); } diskFile.Close(); } return iCrc; }
Bool HawkMemoryFile::Open(const AString& sFile) { Close(); m_eOpenType = OPEN_READ; m_bExtra = false; HawkDiskFile df; if (df.Open(sFile)) { m_iFileSize = df.GetFileSize(); m_pData = (Char*)HawkMalloc((Size_t)m_iFileSize); memset(m_pData, 0, (Size_t)m_iFileSize); df.Read(m_pData, m_iFileSize); return true; } return false; }