當前位置: 首頁>>代碼示例>>C++>>正文


C++ FileException函數代碼示例

本文整理匯總了C++中FileException函數的典型用法代碼示例。如果您正苦於以下問題:C++ FileException函數的具體用法?C++ FileException怎麽用?C++ FileException使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了FileException函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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,代碼來源:FileImpl.cpp

示例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,代碼來源:file.cpp

示例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,代碼來源:File.cpp

示例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,代碼來源:File_VMS.cpp

示例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,代碼來源:datasource_filereader.cpp

示例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,代碼來源:File.cpp

示例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,代碼來源:DirectoryListing.cpp

示例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,代碼來源:SerialChannel_WIN32U.cpp

示例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,代碼來源:iolib.cpp

示例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,代碼來源:File_WIN32.cpp

示例11: dcassert

void File::setEOF()
{
	dcassert(isOpen());
	if (!SetEndOfFile(h))
	{
		throw FileException(Util::translateError(GetLastError()));
	}
}
開發者ID:snarkus,項目名稱:flylinkdc-r5xx,代碼行數:8,代碼來源:File.cpp

示例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,代碼來源:FileInputStream.cpp

示例13: FileException

unsigned int
ReadableFromZCSV::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,代碼來源:ReadableFromZCSV.cpp

示例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,代碼來源:File.cpp

示例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,代碼來源:File.cpp


注:本文中的FileException函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。