forked from easymodo/qimgv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: file/dir name codec error (easymodo#354)
current method to resolve path is not corret due to encoding issues, simply using QDir/QFileInfo to replace std::filesystem and std::string.
- Loading branch information
Showing
4 changed files
with
57 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,49 @@ | ||
#include "fsentry.h" | ||
|
||
#include <QDir> | ||
|
||
FSEntry::FSEntry() { | ||
} | ||
|
||
FSEntry::FSEntry(const QString &path) { | ||
std::filesystem::directory_entry stdEntry(toStdString(path)); | ||
QString name = QString::fromStdString(stdEntry.path().filename().generic_string()); | ||
if(stdEntry.is_directory()) { | ||
try { | ||
this->name = name; | ||
this->path = path; | ||
this->isDirectory = true; | ||
} catch (const std::filesystem::filesystem_error &err) { } | ||
QFileInfo file(path); | ||
if(file.isDir()) { | ||
this->name = file.fileName(); | ||
this->path = file.absoluteFilePath(); | ||
this->isDirectory = true; | ||
} else { | ||
try { | ||
this->name = name; | ||
this->path = path; | ||
this->isDirectory = false; | ||
this->size = stdEntry.file_size(); | ||
this->modifyTime = stdEntry.last_write_time(); | ||
} catch (const std::filesystem::filesystem_error &err) { } | ||
this->name = file.fileName(); | ||
this->path = file.absoluteFilePath(); | ||
this->isDirectory = false; | ||
this->size = file.size(); | ||
this->modifyTime = file.lastModified(); | ||
} | ||
} | ||
|
||
FSEntry::FSEntry( QString _path, QString _name, std::uintmax_t _size, std::filesystem::file_time_type _modifyTime, bool _isDirectory) | ||
FSEntry::FSEntry( QString _path, QString _name, std::uintmax_t _size, QDateTime _modifyTime, bool _isDirectory) | ||
: path(_path), | ||
name(_name), | ||
size(_size), | ||
modifyTime(_modifyTime), | ||
isDirectory(_isDirectory) | ||
{ | ||
} | ||
|
||
FSEntry::FSEntry( QString _path, QString _name, std::uintmax_t _size, bool _isDirectory) | ||
: path(_path), | ||
name(_name), | ||
size(_size), | ||
isDirectory(_isDirectory) | ||
{ | ||
} | ||
|
||
FSEntry::FSEntry( QString _path, QString _name, bool _isDirectory) | ||
: path(_path), | ||
name(_name), | ||
isDirectory(_isDirectory) | ||
{ | ||
} | ||
|
||
bool FSEntry::operator==(const QString &anotherPath) const { | ||
return this->path == anotherPath; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
#pragma once | ||
#include <QString> | ||
#include <QDateTime> | ||
#include <filesystem> | ||
#include "utils/stuff.h" | ||
|
||
class FSEntry { | ||
public: | ||
FSEntry(); | ||
FSEntry( const QString &filePath); | ||
FSEntry( QString _path, QString _name, std::uintmax_t _size, std::filesystem::file_time_type _modifyTime, bool _isDirectory); | ||
FSEntry( QString _path, QString _name, std::uintmax_t _size, QDateTime _modifyTime, bool _isDirectory); | ||
FSEntry( QString _path, QString _name, std::uintmax_t _size, bool _isDirectory); | ||
FSEntry( QString _path, QString _name, bool _isDirectory); | ||
bool operator==(const QString &anotherPath) const; | ||
|
||
QString path, name; | ||
std::uintmax_t size; | ||
std::filesystem::file_time_type modifyTime; | ||
QDateTime modifyTime; | ||
bool isDirectory; | ||
}; |