Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions bundle-utils/src/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ namespace jetpack {
if (origin.empty()) {
return;
}
#ifndef WIN32
if (origin[0] != PATH_DIV) {
throw std::runtime_error("first char should be DIV");
#else
if (origin.length() < 2 || origin[1] != ':') {
#endif
throw std::runtime_error("path should be absolute");
}

#ifndef WIN32
std::size_t i = 1;
#else
std::size_t i = 0;
#endif
std::string buffer;

while (i < origin.size()) {
Expand Down Expand Up @@ -97,11 +105,23 @@ namespace jetpack {
[[nodiscard]] inline std::string ToString() const {
std::stringstream ss;

#ifdef WIN32
auto it = slices.begin();
// First element is the drive letter, e.g. C:
if (it != slices.end()) {
ss << *it;

while (++it != slices.end()) {
ss << PATH_DIV;
ss << *it;
}
}
#else
for (auto& item : slices) {
ss << PATH_DIV;
ss << item;
}

#endif
return ss.str();
}

Expand Down
5 changes: 5 additions & 0 deletions jetpack/src/ModuleResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,13 @@ namespace jetpack {
std::string absolutePath;
if (targetPath.empty()) {
return;
#ifndef WIN32
} else if (targetPath[0] == Path::PATH_DIV) {
absolutePath = targetPath;
#else
} else if (targetPath.length() > 1 && targetPath[1] == ':') {
absolutePath = targetPath;
#endif
} else {
Path p(utils::GetRunningDir());
p.Join(targetPath);
Expand Down