Skip to content

Commit f4b171e

Browse files
authored
Merge pull request RetroShare#202 from jolavillette/FixMing64FailingOnDirectoryNamesWithTrailingSlash
rsdir.cc: remove trailing slash/backslash in directory names to avoid mingw64 _wstat fail
2 parents 30c85bd + 82aced1 commit f4b171e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/util/rsdir.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,12 @@ bool RsDirUtil::checkDirectory(const std::string& dir)
520520
int val;
521521
mode_t st_mode;
522522
#ifdef WINDOWS_SYS
523+
std::string fixed = dir;
523524
std::wstring wdir;
524-
librs::util::ConvertUtf8ToUtf16(dir, wdir);
525+
// mingw64 _wstat fails when the directory name has trailing slash or backslash: we remove them
526+
while (!fixed.empty() && (fixed.back() == '\\' || fixed.back() == '/'))
527+
fixed.pop_back();
528+
librs::util::ConvertUtf8ToUtf16(fixed, wdir);
525529
struct _stat buf;
526530
val = _wstat(wdir.c_str(), &buf);
527531
st_mode = buf.st_mode;

0 commit comments

Comments
 (0)