Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
quniquehandle_types.cpp
Go to the documentation of this file.
1// Copyright (C) 2024 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtCore/private/quniquehandle_types_p.h>
5
6#include "qplatformdefs.h" // For QT_CLOSE
7
8#ifdef Q_OS_WIN
9# include <QtCore/qt_windows.h>
10#endif
11
12#ifdef Q_OS_UNIX
13# include <QtCore/private/qcore_unix_p.h> // for qt_safe_close
14#endif
15
16QT_BEGIN_NAMESPACE
17
19
20#ifdef Q_OS_WIN
21
23{
24 return ::CloseHandle(handle);
25}
26
27bool NullHandleTraits::close(Type handle) noexcept
28{
29 return ::CloseHandle(handle);
30}
31
32#endif
33
35{
36 // not noexcept because close() is a POSIX cancellation point
37 return QT_CLOSE(handle) == 0;
38}
39
41{
42 // not noexcept because fclose() is a POSIX cancellation point
43 return ::fclose(handle);
44}
45
46} // namespace QtUniqueHandleTraits
47
48#ifdef Q_OS_UNIX
49
50using QUniqueFileDescriptorHandle = QUniqueHandle<QtUniqueHandleTraits::FileDescriptorHandleTraits>;
51
52#endif
53
54QT_END_NAMESPACE