feat: support get file type

(#4)
This commit is contained in:
Gary Wang 2019-07-26 16:56:53 +08:00 committed by GitHub
parent 6d6c50e40e
commit fbe5ddfe93
Failed to generate hash of commit
4 changed files with 25 additions and 4 deletions

View file

@ -132,7 +132,7 @@ QExplicitlySharedDataPointer<DGioFileInfo> DGioFile::createFileSystemInfo()
QExplicitlySharedDataPointer<DGioFileInfo> fileInfoPtr(new DGioFileInfo(gmmFileInfo.release())); QExplicitlySharedDataPointer<DGioFileInfo> fileInfoPtr(new DGioFileInfo(gmmFileInfo.release()));
return fileInfoPtr; return fileInfoPtr;
} }
} catch (Glib::Error error) { } catch (const Glib::Error &error) {
qDebug() << QString::fromStdString(error.what().raw()); qDebug() << QString::fromStdString(error.what().raw());
} }

View file

@ -60,7 +60,14 @@ DGioFileInfo::~DGioFileInfo()
} }
bool DGioFileInfo::isReadOnly() const DGioFileType DGioFileInfo::fileType() const
{
Q_D(const DGioFileInfo);
return static_cast<DGioFileType>(d->getGmmFileInfoInstance()->get_file_type());
}
bool DGioFileInfo::fsReadOnly() const
{ {
Q_D(const DGioFileInfo); Q_D(const DGioFileInfo);

View file

@ -4,6 +4,17 @@
#include <QObject> #include <QObject>
#include <QSharedData> #include <QSharedData>
enum DGioFileType {
FILE_TYPE_NOT_KNOWN,
FILE_TYPE_REGULAR,
FILE_TYPE_DIRECTORY,
FILE_TYPE_SYMBOLIC_LINK,
FILE_TYPE_SPECIAL,
FILE_TYPE_SHORTCUT,
FILE_TYPE_MOUNTABLE
};
Q_ENUMS(DGioFileType);
namespace Gio { namespace Gio {
class FileInfo; class FileInfo;
} }
@ -16,8 +27,11 @@ public:
explicit DGioFileInfo(Gio::FileInfo *gmmFileInfoInfoPtr, QObject *parent = nullptr); explicit DGioFileInfo(Gio::FileInfo *gmmFileInfoInfoPtr, QObject *parent = nullptr);
~DGioFileInfo(); ~DGioFileInfo();
bool isReadOnly() const; // file info
DGioFileType fileType() const;
// filesystem info.
bool fsReadOnly() const;
quint64 fsTotalBytes() const; quint64 fsTotalBytes() const;
quint64 fsUsedBytes() const; quint64 fsUsedBytes() const;
quint64 fsFreeBytes() const; quint64 fsFreeBytes() const;

View file

@ -86,7 +86,7 @@ DGioMount *DGioMount::createFromPath(QString path, QObject *parent)
if (gmmMount) { if (gmmMount) {
return new DGioMount(gmmMount.release(), parent); return new DGioMount(gmmMount.release(), parent);
} }
} catch (Glib::Error error) { } catch (const Glib::Error &error) {
qDebug() << QString::fromStdString(error.what().raw()); qDebug() << QString::fromStdString(error.what().raw());
} }