Index: libcxx/src/filesystem/operations.cpp =================================================================== --- libcxx/src/filesystem/operations.cpp +++ libcxx/src/filesystem/operations.cpp @@ -1018,12 +1018,16 @@ path __current_path(error_code* ec) { ErrorHandler err("current_path", ec); +#if defined(_LIBCPP_WIN32API) + auto size = MAX_PATH; +#else auto size = ::pathconf(".", _PC_PATH_MAX); _LIBCPP_ASSERT(size >= 0, "pathconf returned a 0 as max size"); +#endif - auto buff = unique_ptr(new char[size + 1]); - char* ret; - if ((ret = ::getcwd(buff.get(), static_cast(size))) == nullptr) + auto buff = unique_ptr(new path::value_type[size + 1]); + path::value_type* ret; + if ((ret = detail::getcwd(buff.get(), static_cast(size))) == nullptr) return err.report(capture_errno(), "call to getcwd failed"); return {buff.get()}; Index: libcxx/src/filesystem/posix_compat.h =================================================================== --- libcxx/src/filesystem/posix_compat.h +++ libcxx/src/filesystem/posix_compat.h @@ -277,6 +277,10 @@ } int close(int fd) { return _close(fd); } int chdir(const wchar_t *path) { return _wchdir(path); } + +wchar_t *getcwd(wchar_t *buff, size_t size) { + return _wgetcwd(buff, size); +} #else int symlink_file(const char *oldname, const char *newname) { return ::symlink(oldname, newname); @@ -288,6 +292,7 @@ using ::close; using ::fstat; using ::ftruncate; +using ::getcwd; using ::link; using ::lstat; using ::mkdir;