0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 23:44:01 +01:00

modules/console: Simplify proc cmd listing output.

This commit is contained in:
Jason Volk 2018-12-15 19:21:14 -08:00
parent da97535713
commit 183af6a449

View file

@ -645,16 +645,23 @@ console_cmd__proc(opt &out, const string_view &line)
param.at("filename", ""_sv)
};
static const auto prefix
{
"/proc/self/"_sv
};
char pathbuf[128];
const string_view path{fmt::sprintf
{
pathbuf, "/proc/self/%s", filename
pathbuf, "%s%s", prefix, filename
}};
if(fs::is_dir(path))
{
for(const auto &file : fs::ls(path))
out << file << std::endl;
out << lstrip(file, prefix)
<< (fs::is_dir(file)? "/" : "")
<< std::endl;
return true;
}