Skip to content

Commit 9145728

Browse files
committed
[fix] : fix last commit (#202)
1 parent 26cda85 commit 9145728

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ SOFTWARE.
6666
defined(_WIN64) || \
6767
defined(_MSC_VER)
6868
#define _IGFD_WIN_
69-
#define stat _wstat64
69+
#define stat _stat64
7070
#define stricmp _stricmp
7171
#include <cctype>
7272
// this option need c++17
@@ -608,7 +608,9 @@ class FileSystemStd : public IGFD::IFileSystem {
608608
// date
609609
size_t len{};
610610
const auto lastWriteTime = fs::last_write_time(fpath);
611-
const auto cftime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now() + (lastWriteTime - fs::file_time_type::clock::now()));
611+
const auto sctp = std::chrono::time_point_cast<std::chrono::system_clock::duration>( //
612+
lastWriteTime - fs::file_time_type::clock::now() + std::chrono::system_clock::now());
613+
const auto cftime = std::chrono::system_clock::to_time_t(sctp);
612614
static char timebuf[100];
613615
std::strftime(timebuf, sizeof(timebuf), DateTimeFormat, std::localtime(&cftime));
614616
voDate = timebuf;
@@ -775,11 +777,12 @@ class FileSystemDirent : public IGFD::IFileSystem {
775777
case DT_UNKNOWN: {
776778
struct stat sb = {};
777779
#ifdef _IGFD_WIN_
778-
auto filePath = vPath + ent->d_name;
780+
const auto wfpn = IGFD::Utils::UTF8Decode(vPath + ent->d_name);
781+
if (!_wstati64(wfpn.c_str(), &sb)) {
779782
#else
780-
auto filePath = vPath + IGFD::Utils::GetPathSeparator() + ent->d_name;
783+
const auto fpn = vPath + IGFD::Utils::GetPathSeparator() + ent->d_name;
784+
if (!stat(fpn.c_str(), &sb)) {
781785
#endif
782-
if (!stat(filePath.c_str(), &sb)) {
783786
if (sb.st_mode & S_IFLNK) {
784787
fileType.SetSymLink(true);
785788
// by default if we can't figure out the target type.
@@ -821,15 +824,11 @@ class FileSystemDirent : public IGFD::IFileSystem {
821824
return false;
822825
}
823826
void GetFileDateAndSize(const std::string& vFilePathName, const IGFD::FileType& vFileType, std::string& voDate, size_t& voSize) override {
824-
struct stat statInfos = {};
827+
struct stat statInfos{};
828+
int32_t result{};
825829
#ifdef _IGFD_WIN_
826830
std::wstring wfpn = IGFD::Utils::UTF8Decode(vFilePathName);
827-
struct _stat64 wstatInfos{};
828-
const auto result = stat(wfpn.c_str(), &wstatInfos);
829-
if (!result) {
830-
statInfos.st_size = wstatInfos.st_size;
831-
statInfos.st_mtime = wstatInfos.st_mtime;
832-
}
831+
result = _wstati64(wfpn.c_str(), &statInfos);
833832
#else
834833
result = stat(vFilePathName.c_str(), &statInfos);
835834
#endif
@@ -4061,8 +4060,8 @@ void IGFD::FileDialog::m_DisplayPathPopup(ImVec2 vSize) {
40614060

40624061
bool IGFD::FileDialog::m_DrawOkButton() {
40634062
auto& fdFile = m_FileDialogInternal.fileManager;
4064-
if (m_FileDialogInternal.canWeContinue && strlen(fdFile.fileNameBuffer) || //
4065-
m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_OptionalFileName) { // optional
4063+
if ((m_FileDialogInternal.canWeContinue && strlen(fdFile.fileNameBuffer)) || //
4064+
(m_FileDialogInternal.getDialogConfig().flags & ImGuiFileDialogFlags_OptionalFileName)) { // optional
40664065
if (IMGUI_BUTTON(okButtonString "##validationdialog", ImVec2(okButtonWidth, 0.0f)) || m_FileDialogInternal.isOk) {
40674066
m_FileDialogInternal.isOk = true;
40684067
return true;

0 commit comments

Comments
 (0)