woaidongmao

文章均收录自他人博客,但不喜标题前加-[转贴],因其丑陋,见谅!~
随笔 - 1469, 文章 - 0, 评论 - 661, 引用 - 0
数据加载中……

文件载入

BOOL            LoadFile(const char* file_name, vector<char>& vec_file);

 

BOOL Glob_Fun::LoadFile(const char* file_name, vector<char>& vec_file)
{
    vec_file.clear();
    if ((NULL == file_name))
        return FALSE;
    CFile file;
    char szBuf[1024 * 10] = "", *pTmp = NULL;
    int nRead = 0;
    int file_len = 0;

    if(FALSE == file.Open(file_name,CFile::modeRead))
        return FALSE;

    if(0 >= (file_len=file.GetLength()))
    {
        file.Close();
        return TRUE;
    }
    vec_file.resize(file_len);
    pTmp = &vec_file[0];
    do
    {
        nRead = file.Read(szBuf, sizeof(szBuf));
        memcpy(pTmp, szBuf, nRead);
        pTmp += nRead;
    }while (nRead > 0);
    file.Close();
    return TRUE;
}

posted on 2008-06-25 11:16 肥仔 阅读(373) 评论(0)  编辑 收藏 引用 所属分类: 库 & 代码段


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理