• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ AfxThrowFileException函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中AfxThrowFileException函数的典型用法代码示例。如果您正苦于以下问题:C++ AfxThrowFileException函数的具体用法?C++ AfxThrowFileException怎么用?C++ AfxThrowFileException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了AfxThrowFileException函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ASSERT_VALID

UINT CStdioFile::Read(void* lpBuf, UINT nCount)
{
	ASSERT_VALID(this);
	ASSERT(m_pStream != NULL);

	if (nCount == 0)
		return 0;   // avoid Win32 "null-read"

	ASSERT(AfxIsValidAddress(lpBuf, nCount));

	if (lpBuf == NULL)
	{
		AfxThrowInvalidArgException();
	}

	UINT nRead = 0;

	if ((nRead = (UINT)fread(lpBuf, sizeof(BYTE), nCount, m_pStream)) == 0 && !feof(m_pStream))
		AfxThrowFileException(CFileException::genericException, _doserrno, m_strFileName);
	if (ferror(m_pStream))
	{
		Afx_clearerr_s(m_pStream);
		AfxThrowFileException(CFileException::genericException, _doserrno, m_strFileName);
	}
	return nRead;
}
开发者ID:jbeaurain,项目名称:omaha_vs2010,代码行数:26,代码来源:filetxt.cpp


示例2: AfxThrowFileException

UINT CBuffFile::Read(void* lpBuf, UINT nCount)
{
	UINT nRead = 0;

	if ((nRead = fread(lpBuf, sizeof(BYTE), nCount, m_pStream)) == 0 && !feof(m_pStream))
		AfxThrowFileException(CFileException::generic, _doserrno);
	if (ferror(m_pStream))
	{
		clearerr(m_pStream);
		AfxThrowFileException(CFileException::generic, _doserrno);
	}
	return nRead;
}
开发者ID:Madzi,项目名称:POW,代码行数:13,代码来源:Mycbufil.cpp


示例3: switch

LONG CMyMemFile::Seek(LONG lOff, UINT nFrom)
{
    switch(nFrom)
    {
    case CFile::begin:
        if(NULL != m_pData)
        {
            m_pData -= m_dwLength;
            m_pData += lOff;
        }
        m_dwLength = lOff;
        break;

    case CFile::current:
        if(NULL != m_pData)
        {
            m_pData += lOff;
        }
        m_dwLength += lOff;
        break;

    case CFile::end:
    default:
        AfxThrowFileException(CFileException::badSeek);
    }
    return m_dwLength;
}
开发者ID:tomorrow56,项目名称:VS2010,代码行数:27,代码来源:MyMemFile.cpp


示例4: AfxThrowFileException

void PASCAL CFileException::ThrowErrno(int nErrno,
	LPCTSTR lpszFileName /* = NULL */)
{
	if (nErrno != 0)
		AfxThrowFileException(CFileException::ErrnoToException(nErrno),
			_doserrno, lpszFileName);
}
开发者ID:Ugnis,项目名称:Far-NetBox,代码行数:7,代码来源:filex.cpp


示例5: ASSERT

void CStdioFileEx::WriteWideString(LPCWSTR lpsz)
{
   ASSERT(lpsz != NULL);
   
   if (lpsz == NULL)
   {
      AfxThrowInvalidArgException();
   }
   if(m_bIsUnicodeText)
   {
      ASSERT(m_pStream != NULL);
      // If writing Unicode and at the start of the file, need to write byte mark
      if(GetPosition() == 0)
      {
         wchar_t cBOM = (wchar_t)UNICODE_BOM;
         CFile::Write(&cBOM, sizeof(wchar_t));
      }
      if (fputws(lpsz, m_pStream) == _TEOF)
         AfxThrowFileException(CFileException::diskFull, _doserrno, m_strFileName);
   }
   else
   {
      USES_CONVERSION;
      WriteAnsiString(CW2A(lpsz));
   }
}
开发者ID:jhpeng,项目名称:FreeMyUSB,代码行数:26,代码来源:StdioFileEx.cpp


示例6: ASSERT

