fs: remove basename in favor of std::filesystem · nodejs/node@7940db7 · GitHub
Skip to content

Commit 7940db7

Browse files
anonrigtargos
authored andcommitted
fs: remove basename in favor of std::filesystem
PR-URL: #53062 Reviewed-By: Daniel Lemire <daniel@lemire.me> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent ec44965 commit 7940db7

3 files changed

Lines changed: 3 additions & 28 deletions

File tree

src/node_errors.cc

Lines changed: 3 additions & 1 deletion

src/node_file.cc

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,6 @@ constexpr char kPathSeparator = '/';
8282
const char* const kPathSeparator = "\\/";
8383
#endif
8484

85-
std::string Basename(const std::string& str, const std::string& extension) {
86-
// Remove everything leading up to and including the final path separator.
87-
std::string::size_type pos = str.find_last_of(kPathSeparator);
88-
89-
// Starting index for the resulting string
90-
std::size_t start_pos = 0;
91-
// String size to return
92-
std::size_t str_size = str.size();
93-
if (pos != std::string::npos) {
94-
start_pos = pos + 1;
95-
str_size -= start_pos;
96-
}
97-
98-
// Strip away the extension, if any.
99-
if (str_size >= extension.size() &&
100-
str.compare(str.size() - extension.size(),
101-
extension.size(), extension) == 0) {
102-
str_size -= extension.size();
103-
}
104-
105-
return str.substr(start_pos, str_size);
106-
}
107-
10885
inline int64_t GetOffset(Local<Value> value) {
10986
return IsSafeJsInt(value) ? value.As<Integer>()->Value() : -1;
11087
}

src/node_internals.h

Lines changed: 0 additions & 4 deletions

0 commit comments

Comments
 (0)