mirror of
https://github.com/matrix-construct/construct
synced 2024-08-22 01:24:53 +02:00
modules/console: Simplify proc cmd listing output.
This commit is contained in:
parent
da97535713
commit
183af6a449
|
@ -645,16 +645,23 @@ console_cmd__proc(opt &out, const string_view &line)
|
||||||
param.at("filename", ""_sv)
|
param.at("filename", ""_sv)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const auto prefix
|
||||||
|
{
|
||||||
|
"/proc/self/"_sv
|
||||||
|
};
|
||||||
|
|
||||||
char pathbuf[128];
|
char pathbuf[128];
|
||||||
const string_view path{fmt::sprintf
|
const string_view path{fmt::sprintf
|
||||||
{
|
{
|
||||||
pathbuf, "/proc/self/%s", filename
|
pathbuf, "%s%s", prefix, filename
|
||||||
}};
|
}};
|
||||||
|
|
||||||
if(fs::is_dir(path))
|
if(fs::is_dir(path))
|
||||||
{
|
{
|
||||||
for(const auto &file : fs::ls(path))
|
for(const auto &file : fs::ls(path))
|
||||||
out << file << std::endl;
|
out << lstrip(file, prefix)
|
||||||
|
<< (fs::is_dir(file)? "/" : "")
|
||||||
|
<< std::endl;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue