diff options
author | bcoe <bencoe@google.com> | 2020-01-29 10:06:44 +0300 |
---|---|---|
committer | Benjamin Coe <bencoe@google.com> | 2020-01-31 22:57:19 +0300 |
commit | 13fe56bbbbc290cbc16804994ce0ec1d25729775 (patch) | |
tree | 08d6e7fea79a897d44256b011165c5f7c3c988c0 /src/node_file-inl.h | |
parent | 43fb6ffef7a14b47d1b0ba8134102795f5017a59 (diff) |
fs: return first folder made by mkdir recursive
mkdir('/foo/bar', { recursive: true }) and mkdirSync will now return
the path of the first folder created. This matches more closely
mkdirp's behavior, and is useful for setting folder permissions.
PR-URL: https://github.com/nodejs/node/pull/31530
Refs: https://github.com/nodejs/node/issues/31481
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/node_file-inl.h')
-rw-r--r-- | src/node_file-inl.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node_file-inl.h b/src/node_file-inl.h index 390f6c74157..e9ed18a75fa 100644 --- a/src/node_file-inl.h +++ b/src/node_file-inl.h @@ -21,6 +21,12 @@ void FSContinuationData::PushPath(const std::string& path) { paths_.push_back(path); } +void FSContinuationData::MaybeSetFirstPath(const std::string& path) { + if (first_path_.empty()) { + first_path_ = path; + } +} + std::string FSContinuationData::PopPath() { CHECK_GT(paths_.size(), 0); std::string path = std::move(paths_.back()); |