Esempio n. 1
0
static Status OpenFile(const OsPath& pathname, int oflag, HANDLE& hFile)
{
	WinScopedPreserveLastError s;

	const DWORD access = DesiredAccess(oflag);
	const DWORD share  = ShareMode(oflag);
	const DWORD create = CreationDisposition(oflag);
	const DWORD flags  = FlagsAndAttributes();
	hFile = CreateFileW(OsString(pathname).c_str(), access, share, 0, create, flags, 0);
	if(hFile == INVALID_HANDLE_VALUE)
		WARN_RETURN(StatusFromWin());

	return INFO::OK;
}
Esempio n. 2
0
Status sys_cursor_free(sys_cursor cursor)
{
	// bail now to prevent potential confusion below; there's nothing to do.
	if(!cursor)
		return INFO::OK;

	// if the cursor being freed is active, restore the default arrow
	// (just for safety).
	if(cursor_from_HCURSOR(GetCursor()) == cursor)
		WARN_IF_ERR(sys_cursor_set(0));

	if(!DestroyIcon(HICON_from_cursor(cursor)))
		WARN_RETURN(StatusFromWin());
	return INFO::OK;
}
Esempio n. 3
0
Status PollCompletionPort(HANDLE hIOCP, DWORD timeout, DWORD& bytesTransferred, ULONG_PTR& key, OVERLAPPED*& ovl)
{
	if(hIOCP == 0)
		return ERR::INVALID_HANDLE;	// NOWARN (happens if called before the first Attach)

	WinScopedPreserveLastError s;

	bytesTransferred = 0;
	key = 0;
	ovl = 0;
	if(GetQueuedCompletionStatus(hIOCP, &bytesTransferred, &key, &ovl, timeout))
		return INFO::OK;
	const Status ret = StatusFromWin();
	if(ret == ERR::AGAIN || ret == ERR::ABORTED)	// avoid polluting last error
		SetLastError(0);
	return ret;	// NOWARN (let caller decide what to do)
}