From dc7a5753b934e323d4d8d13f3253cbe7ae55a111 Mon Sep 17 00:00:00 2001 From: "Hong Jen Yee (PCMan)" Date: Sun, 10 Jun 2018 00:07:31 +0800 Subject: [PATCH] Correctly handle mountable types. --- src/core/basicfilelauncher.cpp | 6 +++--- src/core/fileinfo.cpp | 4 ++-- src/core/fileinfo.h | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/basicfilelauncher.cpp b/src/core/basicfilelauncher.cpp index 0dc8208..0ae1177 100644 --- a/src/core/basicfilelauncher.cpp +++ b/src/core/basicfilelauncher.cpp @@ -30,11 +30,10 @@ bool BasicFileLauncher::launchFiles(const FileInfoList& fileInfos, GAppLaunchCon // classify files according to different mimetypes for(auto& fileInfo : fileInfos) { /* - qDebug("path: %s, type: %s, target: %s, isDir: %i, isDesktopEntry: %i", + qDebug("path: %s, type: %s, target: %s, isDir: %i, isShortcut: %i, isMountable: %i, isDesktopEntry: %i", fileInfo->path().toString().get(), fileInfo->mimeType()->name(), fileInfo->target().c_str(), - fileInfo->isDir(), fileInfo->isDesktopEntry()); + fileInfo->isDir(), fileInfo->isShortcut(), fileInfo->isMountable(), fileInfo->isDesktopEntry()); */ - if(fileInfo->isMountable()) { if(fileInfo->target().empty()) { // the mountable is not yet mounted so we have no target URI. @@ -269,6 +268,7 @@ FilePath BasicFileLauncher::handleShortcut(const FileInfoPtr& fileInfo, GAppLaun // if we know the target is a dir, we are not going to open it using other apps // for example: `network:///smb-root' is a shortcut targeting `smb:///' and it's also a dir if(fileInfo->isDir()) { + qDebug("shortcut is dir: %s", target.c_str()); return FilePath::fromPathStr(target.c_str()); } diff --git a/src/core/fileinfo.cpp b/src/core/fileinfo.cpp index b19a751..5838fe5 100644 --- a/src/core/fileinfo.cpp +++ b/src/core/fileinfo.cpp @@ -118,7 +118,8 @@ void FileInfo::setFromGFileInfo(const GObjectPtr& inf, const FilePath isDeletable_ = true; } - isShortcut_ = false; + isShortcut_ = (type == G_FILE_TYPE_SHORTCUT); + isMountable_ = (type == G_FILE_TYPE_MOUNTABLE); /* special handling for symlinks */ if(g_file_info_get_is_symlink(inf.get())) { @@ -129,7 +130,6 @@ void FileInfo::setFromGFileInfo(const GObjectPtr& inf, const FilePath switch(type) { case G_FILE_TYPE_SHORTCUT: - isShortcut_ = true; /* Falls through. */ case G_FILE_TYPE_MOUNTABLE: uri = g_file_info_get_attribute_string(inf.get(), G_FILE_ATTRIBUTE_STANDARD_TARGET_URI); diff --git a/src/core/fileinfo.h b/src/core/fileinfo.h index 8437d92..27f7508 100644 --- a/src/core/fileinfo.h +++ b/src/core/fileinfo.h @@ -150,7 +150,7 @@ class LIBFM_QT_API FileInfo { } bool isMountable() const { - return mimeType_->isMountable(); + return isMountable_; } bool isShortcut() const { @@ -238,6 +238,7 @@ class LIBFM_QT_API FileInfo { std::string target_; /* target of shortcut or mountable. */ bool isShortcut_ : 1; /* TRUE if file is shortcut type */ + bool isMountable_ : 1; /* TRUE if file is mountable type */ bool isAccessible_ : 1; /* TRUE if can be read by user */ bool isWritable_ : 1; /* TRUE if can be written to by user */ bool isDeletable_ : 1; /* TRUE if can be deleted by user */