UINT CConverter::Read(void FAR* lpBuf, UINT nCount)
{
	ASSERT(m_bForeignToRtf);
	if (m_bDone)
		return 0;
	// if converter is done
	int cch = nCount;
	BYTE* pBuf = (BYTE*)lpBuf;
	while (cch != 0)
	{
		if (m_nBytesAvail == 0)
		{
			if (m_pBuf != NULL)
				GlobalUnlock(m_hBuff);
			m_pBuf = NULL;
			SetEvent(m_hEventConv);
			WaitForConverter();
			VERIFY(ResetEvent(m_hEventFile));
			if (m_bConvErr)
				AfxThrowFileException(CFileException::generic);
			if (m_bDone)
				return nCount - cch;
			m_pBuf = (BYTE*)GlobalLock(m_hBuff);
			ASSERT(m_pBuf != NULL);
		}
		int nBytes = min(cch, m_nBytesAvail);
		memcpy(pBuf, m_pBuf, nBytes);
		pBuf += nBytes;
		m_pBuf += nBytes;
		m_nBytesAvail -= nBytes;
		cch -= nBytes;
		OutputPercent(m_nPercent);
	}
	return nCount - cch;
}
开发者ID:BraveStone,项目名称:wordpad,代码行数:35,代码来源:multconv.cpp


示例7: CMemFile

COXRegistryValFile::COXRegistryValFile(HKEY hkey, LPCTSTR lpszKey, LPCTSTR lpszValue)
	: CMemFile(1024), m_key(0)
	{
	LONG error;
	if (!Open(hkey, lpszKey, lpszValue, error))
		AfxThrowFileException(CFileException::accessDenied, error, lpszKey);
	}
开发者ID:drupalhunter-team,项目名称:TrackMonitor,代码行数:7,代码来源:OXRegistryValFile.cpp


示例8: AfxThrowFileException

uint64 CSafeMemFile::ReadUInt64()
{
	if (m_nPosition + sizeof(uint64) > m_nFileSize)
		AfxThrowFileException(CFileException::endOfFile, 0, GetFileName());
	uint64 nResult = *((uint64*)(m_lpBuffer + m_nPosition));
	m_nPosition += sizeof(uint64);
	return nResult;
}
开发者ID:litaobj,项目名称:easymule,代码行数:8,代码来源:SafeFile.cpp


示例9: ASSERT

void CStdioFile::WriteString(LPCTSTR lpsz)
{
	ASSERT(lpsz != NULL);
	ASSERT(m_pStream != NULL);

	if (_fputts(lpsz, m_pStream) == _TEOF)
		AfxThrowFileException(CFileException::diskFull, _doserrno, m_strFileName);
}
开发者ID:Rupan,项目名称:winscp,代码行数:8,代码来源:filetxt.cpp


示例10: ASSERT_VALID

void CStdioFile::Flush()
{
	ASSERT_VALID(this);

	if (m_pStream != NULL && fflush(m_pStream) != 0)
		AfxThrowFileException(CFileException::diskFull, _doserrno,
			m_strFileName);
}
开发者ID:Rupan,项目名称:winscp,代码行数:8,代码来源:filetxt.cpp


示例11: va_start

int CSafeBufferedFile::printf(LPCTSTR pszFmt, ...)
{
	va_list args;
	va_start(args, pszFmt);
	int iResult = _vftprintf(m_pStream, pszFmt, args);
	va_end(args);
	if (iResult < 0)
		AfxThrowFileException(CFileException::generic, _doserrno, m_strFileName);
	return iResult;
}
开发者ID:litaobj,项目名称:easymule,代码行数:10,代码来源:SafeFile.cpp


示例12: AfxThrowFileException

void PASCAL CFileException::ThrowErrno(int nErrno)
{
	if (nErrno != 0)
		AfxThrowFileException(CFileException::ErrnoToException(nErrno),
#ifndef _MAC
			_doserrno);
#else
			GetLastError());
#endif
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:10,代码来源:filex.cpp


示例13: ASSERT

void CSocketFile::Write(const void* lpBuf, UINT nCount)
{
	ASSERT (m_pSocket!=NULL);

	int nWritten = m_pSocket->Send(lpBuf, nCount);
	if (nWritten == SOCKET_ERROR)
	{
		int nError = m_pSocket->GetLastError();
		AfxThrowFileException(CFileException::generic, nError);
	}
}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:11,代码来源:sockcore.cpp


示例14: _ASSERTE

