Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qfilesystemengine_mac.mm
Go to the documentation of this file.
1// Copyright (C) 2019 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 "qplatformdefs.h"
6#include "qfile.h"
7#include "qurl.h"
8
9#include <QtCore/private/qcore_mac_p.h>
10#include <CoreFoundation/CoreFoundation.h>
11
13
14/*
15 This implementation does not enable the "put back" option in Finder
16 for the trashed object. The only way to get this is to use Finder automation,
17 which would query the user for permission to access Finder using a modal,
18 blocking dialog - which we definitely can't have in a console application.
19
20 Using Finder would also play the trash sound, which we don't want either in
21 such a core API; applications that want that can play the sound themselves.
22*/
23//static
25 QFileSystemEntry &newLocation, QSystemError &error)
26{
27#ifdef Q_OS_MACOS // desktop macOS has a trash can
29
30 QFileInfo info(source.filePath());
31 NSString *filepath = info.filePath().toNSString();
32 NSURL *fileurl = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()];
33 NSURL *resultingUrl = nil;
34 NSError *nserror = nil;
35 NSFileManager *fm = [NSFileManager defaultManager];
36 if ([fm trashItemAtURL:fileurl resultingItemURL:&resultingUrl error:&nserror] != YES) {
38 return false;
39 }
40 newLocation = QFileSystemEntry(QUrl::fromNSURL(resultingUrl).path());
41 return true;
42#else // watch, tv, iOS don't have a trash can
44 Q_UNUSED(newLocation);
46 return false;
47#endif
48}
49
static bool moveFileToTrash(const QFileSystemEntry &source, QFileSystemEntry &newLocation, QSystemError &error)
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
GLsizei GLsizei GLchar * source
GLsizei const GLchar *const * path
#define Q_UNUSED(x)
QHostInfo info
[0]