Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [io]Files that cannot be deleted to the recycle bin pop up the Delete Completely dialog. #38

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/dfm-io/dfm-io/dfmio_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class DFMUtils
static DEnumeratorFuture *asyncTrashCount();
static int syncTrashCount();
static qint64 deviceBytesFree(const QUrl &url);
static bool supportTrash(const QUrl &url);

private:
static QMap<QString, QString>
Expand Down
28 changes: 28 additions & 0 deletions src/dfm-io/dfm-io/dfmio_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <gio/gio.h>
#include <gio-unix-2.0/gio/gunixmounts.h>
#include <glib/gstdio.h>

#include <QUrl>
#include <QSet>
Expand Down Expand Up @@ -306,6 +307,33 @@ qint64 DFMUtils::deviceBytesFree(const QUrl &url)
}
}

bool dfmio::DFMUtils::supportTrash(const QUrl &url)
{
if (!url.isValid())
return false;

auto path = url.path();
GStatBuf file_stat, home_stat;
if (g_stat (path.toStdString().data(), &file_stat) != 0)
return false;

const char *homedir = g_get_home_dir ();
g_stat (homedir, &home_stat);
// 和当前用的主目录在同一挂载点
if (file_stat.st_dev == home_stat.st_dev)
return true;

g_autoptr(GFile) gfile = g_file_new_for_uri(url.toString().toLocal8Bit().data());
g_autofree char *path1 = g_file_get_path(gfile);
if (!path1)
return false;
g_autoptr(GUnixMountEntry) mount = g_unix_mount_for(path1, nullptr);
if (mount == nullptr || g_unix_mount_is_system_internal (mount))
return false;

return true;
}

QMap<QString, QString> DFMUtils::fstabBindInfo()
{
static QMutex mutex;
Expand Down
Loading