BOOL CStdioFileEx::ReadWideString(CStringW& rString)
{
   _ASSERTE(m_pStream);
   rString = L"";// empty string without deallocating
   
   if(m_bIsUnicodeText)
   {
      // If at position 0, discard byte-order mark before reading
      if(GetPosition() == 0)
      {
         wchar_t bom;
         Read(&bom, sizeof(wchar_t));
      }
      const int nMaxSize = 128;
      LPWSTR lpsz = rString.GetBuffer(nMaxSize);
      LPWSTR lpszResult;
      int nLen = 0;
      for (;;)
      {
         lpszResult = fgetws(lpsz, nMaxSize+1, m_pStream);
         rString.ReleaseBuffer();
         
         // handle error/eof case
         if (lpszResult == NULL && !feof(m_pStream))
         {
            Afx_clearerr_s(m_pStream);
            AfxThrowFileException(CFileException::genericException, _doserrno,
               m_strFileName);
         }
         
         // if string is read completely or EOF
         if (lpszResult == NULL || (nLen = (int)lstrlenW(lpsz)) < nMaxSize || lpsz[nLen-1] == '\n')
            break;
         
         nLen = rString.GetLength();
         lpsz = rString.GetBuffer(nMaxSize + nLen) + nLen;
      }
      //remove crlf if exist.
      nLen = rString.GetLength();
      if (nLen > 1 && rString.Mid(nLen-2) == L"\r\n")
      {
         rString.GetBufferSetLength(nLen-2);
      }
      return rString.GetLength() > 0;
   }
   else
   {
      CStringA ansiString;
      BOOL bRetval = ReadAnsiString(ansiString);
      //setlocale(LC_ALL, "chs_chn.936");//no need
      rString = ansiString;
      return bRetval;
   }
}
开发者ID:jhpeng,项目名称:FreeMyUSB,代码行数:54,代码来源:StdioFileEx.cpp


示例15: fclose

void CBuffFile::Close()
{
	int nErr= 0;
	if (m_pStream != NULL)
		nErr = fclose(m_pStream);

	m_hFile = hFileNull;
	m_bCloseOnDelete = FALSE;
	m_pStream = NULL;

	if (nErr != 0)
		AfxThrowFileException(CFileException::diskFull, _doserrno);
}
开发者ID:Madzi,项目名称:POW,代码行数:13,代码来源:Mycbufil.cpp


示例16: ASSERT

void CStdioFileT::WriteString(LPCWSTR lpsz)
{
	ASSERT(lpsz != NULL);
	ASSERT(m_pStream != NULL);

	if (lpsz == NULL)
	{
		AfxThrowInvalidArgException();
	}

	if (fputws(lpsz, m_pStream) == EOF)
		AfxThrowFileException(CFileException::diskFull, _doserrno, m_strFileName);
}
开发者ID:omnibs,项目名称:TortoiseGit,代码行数:13,代码来源:StdioFileT.cpp


示例17: ASSERT

void CDocument::SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU)
{
	// store the path fully qualified
	TCHAR szFullPath[_MAX_PATH];
	if ( lstrlen(lpszPathName) >= _MAX_PATH )
	{
		ASSERT(FALSE);
		// MFC requires paths with length < _MAX_PATH
		// No other way to handle the error from a void function
		AfxThrowFileException(CFileException::badPath);
	}

	if( AfxFullPath(szFullPath, lpszPathName) == FALSE )
	{
		ASSERT(FALSE);
		// MFC requires paths with length < _MAX_PATH
		// No other way to handle the error from a void function
		AfxThrowFileException(CFileException::badPath);
	}

	m_strPathName = szFullPath;
	ASSERT(!m_strPathName.IsEmpty());       // must be set to something
	m_bEmbedded = FALSE;
	ASSERT_VALID(this);

	// set the document title based on path name
	TCHAR szTitle[_MAX_FNAME];
	if (AfxGetFileTitle(szFullPath, szTitle, _MAX_FNAME) == 0)
		SetTitle(szTitle);

	// add it to the file MRU list
	if (bAddToMRU)
		AfxGetApp()->AddToRecentFileList(m_strPathName);

	ASSERT_VALID(this);
}
开发者ID:pixelspark,项目名称:corespark,代码行数:36,代码来源:doccore.cpp



注:本文中的AfxThrowFileException函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ AfxThrowMemoryException函数代码示例发布时间:2022-05-30
下一篇:
C++ AfxTermExtensionModule函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap