本文整理汇总了C++中IsOpened函数的典型用法代码示例。如果您正苦于以下问题:C++ IsOpened函数的具体用法?C++ IsOpened怎么用?C++ IsOpened使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsOpened函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxCHECK_MSG
bool wxDir::GetFirst(wxString *filename,
const wxString& filespec,
int flags) const
{
wxCHECK_MSG( IsOpened(), false, wxT("must wxDir::Open() first") );
M_DIR->Rewind();
M_DIR->SetFileSpec(filespec);
M_DIR->SetFlags(flags);
return GetNext(filename);
}
示例2: UNREFERENCED_PARAMETER
void CLCDOutput::OnDisconnecting(int hConnection)
{
UNREFERENCED_PARAMETER(hConnection);
LOGITRACE(_T("CLCDOutput::OnDisconnecting\n"));
// let's hope our device is already gone
LOGIASSERT(!IsOpened());
if (LGLCD_INVALID_CONNECTION != m_hConnection)
{
lgLcdDisconnect(m_hConnection);
m_hConnection = LGLCD_INVALID_CONNECTION;
}
}
示例3: MULE_VALIDATE_STATE
bool CFile::SetLength(size_t new_len)
{
MULE_VALIDATE_STATE(IsOpened(), wxT("CFile: Cannot set length when no file is open."));
#ifdef __WXMSW__
int result = chsize(m_fd, new_len);
#else
int result = ftruncate(m_fd, new_len);
#endif
SYSCALL_CHECK((result != -1), wxT("truncating file"));
return (result != -1);
}
示例4: Flush
bool wxFFile::Flush()
{
if ( IsOpened() )
{
if ( fflush(m_fp) != 0 )
{
wxLogSysError(_("failed to flush the file '%s'"), m_name.c_str());
return false;
}
}
return true;
}
示例5: DropTables
void CompilationDatabase::DropTables()
{
if(!IsOpened()) return;
try {
// Create the schema
m_db->ExecuteUpdate("DROP TABLE COMPILATION_TABLE");
m_db->ExecuteUpdate("DROP TABLE SCHEMA_VERSION");
} catch(wxSQLite3Exception& e) {
wxUnusedVar(e);
}
}
示例6: UNREFERENCED_PARAMETER
void CLCDOutput::OnDisconnecting(int hConnection)
{
UNREFERENCED_PARAMETER(hConnection);
LCDUITRACE(_T("CLCDOutput::OnDisconnecting\n"));
// let's hope our device is already gone
LCDUIASSERT(!IsOpened());
if (LGLCD_INVALID_CONNECTION != m_hConnection)
{
lgLcdDisconnect(m_hConnection);
m_hConnection = LGLCD_INVALID_CONNECTION;
ZeroMemory(m_pLastBitmap, sizeof(lgLcdBitmap160x43x1));
}
}
示例7: Bind
void TCPSocket::Bind( const sockaddr_in& addr )
{
int error;
if (!IsOpened())
{
throw TCPException("Socket::bind","Socket没有打开");
}
const sockaddr* socketAddress = reinterpret_cast<const sockaddr*>(&addr);
error = ::bind(m_descriptor,socketAddress,sizeof(addr));
if(error == SOCKET_ERROR )
{
throw TCPException("Socket::bind","绑定Socket失败",error);
}
}
示例8: throw
void TCPSocket::Connect( const sockaddr_in& addr ) throw(TCPException)
{
int error;
if(!IsOpened())
{
throw TCPException("Socket::connect", "Socket没有打开");
}
const sockaddr* socketAddress = reinterpret_cast<const sockaddr*>(&addr);
error = ::connect(m_descriptor, socketAddress, sizeof(addr));
if (error == SOCKET_ERROR)
{
//throw TCPException("Socket::connect","Socket连接出错",error);
}
}
示例9: wxCHECK
// read
ssize_t wxFile::Read(void *pBuf, size_t nCount)
{
wxCHECK( (pBuf != NULL) && IsOpened(), 0 );
ssize_t iRc = wxRead(m_fd, pBuf, nCount);
if ( CheckForError(iRc) )
{
wxLogSysError(_("can't read from file descriptor %d"), m_fd);
return wxInvalidOffset;
}
return iRc;
}
示例10: GetOvelappedIoResult
bool AdbIOCompletion::GetOvelappedIoResult(LPOVERLAPPED ovl_data,
ULONG* bytes_transferred,
bool wait) {
if (NULL != bytes_transferred)
*bytes_transferred = 0;
if (!IsOpened()) {
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
ULONG transfer;
bool ret = GetOverlappedResult(parent_io_object()->usb_handle(),
overlapped(),
&transfer,
wait) ? true :
false;
// TODO: This is bizzare but I've seen it happening
// that GetOverlappedResult with wait set to true returns "prematurely",
// with wrong transferred bytes value and GetLastError reporting
// ERROR_IO_PENDING. So, lets give it an up to a 20 ms loop!
ULONG error = GetLastError();
if (wait && ret && (0 == transfer) && (0 != expected_transfer_size_) &&
((ERROR_IO_INCOMPLETE == error) || (ERROR_IO_PENDING == error))) {
for (int trying = 0; trying < 10; trying++) {
Sleep(2);
ret = GetOverlappedResult(parent_io_object()->usb_handle(),
overlapped(),
&transfer,
wait) ? true :
false;
error = GetLastError();
if (!ret || (0 != transfer) ||
((ERROR_IO_INCOMPLETE != error) && (ERROR_IO_PENDING != error))) {
break;
}
}
}
if (NULL != ovl_data)
CopyMemory(ovl_data, overlapped(), sizeof(OVERLAPPED));
if (NULL != bytes_transferred)
*bytes_transferred = is_write_ioctl() ? transferred_bytes_ : transfer;
return ret;
}
示例11: GetUsbDeviceDescriptor
bool AdbInterfaceObject::GetUsbDeviceDescriptor(USB_DEVICE_DESCRIPTOR* desc) {
if (!IsOpened()) {
SetLastError(ERROR_INVALID_HANDLE);
return false;
}
if (NULL == desc) {
SetLastError(ERROR_INVALID_PARAMETER);
return false;
}
CopyMemory(desc, usb_device_descriptor(), sizeof(USB_DEVICE_DESCRIPTOR));
return true;
}
示例12: MULE_VALIDATE_STATE
sint64 CFile::doSeek(sint64 offset) const
{
MULE_VALIDATE_STATE(IsOpened(), wxT("Cannot seek on closed file."));
MULE_VALIDATE_PARAMS(offset >= 0, wxT("Invalid position, must be positive."));
sint64 result = SEEK_FD(m_fd, offset, SEEK_SET);
if (result == offset) {
return result;
} else if (result == wxInvalidOffset) {
throw CSeekFailureException(wxString(wxT("Seeking failed: ")) + wxSysErrorMsg());
} else {
throw CSeekFailureException(wxT("Seeking returned incorrect position"));
}
}
示例13: Close
// close
bool wxFile::Close()
{
if ( IsOpened() ) {
if ( CheckForError(wxClose(m_fd)) )
{
wxLogSysError(_("can't close file descriptor %d"), m_fd);
m_fd = fd_invalid;
return false;
}
else
m_fd = fd_invalid;
}
return true;
}
示例14: wxConstCast
bool wxPipeInputStream::CanRead() const
{
// we can read if there's something in the put back buffer
// even pipe is closed
if ( m_wbacksize > m_wbackcur )
return true;
wxPipeInputStream * const self = wxConstCast(this, wxPipeInputStream);
if ( !IsOpened() )
{
// set back to mark Eof as it may have been unset by Ungetch()
self->m_lasterror = wxSTREAM_EOF;
return false;
}
DWORD nAvailable;
// function name is misleading, it works with anon pipes as well
DWORD rc = ::PeekNamedPipe
(
m_hInput, // handle
NULL, 0, // ptr to buffer and its size
NULL, // [out] bytes read
&nAvailable, // [out] bytes available
NULL // [out] bytes left
);
if ( !rc )
{
if ( ::GetLastError() != ERROR_BROKEN_PIPE )
{
// unexpected error
wxLogLastError(wxT("PeekNamedPipe"));
}
// don't try to continue reading from a pipe if an error occurred or if
// it had been closed
::CloseHandle(m_hInput);
self->m_hInput = INVALID_HANDLE_VALUE;
self->m_lasterror = wxSTREAM_EOF;
nAvailable = 0;
}
return nAvailable != 0;
}
示例15: assert
int Tcp::Connect(/* [in] */ const Address &addr,
/* [in] */ OutConnectHandler *handler)
{
assert(IsOpened());
int result = uv_tcp_connect(&m_connectReq,
*this,
addr,
OnConnected);
if(! result) {
Ref();
m_pOutConnectHandler = handler;
}
return result;
}