Skip to content

Commit 454de08

Browse files
committed
Merge branch 'Lib_Only_Std__FileSystem_WIP' of https://github.com/aiekick/ImGuiFileDialog into Lib_Only_Std__FileSystem_WIP
2 parents 75cb2dc + 9c61f6b commit 454de08

1 file changed

Lines changed: 38 additions & 33 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,43 +37,44 @@ SOFTWARE.
3737
#include <ctime>
3838
#include <sys/stat.h>
3939
#include <cstdio>
40+
// this option need c++17
41+
#ifdef USE_STD_FILESYSTEM
42+
#include <filesystem>
43+
#endif
4044
#if defined (__EMSCRIPTEN__) // EMSCRIPTEN
41-
#include <emscripten.h>
45+
#include <emscripten.h>
4246
#endif // EMSCRIPTEN
4347
#if defined(__WIN32__) || defined(_WIN32)
44-
#ifndef WIN32
45-
#define WIN32
46-
#endif // WIN32
47-
#define stat _stat
48-
#define stricmp _stricmp
49-
#include <cctype>
50-
// this option need c++17
51-
#ifdef USE_STD_FILESYSTEM
52-
#include <filesystem>
53-
#include <Windows.h>
54-
#else
55-
#include "dirent/dirent.h" // directly open the dirent file attached to this lib
56-
#endif // USE_STD_FILESYSTEM
57-
#define PATH_SEP '\\'
58-
#ifndef PATH_MAX
59-
#define PATH_MAX 260
60-
#endif // PATH_MAX
48+
#ifndef WIN32
49+
#define WIN32
50+
#endif // WIN32
51+
#define stat _stat
52+
#define stricmp _stricmp
53+
#include <cctype>
54+
// this option need c++17
55+
#ifdef USE_STD_FILESYSTEM
56+
#include <Windows.h>
57+
#else
58+
#include "dirent/dirent.h" // directly open the dirent file attached to this lib
59+
#endif // USE_STD_FILESYSTEM
60+
#define PATH_SEP '\\'
61+
#ifndef PATH_MAX
62+
#define PATH_MAX 260
63+
#endif // PATH_MAX
6164
#elif defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined (__EMSCRIPTEN__)
62-
#define UNIX
63-
#define stricmp strcasecmp
64-
#include <sys/types.h>
65-
// this option need c++17
66-
#ifdef USE_STD_FILESYSTEM
67-
#include <filesystem>
68-
#else
69-
#include <dirent.h>
70-
#endif // USE_STD_FILESYSTEM
71-
#define PATH_SEP '/'
65+
#define UNIX
66+
#define stricmp strcasecmp
67+
#include <sys/types.h>
68+
// this option need c++17
69+
#ifndef USE_STD_FILESYSTEM
70+
#include <dirent.h>
71+
#endif // USE_STD_FILESYSTEM
72+
#define PATH_SEP '/'
7273
#endif // defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__APPLE__)
7374

7475
#include "imgui.h"
7576
#ifndef IMGUI_DEFINE_MATH_OPERATORS
76-
#define IMGUI_DEFINE_MATH_OPERATORS
77+
#define IMGUI_DEFINE_MATH_OPERATORS
7778
#endif // IMGUI_DEFINE_MATH_OPERATORS
7879
#include "imgui_internal.h"
7980

@@ -478,8 +479,12 @@ namespace IGFD
478479
{
479480
#ifdef USE_STD_FILESYSTEM
480481
namespace fs = std::filesystem;
482+
#ifdef WIN32
481483
std::wstring wname = IGFD::Utils::string_to_wstring(name.c_str());
482484
fs::path pathName = fs::path(wname);
485+
#else
486+
fs::path pathName = fs::path(name);
487+
#endif
483488
bExists = fs::is_directory(pathName);
484489
#else
485490
DIR* pDir = nullptr;
@@ -1609,7 +1614,7 @@ namespace IGFD
16091614
#ifdef WIN32
16101615
res = *vIter + std::string(1u, PATH_SEP) + res;
16111616
#elif defined(UNIX) // UNIX is LINUX or APPLE
1612-
if (*vIter == s_fs_root)
1617+
if (*vIter == puFsRoot)
16131618
res = *vIter + res;
16141619
else
16151620
res = *vIter + PATH_SEP + res;
@@ -1697,7 +1702,7 @@ namespace IGFD
16971702
else
16981703
{
16991704
#ifdef __linux__
1700-
if (s_fs_root == prCurrentPath)
1705+
if (puFsRoot == prCurrentPath)
17011706
newPath = prCurrentPath + vInfos->fileName;
17021707
else
17031708
#endif // __linux__
@@ -1985,7 +1990,7 @@ namespace IGFD
19851990
if (!filename.empty())
19861991
{
19871992
#ifdef UNIX
1988-
if (s_fs_root != result)
1993+
if (puFsRoot != result)
19891994
#endif // UNIX
19901995
result += std::string(1u, PATH_SEP);
19911996

@@ -2004,7 +2009,7 @@ namespace IGFD
20042009
std::string result = GetResultingPath();
20052010

20062011
#ifdef UNIX
2007-
if (s_fs_root != result)
2012+
if (puFsRoot != result)
20082013
#endif // UNIX
20092014
result += std::string(1u, PATH_SEP);
20102015

0 commit comments

Comments
 (0)