| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1677,33 +1677,33 @@ static void RmSync(const FunctionCallbackInfo<Value>& args) { | |||
| 1677 | 1677 | maxRetries--; | |
| 1678 | 1678 | } | |
| 1679 | 1679 | ||
| 1680 | - // This is required since std::filesystem::path::c_str() returns different | ||
| 1681 | - // values in Windows and Unix. | ||
| 1680 | + // On Windows path::c_str() returns wide char, convert to std::string first. | ||
| 1681 | + std::string file_path_str = file_path.string(); | ||
| 1682 | + const char* path_c_str = file_path_str.c_str(); | ||
| 1682 | 1683 | #ifdef _WIN32 | |
| 1683 | - auto file_ = file_path.string().c_str(); | ||
| 1684 | 1684 | int permission_denied_error = EPERM; | |
| 1685 | 1685 | #else | |
| 1686 | - auto file_ = file_path.c_str(); | ||
| 1687 | 1686 | int permission_denied_error = EACCES; | |
| 1688 | 1687 | #endif // !_WIN32 | |
| 1689 | 1688 | ||
| 1690 | 1689 | if (error == std::errc::operation_not_permitted) { | |
| 1691 | - std::string message = "Operation not permitted: " + file_path.string(); | ||
| 1692 | - return env->ThrowErrnoException(EPERM, "rm", message.c_str(), file_); | ||
| 1690 | + std::string message = "Operation not permitted: " + file_path_str; | ||
| 1691 | + return env->ThrowErrnoException(EPERM, "rm", message.c_str(), path_c_str); | ||
| 1693 | 1692 | } else if (error == std::errc::directory_not_empty) { | |
| 1694 | - std::string message = "Directory not empty: " + file_path.string(); | ||
| 1695 | - return env->ThrowErrnoException(EACCES, "rm", message.c_str(), file_); | ||
| 1693 | + std::string message = "Directory not empty: " + file_path_str; | ||
| 1694 | + return env->ThrowErrnoException(EACCES, "rm", message.c_str(), path_c_str); | ||
| 1696 | 1695 | } else if (error == std::errc::not_a_directory) { | |
| 1697 | - std::string message = "Not a directory: " + file_path.string(); | ||
| 1698 | - return env->ThrowErrnoException(ENOTDIR, "rm", message.c_str(), file_); | ||
| 1696 | + std::string message = "Not a directory: " + file_path_str; | ||
| 1697 | + return env->ThrowErrnoException(ENOTDIR, "rm", message.c_str(), path_c_str); | ||
| 1699 | 1698 | } else if (error == std::errc::permission_denied) { | |
| 1700 | - std::string message = "Permission denied: " + file_path.string(); | ||
| 1699 | + std::string message = "Permission denied: " + file_path_str; | ||
| 1701 | 1700 | return env->ThrowErrnoException( | |
| 1702 | - permission_denied_error, "rm", message.c_str(), file_); | ||
| 1701 | + permission_denied_error, "rm", message.c_str(), path_c_str); | ||
| 1703 | 1702 | } | |
| 1704 | 1703 | ||
| 1705 | 1704 | std::string message = "Unknown error: " + error.message(); | |
| 1706 | - return env->ThrowErrnoException(UV_UNKNOWN, "rm", message.c_str(), file_); | ||
| 1705 | + return env->ThrowErrnoException( | ||
| 1706 | + UV_UNKNOWN, "rm", message.c_str(), path_c_str); | ||
| 1707 | 1707 | } | |
| 1708 | 1708 | ||
| 1709 | 1709 | int MKDirpSync(uv_loop_t* loop, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments