@@ -82,12 +82,6 @@ using v8::Value;
8282# define S_ISDIR (mode ) (((mode) & S_IFMT) == S_IFDIR)
8383#endif
8484
85- #ifdef __POSIX__
86- constexpr char kPathSeparator = ' /' ;
87- #else
88- const char * const kPathSeparator = " \\ /" ;
89- #endif
90-
9185inline int64_t GetOffset (Local<Value> value) {
9286 return IsSafeJsInt (value) ? value.As <Integer>()->Value () : -1 ;
9387}
@@ -1639,9 +1633,9 @@ int MKDirpSync(uv_loop_t* loop,
16391633 return err;
16401634 }
16411635 case UV_ENOENT: {
1642- std::string dirname = next_path. substr ( 0 ,
1643- next_path. find_last_of ( kPathSeparator ));
1644- if ( dirname != next_path) {
1636+ auto filesystem_path = std::filesystem::path (next_path);
1637+ if (filesystem_path. has_parent_path ()) {
1638+ std::string dirname = filesystem_path. parent_path (). string ();
16451639 req_wrap->continuation_data ()->PushPath (std::move (next_path));
16461640 req_wrap->continuation_data ()->PushPath (std::move (dirname));
16471641 } else if (req_wrap->continuation_data ()->paths ().empty ()) {
@@ -1719,9 +1713,9 @@ int MKDirpAsync(uv_loop_t* loop,
17191713 break ;
17201714 }
17211715 case UV_ENOENT: {
1722- std::string dirname = path. substr ( 0 ,
1723- path. find_last_of ( kPathSeparator ));
1724- if ( dirname != path) {
1716+ auto filesystem_path = std::filesystem:: path(path);
1717+ if (filesystem_path. has_parent_path ()) {
1718+ std::string dirname = filesystem_path. parent_path (). string ();
17251719 req_wrap->continuation_data ()->PushPath (path);
17261720 req_wrap->continuation_data ()->PushPath (std::move (dirname));
17271721 } else if (req_wrap->continuation_data ()->paths ().empty ()) {
0 commit comments