Skip to content

Commit

Permalink
feat: [io]Files that cannot be deleted to the recycle bin pop up the …
Browse files Browse the repository at this point in the history
…Delete Completely dialog.

Files that cannot be deleted to the recycle bin pop up the Delete Completely dialog box.

Log: Files that cannot be deleted to the recycle bin pop up the Delete Completely dialog box.
Task: https://pms.uniontech.com/bug-view-182353.html
  • Loading branch information
liyigang1 authored and max-lvs committed Aug 7, 2023
1 parent f974026 commit 024ac7f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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

0 comments on commit 024ac7f

Please sign in to comment.