path conversion operators, simplify usage
parent
855a936c0f
commit
90f9285b16
24
build.cc
24
build.cc
|
@ -206,9 +206,9 @@ int main(int argc, char **argv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
auto default_lib = std::string{OSTD_SHARED_LIB.string()};
|
||||
std::string default_lib = OSTD_SHARED_LIB;
|
||||
if (build_static) {
|
||||
default_lib = std::string{OSTD_STATIC_LIB.string()};
|
||||
default_lib = OSTD_STATIC_LIB;
|
||||
}
|
||||
|
||||
auto strip = from_env_or("STRIP", "strip");
|
||||
|
@ -335,8 +335,8 @@ int main(int argc, char **argv) {
|
|||
|
||||
args.push_back("-c");
|
||||
args.push_back("-o");
|
||||
args.push_back(std::string{outp.string()});
|
||||
args.push_back(std::string{ifs});
|
||||
args.push_back(outp);
|
||||
args.push_back(ifs);
|
||||
|
||||
exec_v(args);
|
||||
|
||||
|
@ -366,8 +366,8 @@ int main(int argc, char **argv) {
|
|||
|
||||
args.push_back("-c");
|
||||
args.push_back("-o");
|
||||
args.push_back(std::string{outp.string()});
|
||||
args.push_back(std::string{ifs});
|
||||
args.push_back(outp);
|
||||
args.push_back(ifs);
|
||||
|
||||
exec_v(args);
|
||||
|
||||
|
@ -383,9 +383,9 @@ int main(int argc, char **argv) {
|
|||
add_args(args, cxxflags);
|
||||
|
||||
args.push_back("-o");
|
||||
args.push_back(std::string{output.string()});
|
||||
args.push_back(output);
|
||||
for (auto &p: files) {
|
||||
args.push_back(std::string{p.string()});
|
||||
args.push_back(p);
|
||||
}
|
||||
args.insert(args.cend(), flags.begin(), flags.end());
|
||||
|
||||
|
@ -396,7 +396,7 @@ int main(int argc, char **argv) {
|
|||
if (build_cfg == "release") {
|
||||
args.clear();
|
||||
args.push_back(strip);
|
||||
args.push_back(std::string{output.string()});
|
||||
args.push_back(output);
|
||||
exec_v(args);
|
||||
}
|
||||
};
|
||||
|
@ -414,9 +414,9 @@ int main(int argc, char **argv) {
|
|||
echo_q("AR: %s", output);
|
||||
|
||||
args.push_back("rcs");
|
||||
args.push_back(std::string{output.string()});
|
||||
args.push_back(output);
|
||||
for (auto &p: files) {
|
||||
args.push_back(std::string{p.string()});
|
||||
args.push_back(p);
|
||||
}
|
||||
|
||||
exec_v(args);
|
||||
|
@ -562,7 +562,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (build_testsuite) {
|
||||
exec_v({ "./test_runner", std::string{TEST_DIR.string()} });
|
||||
exec_v({ "./test_runner", TEST_DIR });
|
||||
}
|
||||
|
||||
io_msgs.close();
|
||||
|
|
14
ostd/path.hh
14
ostd/path.hh
|
@ -204,7 +204,7 @@ struct path {
|
|||
return path{anchor(), p_fmt};
|
||||
}
|
||||
} else {
|
||||
sep = ostd::find_last(string(), separator());
|
||||
sep = ostd::find_last(string_range{p_path}, separator());
|
||||
if (sep.empty()) {
|
||||
return *this;
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ struct path {
|
|||
if (is_absolute()) {
|
||||
return (string() != anchor());
|
||||
}
|
||||
return !ostd::find(string(), separator()).empty();
|
||||
return !ostd::find(string_range{p_path}, separator()).empty();
|
||||
}
|
||||
|
||||
detail::path_parent_range parents() const;
|
||||
|
@ -406,7 +406,15 @@ struct path {
|
|||
);
|
||||
}
|
||||
|
||||
string_range string() const noexcept {
|
||||
std::string const &string() const noexcept {
|
||||
return p_path;
|
||||
}
|
||||
|
||||
operator std::string() const {
|
||||
return p_path;
|
||||
}
|
||||
|
||||
operator string_range() const noexcept {
|
||||
return p_path;
|
||||
}
|
||||
|
||||
|
|
|
@ -289,7 +289,7 @@ OSTD_EXPORT path weakly_canonical(path const &p) {
|
|||
}
|
||||
/* cp refers to an existing section, canonicalize */
|
||||
path ret = canonical(cp);
|
||||
auto pstr = p.string();
|
||||
string_range pstr = p;
|
||||
/*a append the unresolved rest */
|
||||
ret.append(pstr.slice(cp.string().size(), pstr.size()));
|
||||
return ret;
|
||||
|
|
Loading…
Reference in New Issue