zoukankan      html  css  js  c++  java
  • VC++:Debug出错,提示错误在findfile.cpp (Line 369)

      调试程序的Debug版本,出现断言框,定位于库文件findfile.cpp 第369行: 

    void CFileFind::AssertValid() const
    {
        // if you trip the ASSERT in the else side, you've called
        // a Get() function without having done at least one
        // FindNext() call
    
        if (m_hContext == NULL)
            ASSERT(m_pFoundInfo == NULL && m_pNextInfo == NULL);
        else
            ASSERT(m_pFoundInfo != NULL && m_pNextInfo != NULL);   // 第369行
    }

      原程序:

    CFileFind finder;
    if(finder.FindFile(filename))
    {
        CString str = findfile.GetRoot();
        // do something ...
    }

      修改后:

    CFileFind finder;
    if(finder.FindFile(filename))
    {
        findfile.FindNextFile();
        CString str = findfile.GetRoot();
        // do something ...
    }

      正确的调用的次序应该是:FindFile,FindNextFile,GetFileName/GetRoot

      扩展:BOOL CFileFind::FindNextFile

    BOOL CFileFind::FindNextFile()
    {
        ASSERT(m_hContext != NULL);
     
        if (m_hContext == NULL)
            return FALSE;
        if (m_pFoundInfo == NULL)
            m_pFoundInfo = new WIN32_FIND_DATA;
     
        ASSERT_VALID(this);
     
        void* pTemp = m_pFoundInfo;
        m_pFoundInfo = m_pNextInfo;
        m_pNextInfo = pTemp;
     
        return ::FindNextFile(m_hContext, (LPWIN32_FIND_DATA) m_pNextInfo);
    }

      以下是MSDN中对于FindNextFile的说明:

      Call this member function to continue a file search from a previous call to FindFile. 

      You must call FindNextFile at least once before calling any of the following attribute member functions:

      •   GetCreationTime

      •   GetFileName

      •   GetFileTitle

      •   GetFilePath

      •   GetFileURL

      •   GetLastAccessTime

      •   GetLastWriteTime

      •   GetLength

      •   GetRoot

      •   IsArchived

      •   IsCompressed

      •   IsDirectory

      •   IsDots

      •   IsHidden

      •   IsNormal

      •   IsReadOnly

      •   IsSystem

      •   IsTemporary

      •   MatchesMask

  • 相关阅读:
    二分法查找
    全排列 递归实现 c 语言实现
    南阳oj 题目290 动物统计加强版 字典树
    蛇形填数
    南阳理工oj 题目289 苹果 01背包
    南阳理工 oj 题目38 布线问题
    南阳理工oj 题目85 有趣的数 Cantor数表
    CSU-1110 RMQ with Shifts (单点更新+区间最小值 zkw线段树)
    POJ-2387 Til the Cows Come Home
    HDU-2680 Choose the best route
  • 原文地址:https://www.cnblogs.com/MakeView660/p/6527126.html
Copyright © 2011-2022 走看看