diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2020-01-22 04:29:44 -0500 |
|---|---|---|
| committer | isanae <14251494+isanae@users.noreply.github.com> | 2020-02-04 03:33:22 -0500 |
| commit | 7c98635edc33d74ab24352e971bb6a127e7272e8 (patch) | |
| tree | cdb6594f379a1b4c4a29bc48ca15a04cbe469e73 /src/filetreeitem.cpp | |
| parent | a55a69e6ac56dfb6851b5538e4252e9d8dab402b (diff) | |
filetype and last modified columns
Diffstat (limited to 'src/filetreeitem.cpp')
| -rw-r--r-- | src/filetreeitem.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/src/filetreeitem.cpp b/src/filetreeitem.cpp index cfcf891a..e7510279 100644 --- a/src/filetreeitem.cpp +++ b/src/filetreeitem.cpp @@ -102,8 +102,28 @@ QFont FileTreeItem::font() const const FileTreeItem::Meta& FileTreeItem::meta() const { if (!m_meta) { - QFile f(m_realPath); - m_meta = {static_cast<uint64_t>(f.size())}; + QFileInfo fi(m_realPath); + + SHFILEINFOW sfi = {}; + const auto r = SHGetFileInfoW( + m_realPath.toStdWString().c_str(), 0, &sfi, sizeof(sfi), + SHGFI_TYPENAME); + + if (!r) { + const auto e = GetLastError(); + + log::error( + "SHGetFileInfoW failed for '{}', {}", + m_realPath, e); + + sfi = {}; + } + + m_meta = { + static_cast<uint64_t>(fi.size()), + fi.lastModified(), + QString::fromWCharArray(sfi.szTypeName) + }; } return *m_meta; |
