Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix mkdir for win32 #1245

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/lib/fcitx-utils/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,21 @@
#include "mtime_p.h"
#include "standardpath.h"
#include "stringutils.h"
#ifdef _WIN32
#include <direct.h>
#endif

namespace fcitx::fs {

namespace {

bool makePathHelper(const std::string &name) {
if (::mkdir(name.c_str(), 0777) == 0) {
#ifdef _WIN32
int res = _mkdir(name.c_str());
#else
int res = ::mkdir(name.c_str(), 0777);
#endif
if (res == 0) {
return true;
}
if (errno == EEXIST) {
Expand All @@ -52,7 +60,12 @@ bool makePathHelper(const std::string &name) {
}

// try again
if (::mkdir(name.c_str(), 0777) == 0) {
#ifdef _WIN32
res = _mkdir(name.c_str());
#else
res = ::mkdir(name.c_str(), 0777);
#endif
if (res == 0) {
return true;
}
return errno == EEXIST && isdir(name);
Expand Down
Loading