您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FileException函数代码示例

51自学网 2021-06-01 20:46:00
  C++
这篇教程C++ FileException函数代码示例写得很实用,希望能帮到您。

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

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

示例1: FileException

 unsigned long File::FileImpl::Write(const void *buf, unsigned long bytes) {   DWORD WriteBytes = static_cast<DWORD>(bytes);   if (!WriteFile(FileHandle, buf, static_cast<DWORD>(bytes), &WriteBytes, NULL))     throw FileException("Can't write");   return static_cast<unsigned long>(WriteBytes); }
开发者ID:Diego160289,项目名称:cross-fw,代码行数:7,


示例2: FileException

std::string File::readString(size_t len) {	if (!_file)		throw FileException("File is not open");	if ((_mode & FILEMODE_READ) == 0)		throw FileException("Tried to read from file opened in write mode (" + _name.getFullPath() + ")");	std::string s('/0', len);	std::string::iterator is = s.begin();	char c;	while ((c = readByte())) {		*is = c;	}	return s;}
开发者ID:agfor,项目名称:scummvm-tools,代码行数:16,


示例3: FileException

void File::copyFile(const tstring& source, const tstring& target){	if (!::CopyFile(formatPath(source).c_str(), formatPath(target).c_str(), FALSE))	{		throw FileException(Util::translateError(GetLastError())); // 2012-05-03_22-05-14_LZE57W5HZ7NI3VC773UG4DNJ4QIKP7Q7AEBLWOA_AA236F48_crash-stack-r502-beta24-x64-build-9900.dmp	}}
开发者ID:snarkus,项目名称:flylinkdc-r5xx,代码行数:7,


示例4: poco_assert

void FileImpl::renameToImpl(const std::string& path){	poco_assert (!_path.empty());	POCO_DESCRIPTOR_STRING(oldNameDsc, _path);	POCO_DESCRIPTOR_STRING(newNameDsc, path);	int res;	if ((res = lib$rename_file(&oldNameDsc, &newNameDsc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) != 1)	{		switch (res & 0x0FFFFFFF)		{		case RMS$_FNF: 			throw FileNotFoundException(_path);		case RMS$_DEV:		case RMS$_DNF:			throw PathNotFoundException(_path);		case RMS$_SYN:			throw PathSyntaxException(path);		case RMS$_RMV:			throw FileAccessDeniedException(_path);		case RMS$_PRV:			throw FileAccessDeniedException("insufficient privileges", _path);				default:			throw FileException(path);		}	}}
开发者ID:carvalhomb,项目名称:tsmells,代码行数:28,


示例5: fopen

/** @brief FileReaderDataSource  *  * @todo: document this function  */ FileReaderDataSource::FileReaderDataSource(std::string FileName){	FileHandle = fopen(FileName.c_str(), "rb");	if (FileHandle == NULL)		throw FileException(std::string("Could not open ") + FileName);	reset();}
开发者ID:dgeelen,项目名称:dmplayer,代码行数:11,


示例6: CreateFileW

utils::File::File(const zchar* const filename, FileAccess access, FileShare share,	FileMode mode, FileType type){	hFile = CreateFileW(filename, static_cast<DWORD>(access), static_cast<DWORD>(share), nullptr,		static_cast<DWORD>(mode), static_cast<DWORD>(type), nullptr);	if (hFile == INVALID_HANDLE_VALUE)	{		OutputDebugStringW(L"Something is wrong:/n");		auto error = GetLastError();		switch (error)		{		case ERROR_FILE_EXISTS:			OutputDebugStringW(L"File already exists./n");			throw FileAlreadyExistsException();		case ERROR_FILE_NOT_FOUND:			OutputDebugStringW(L"File not found./n");			throw FileNotFoundException();		case ERROR_SHARING_VIOLATION:			OutputDebugStringW(L"File cannot be shared./n");			throw FileSharingViolationException();		default:			OutputDebugStringW(L"Reason is not defined./n");			throw FileException();		}	}}
开发者ID:kazami-yuuji,项目名称:ZariDB,代码行数:26,


示例7: throw

void DirectoryListing::loadFile(const string& name) throw(FileException, SimpleXMLException) {	string txt;	// For now, we detect type by ending...	string ext = Util::getFileExt(name);	if(Util::stricmp(ext, ".bz2") == 0) {		::File ff(name, ::File::READ, ::File::OPEN);		FilteredInputStream<UnBZFilter, false> f(&ff);		const size_t BUF_SIZE = 64*1024;		AutoArray<char> buf(BUF_SIZE);		size_t len;		size_t bytesRead = 0;		for(;;) {			size_t n = BUF_SIZE;			len = f.read(buf, n);			txt.append(buf, len);			bytesRead += len;			if(SETTING(MAX_FILELIST_SIZE) && bytesRead > (size_t)SETTING(MAX_FILELIST_SIZE)*1024*1024)				break;			if(len < BUF_SIZE)				break;		}	} else if(Util::stricmp(ext, ".xml") == 0) {		int64_t sz = ::File::getSize(name);		if(sz == -1 || sz >= static_cast<int64_t>(txt.max_size()))			throw(FileException(CSTRING(FILE_NOT_AVAILABLE)));		txt.resize((size_t) sz);		size_t n = txt.length();		::File(name, ::File::READ, ::File::OPEN).read(&txt[0], n);	}	loadXML(txt, false);}
开发者ID:BackupTheBerlios,项目名称:ldcpp-svn,代码行数:34,


示例8: GetLastError

void SerialChannelImpl::handleError(const std::string& name){	std::string errorText;	DWORD error = GetLastError();	switch (error)	{	case ERROR_FILE_NOT_FOUND:		throw FileNotFoundException(name, getErrorText(errorText));	case ERROR_ACCESS_DENIED:		throw FileAccessDeniedException(name, getErrorText(errorText));	case ERROR_ALREADY_EXISTS:	case ERROR_FILE_EXISTS:		throw FileExistsException(name, getErrorText(errorText));	case ERROR_FILE_READ_ONLY:		throw FileReadOnlyException(name, getErrorText(errorText));	case ERROR_CANNOT_MAKE:	case ERROR_INVALID_NAME:	case ERROR_FILENAME_EXCED_RANGE:		throw CreateFileException(name, getErrorText(errorText));	case ERROR_BROKEN_PIPE:	case ERROR_INVALID_USER_BUFFER:	case ERROR_INSUFFICIENT_BUFFER:		throw IOException(name, getErrorText(errorText));	case ERROR_NOT_ENOUGH_MEMORY:		throw OutOfMemoryException(name, getErrorText(errorText));	case ERROR_HANDLE_EOF: break;	default:		throw FileException(name, getErrorText(errorText));	}}
开发者ID:RangelReale,项目名称:sandbox,代码行数:31,


示例9: GzFileWriter

	GzFileWriter(const std::string &filename) {		file = gzopen(filename.c_str(), "wb9");		if (!file) {			fprintf(stderr, "Can't open file '%s' for writing/n", filename.c_str());			throw FileException();		}	}
开发者ID:realhidden,项目名称:stratagus,代码行数:7,


示例10: GetLastError

void FileImpl::handleLastErrorImpl(const std::string& path){	DWORD err = GetLastError();	switch (err)	{	case ERROR_FILE_NOT_FOUND:		throw FileNotFoundException(path, err);	case ERROR_PATH_NOT_FOUND:	case ERROR_BAD_NETPATH:	case ERROR_CANT_RESOLVE_FILENAME:	case ERROR_INVALID_DRIVE:		throw PathNotFoundException(path, err);	case ERROR_ACCESS_DENIED:		throw FileAccessDeniedException(path, err);	case ERROR_ALREADY_EXISTS:	case ERROR_FILE_EXISTS:		throw FileExistsException(path, err);	case ERROR_INVALID_NAME:	case ERROR_DIRECTORY:	case ERROR_FILENAME_EXCED_RANGE:	case ERROR_BAD_PATHNAME:		throw PathSyntaxException(path, err);	case ERROR_FILE_READ_ONLY:		throw FileReadOnlyException(path, err);	case ERROR_CANNOT_MAKE:		throw CreateFileException(path, err);	case ERROR_DIR_NOT_EMPTY:		throw FileException("directory not empty", path, err);	case ERROR_WRITE_FAULT:		throw WriteFileException(path, err);	case ERROR_READ_FAULT:		throw ReadFileException(path, err);	case ERROR_SHARING_VIOLATION:		throw FileException("sharing violation", path, err);	case ERROR_LOCK_VIOLATION:		throw FileException("lock violation", path, err);	case ERROR_HANDLE_EOF:		throw ReadFileException("EOF reached", path, err);	case ERROR_HANDLE_DISK_FULL:	case ERROR_DISK_FULL:		throw WriteFileException("disk is full", path, err);	case ERROR_NEGATIVE_SEEK:		throw FileException("negative seek", path, err);	default:		throw FileException(path, err);	}}
开发者ID:9drops,项目名称:poco,代码行数:47,


示例11: dcassert

void File::setEOF(){	dcassert(isOpen());	if (!SetEndOfFile(h))	{		throw FileException(Util::translateError(GetLastError()));	}}
开发者ID:snarkus,项目名称:flylinkdc-r5xx,代码行数:8,


示例12: FileException

std::size_t FileInputStream::available() const{	long temp = std::ftell(_fp);	if (temp == -1L)		throw FileException();	return _fileSize - temp;}
开发者ID:kpaleniu,项目名称:polymorph-td,代码行数:8,


示例13: FileException

unsigned intReadableFromZCSV::read(const std::string& string, unsigned int pos, ReadableFromZCSV* data){  pos = data->readFromString(string, pos);  if (static_cast<int>(pos) < 0)    throw FileException(m_fileName, "Failed to read an element.");  return (pos);}
开发者ID:Aracthor,项目名称:super_zappy,代码行数:8,


示例14: throw

void File::movePos(int64_t pos) throw(FileException){	// [!] IRainman use SetFilePointerEx function!	LARGE_INTEGER x = {0};	x.QuadPart = pos;	if (!::SetFilePointerEx(h, x, &x, FILE_CURRENT))		throw(FileException(Util::translateError(GetLastError()))); //[+]PPA}
开发者ID:snarkus,项目名称:flylinkdc-r5xx,代码行数:8,


示例15: FileException

void utils::File::Write(const void * data, zuint32 count) const{	zuint32l bytesWritten = 0;	if (!WriteFile(hFile, data, count, &bytesWritten, nullptr))	{		throw FileException();	}}
开发者ID:kazami-yuuji,项目名称:ZariDB,代码行数:8,


示例16: WP5VariableLengthGroup_SubGroup

WP5DefinitionGroup_DefineTablesSubGroup::WP5DefinitionGroup_DefineTablesSubGroup(librevenge::RVNGInputStream *input, WPXEncryption *encryption, unsigned short subGroupSize) :	WP5VariableLengthGroup_SubGroup(),	m_position(0),	m_numColumns(0),	m_leftOffset(0),	m_leftGutter(0),	m_rightGutter(0){	long startPosition = input->tell();	// Skip useless old values to read the old column number	input->seek(2, librevenge::RVNG_SEEK_CUR);	m_numColumns = readU16(input, encryption);	// Skip to new values	input->seek(20+(5*m_numColumns), librevenge::RVNG_SEEK_CUR);	// Read the new values	unsigned char tmpFlags = readU8(input, encryption);	m_position = tmpFlags & 0x07;	input->seek(1, librevenge::RVNG_SEEK_CUR);	m_numColumns = readU16(input, encryption);	input->seek(4, librevenge::RVNG_SEEK_CUR);	m_leftGutter = readU16(input, encryption);	m_rightGutter = readU16(input, encryption);	input->seek(10, librevenge::RVNG_SEEK_CUR);	m_leftOffset = readU16(input, encryption);	int i;	if ((m_numColumns > 32) || ((input->tell() - startPosition + m_numColumns*5) > (subGroupSize - 4)))		throw FileException();	for (i=0; i < m_numColumns; i++)	{		if (input->isEnd())			throw FileException();		m_columnWidth[i] = readU16(input, encryption);	}	for (i=0; i < m_numColumns; i++)	{		if (input->isEnd())			throw FileException();		m_attributeBits[i] = readU16(input, encryption);	}	for (i=0; i < m_numColumns; i++)	{		if (input->isEnd())			throw FileException();		m_columnAlignment[i] = readU8(input, encryption);	}}
开发者ID:Distrotech,项目名称:libpwd,代码行数:46,


示例17: open

////// /brief DeviceManager::OpenDeviceFile Открывает файл устройтсва по заданному имени/// /param fileName Имя файла///void DeviceManager::OpenDeviceFile(const std::string& fileName){    deviceFileDescriptor = open(fileName.c_str(),O_RDWR);    if (deviceFileDescriptor < 0)    {        throw FileException("Error open file: no such file! Kernel module was not loaded!");    }}
开发者ID:ValeriyaSyomina,项目名称:MouseListener,代码行数:12,


示例18: FileException

std::string File::readString() {	if (!_file)		throw FileException("File is not open");	if ((_mode & FILEMODE_READ) == 0)		throw FileException("Tried to read from file opened in write mode (" + _name.getFullPath() + ")");	std::string s;	try {		char c;		while ((c = readByte())) {			s += c;		}	} catch (FileException &) {		// pass, we reached EOF	}	return s;}
开发者ID:Botje,项目名称:residualvm-tools,代码行数:18,


示例19: ftell

long FileInputStream::getReadPosition() const{	long rVal = ftell(_fp);	if (rVal == -1L)		throw FileException();	return rVal;}
开发者ID:kpaleniu,项目名称:polymorph-td,代码行数:9,


示例20: fs_item

Item::Item(std::string filename) {    std::ifstream fs_item (filename);    if (!fs_item.good()) {        throw FileException("File '" + filename + "' not found or is empty");    }    std::getline(fs_item, name);    std::getline(fs_item, description);    debug_println(BIT6,"Item created from file '" << filename << "' has name set to " << name << " and description set to " << description);}
开发者ID:kwabe007,项目名称:spel-spelet,代码行数:10,


示例21: checkTrees

	void checkTrees() throw(FileException) {		while(cur.getLeaves().size() > verified) {			if(cur.getLeaves().size() > real.getLeaves().size() ||				!(cur.getLeaves()[verified] == real.getLeaves()[verified])) 			{				throw FileException(STRING(TTH_INCONSISTENCY));			}			verified++;		}	}
开发者ID:BackupTheBerlios,项目名称:linuxdcpp,代码行数:10,


示例22: SetFilePointer

void utils::File::Seek(zint64 position) const{	zint32 low = position & 0xFFFFFFFF;	zint32l high = position >> 32;	auto result = SetFilePointer(hFile, low, &high, FILE_BEGIN);	if (result == INVALID_SET_FILE_POINTER)	{		throw FileException();	}}
开发者ID:kazami-yuuji,项目名称:ZariDB,代码行数:10,


示例23: SeekToBegin

 void File::FileImpl::SeekTo(unsigned long pos) {   if (!pos)   {     SeekToBegin();     return;   }   if (SetFilePointer(FileHandle, static_cast<LONG>(pos), 0, FILE_CURRENT) == INVALID_SET_FILE_POINTER)     throw FileException("Can't seek to mew position"); }
开发者ID:Diego160289,项目名称:cross-fw,代码行数:10,


示例24: fwrite

        size_t File::Write(BYTE* in, size_t len)        {            size_t _len = 0;            _len = fwrite(in, sizeof(BYTE), len, m_handle);            if(_len != len)                throw FileException(m_path, errno);                            return _len;        }
开发者ID:JamesMarcil,项目名称:HatchitCore,代码行数:11,


示例25: fread

        size_t File::Read(BYTE* out, size_t len)        {            size_t _len = 0;            _len = fread(out, sizeof(BYTE), len, m_handle);            if (_len == 0)                throw FileException(m_path, errno);            return _len;        }
开发者ID:JamesMarcil,项目名称:HatchitCore,代码行数:11,



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


C++ FileExist函数代码示例
C++ FileClose函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。