bool CIOThread::DoWrite(const char* pBuffer, int64_t len)
{
	auto written = m_pFile->write(pBuffer, len);
	if (written == len) {
		return true;
	}

	auto err = GetSystemErrorCode();

	std::wstring const error = fz::to_wstring(GetSystemErrorDescription(err));

	fz::scoped_lock locker(m_mutex);
	m_error_description = error;

	return false;
}
Exemple #2
0
CZipString CZipException::GetInternalErrorDescription(int iCause, bool bNoLoop)
{
	CZipString sz;
	switch (iCause)
	{
		case EROFS:
			sz = _T("Read-only file system");
			break;
		case ESPIPE:
			sz = _T("Illegal seek");
			break;
		case ENOSPC:
			sz = _T("No space left on device");
			break;
		case EFBIG:
			sz = _T("File too large");
			break;
		case EMFILE:
			sz = _T("Too many open files");
			break;
		case ENFILE:
			sz = _T("File table overflow");
			break;
		case EINVAL:
			sz = _T("Invalid argument");
			break;
		case EISDIR:
			sz = _T("Is a directory");
			break;
		case ENOTDIR:
			sz = _T("Not a directory");
			break;
		case ENODEV:
			sz = _T("No such device");
			break;
		case EXDEV:
			sz = _T("Cross-device link");
			break;
		case EEXIST:
			sz = _T("File exists");
			break;
		case EFAULT:
			sz = _T("Bad address");
			break;
		case EACCES:
			sz = _T("Permission denied");
			break;
		case ENOMEM:
			sz = _T("Not enough space");
			break;
		case EBADF:
			sz = _T("Bad file number");
			break;
		case ENXIO:
			sz = _T("No such device or address");
			break;
		case EIO:
			sz = _T("I/O error");
			break;
		case EINTR:
			sz = _T("Interrupted system call");
			break;
		case ENOENT:
			sz = _T("No such file or directory");
			break;
		case EPERM:
			sz = _T("Not super-user");
			break;
		case badZipFile:
			sz = _T("Damaged or not a zip file");
			break;
		case badCrc:
			sz = _T("Crc mismatched");
			break;
		case noCallback:
			sz = _T("No disk-spanning callback functor set");
			break;
		case aborted:
			sz = _T("Disk change aborted");
			break;
		case abortedAction:
			sz = _T("Action aborted");
			break;
		case abortedSafely:
			sz = _T("Action aborted safely");
			break;
		case nonRemovable:
			sz = _T("The device selected for the disk spanning archive is non removable");
			break;
		case tooManyVolumes:
			sz = _T("Limit of the maximum volumes reached (999)");
			break;
		case tooLongFileName:
			sz = _T("The filename of the file being added to the archive is too long");
			break;
		case badPassword:
			sz = _T("Incorrect password set for the file being decrypted");
			break;
		case dirWithSize:
			sz = _T("During testing found the directory with the size greater than 0");
			break;
		case internal:
			sz = _T("Internal error");
			break;
		case notRemoved:
			sz.Format(_T("%s (%s)"), _T("Error while removing a file"), (LPCTSTR)GetSystemErrorDescription());
			break;
		case notRenamed:
			sz.Format(_T("%s (%s)"), _T("Error while renaming a file"), (LPCTSTR)GetSystemErrorDescription());
			break;
		case platfNotSupp:
			sz = _T("Cannot create the file for the specified platform");
			break;
		case cdirNotFound:
			sz = _T("The central directory was not found in the archive (or you were trying to open not the last disk of a multi-disk archive)");
			break;
		case streamEnd:
			sz = _T("Zlib Library error (end of stream)");
			break;
		case errNo:
			sz = GetInternalErrorDescription(errno != errNo ? errno : generic);
			break;
		case streamError:
			sz = _T("Zlib library error (stream error)");
			break;
		case dataError:
			sz = _T("Zlib library error (data error)");
			break;
		case memError:
			sz = _T("Not enough memory");
			break;
		case bufError:
			sz = _T("Zlib library error (buffer error)");
			break;
		case versionError:
			sz = _T("Zlib library error (version error)");
			break;
		default:
			sz = bNoLoop ? _T("Unknown error") :(LPCTSTR) GetSystemErrorDescription();
	}
	return sz;
}