コード例 #1
0
void LogFileImpl::writeImpl(const std::string& text)
{
	int rc = fputs(text.c_str(), _file);
	if (rc == EOF) throw WriteFileException(_path);
	rc = fputc('\n', _file);
	if (rc == EOF) throw WriteFileException(_path);
	rc = fflush(_file);
	if (rc == EOF) throw WriteFileException(_path);
}
コード例 #2
0
void LogFileImpl::writeImpl(const std::string& text)
{
	DWORD bytesWritten;
	BOOL res = WriteFile(_hFile, text.data(), (DWORD) text.size(), &bytesWritten, NULL);
	if (!res) throw WriteFileException(_path);
	res = WriteFile(_hFile, "\r\n", 2, &bytesWritten, NULL);
	if (!res) throw WriteFileException(_path);
	res = FlushFileBuffers(_hFile);
	if (!res) throw WriteFileException(_path);
}
コード例 #3
0
ファイル: LogFile_WIN32.cpp プロジェクト: 12307/poco
void LogFileImpl::writeImpl(const std::string& text, bool flush)
{
	if (INVALID_HANDLE_VALUE == _hFile)	createFile();

	DWORD bytesWritten;
	BOOL res = WriteFile(_hFile, text.data(), (DWORD) text.size(), &bytesWritten, NULL);
	if (!res) throw WriteFileException(_path);
	res = WriteFile(_hFile, "\r\n", 2, &bytesWritten, NULL);
	if (!res) throw WriteFileException(_path);
	if (flush)
	{
		res = FlushFileBuffers(_hFile);
		if (!res) throw WriteFileException(_path);
	}
}
コード例 #4
0
ファイル: File_WIN32.cpp プロジェクト: 9drops/poco
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);
	}
}
コード例 #5
0
ファイル: PipeImpl_WIN32.cpp プロジェクト: zdzhaoyong/PIL2
int PipeImpl::writeBytes(const void* buffer, int length)
{
    pi_assert (_writeHandle != INVALID_HANDLE_VALUE);

	DWORD bytesWritten = 0;
	if (!WriteFile(_writeHandle, buffer, length, &bytesWritten, NULL))
		throw WriteFileException("anonymous pipe");
	return bytesWritten;
}
コード例 #6
0
ファイル: LogFile_STD.cpp プロジェクト: 119/vdc
void LogFileImpl::writeImpl(const std::string& text, bool flush)
{
	_str << text;
	if (flush) 
		_str << std::endl;
	else
		_str << "\n";
	if (!_str.good()) throw WriteFileException(_path);
}
コード例 #7
0
ファイル: PipeImpl_POSIX.cpp プロジェクト: beneon/MITK
int PipeImpl::writeBytes(const void* buffer, int length)
{
	poco_assert (_writefd != -1);

	int n;
	do
	{
		n = write(_writefd, buffer, length);
	}
	while (n < 0 && errno == EINTR);
	if (n >= 0)
		return n;
	else
		throw WriteFileException("anonymous pipe");
}