这篇教程C++ AfxThrowFileException函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中AfxThrowFileException函数的典型用法代码示例。如果您正苦于以下问题:C++ AfxThrowFileException函数的具体用法?C++ AfxThrowFileException怎么用?C++ AfxThrowFileException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了AfxThrowFileException函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ASSERT_VALIDUINT 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,
示例2: AfxThrowFileExceptionUINT 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,
示例3: switchLONG 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,
示例4: AfxThrowFileExceptionvoid PASCAL CFileException::ThrowErrno(int nErrno, LPCTSTR lpszFileName /* = NULL */){ if (nErrno != 0) AfxThrowFileException(CFileException::ErrnoToException(nErrno), _doserrno, lpszFileName);}
开发者ID:Ugnis,项目名称:Far-NetBox,代码行数:7,
示例5: ASSERTvoid 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,
示例6: ASSERTUINT 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,
示例7: CMemFileCOXRegistryValFile::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,
示例8: AfxThrowFileExceptionuint64 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,
示例9: ASSERTvoid 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,
示例10: ASSERT_VALIDvoid CStdioFile::Flush(){ ASSERT_VALID(this); if (m_pStream != NULL && fflush(m_pStream) != 0) AfxThrowFileException(CFileException::diskFull, _doserrno, m_strFileName);}
开发者ID:Rupan,项目名称:winscp,代码行数:8,
示例11: va_startint 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,
示例12: AfxThrowFileExceptionvoid PASCAL CFileException::ThrowErrno(int nErrno){ if (nErrno != 0) AfxThrowFileException(CFileException::ErrnoToException(nErrno),#ifndef _MAC _doserrno);#else GetLastError());#endif}
开发者ID:rickerliang,项目名称:OpenNT,代码行数:10,
示例13: ASSERTvoid 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,
示例14: _ASSERTEBOOL 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,
示例15: fclosevoid 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,
示例16: ASSERTvoid 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,
示例17: ASSERTvoid 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,
注:本文中的AfxThrowFileException函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ AfxThrowMemoryException函数代码示例 C++ AfxTermExtensionModule函数代码示例 |