@@ -76,15 +76,10 @@ using v8::Value;
7676# define S_ISDIR (mode ) (((mode) & S_IFMT) == S_IFDIR)
7777#endif
7878
79- #ifdef __POSIX__
80- constexpr char kPathSeparator = ' /' ;
81- #else
82- const char * const kPathSeparator = " \\ /" ;
83- #endif
84-
8579std::string Basename (const std::string& str, const std::string& extension) {
8680 // Remove everything leading up to and including the final path separator.
87- std::string::size_type pos = str.find_last_of (kPathSeparator );
81+ std::string::size_type pos =
82+ str.find_last_of (std::filesystem::path::preferred_separator);
8883
8984 // Starting index for the resulting string
9085 std::size_t start_pos = 0 ;
@@ -1614,8 +1609,10 @@ int MKDirpSync(uv_loop_t* loop,
16141609 return err;
16151610 }
16161611 case UV_ENOENT: {
1617- std::string dirname = next_path.substr (0 ,
1618- next_path.find_last_of (kPathSeparator ));
1612+ std::string dirname =
1613+ next_path.substr (0 ,
1614+ next_path.find_last_of (
1615+ std::filesystem::path::preferred_separator));
16191616 if (dirname != next_path) {
16201617 req_wrap->continuation_data ()->PushPath (std::move (next_path));
16211618 req_wrap->continuation_data ()->PushPath (std::move (dirname));
@@ -1694,8 +1691,8 @@ int MKDirpAsync(uv_loop_t* loop,
16941691 break ;
16951692 }
16961693 case UV_ENOENT: {
1697- std::string dirname = path.substr (0 ,
1698- path.find_last_of (kPathSeparator ));
1694+ std::string dirname = path.substr (
1695+ 0 , path.find_last_of (std::filesystem::path::preferred_separator ));
16991696 if (dirname != path) {
17001697 req_wrap->continuation_data ()->PushPath (path);
17011698 req_wrap->continuation_data ()->PushPath (std::move (dirname));
0 commit comments