MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / mainLs

Function mainLs

src/fe-ls.cc:36–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36int mainLs(int argc, const char* argv[])
37{
38 if (argc == 1)
39 showProfiles("ls", formats);
40 flags.parseFlagsWithConfigFiles(argc, argv, formats);
41
42 try
43 {
44 auto filesystem = Filesystem::createFilesystemFromConfig();
45 auto files = filesystem->list(Path(directory));
46
47 int maxlen = 0;
48 for (const auto& dirent : files)
49 maxlen = std::max(maxlen, (int)quote(dirent->filename).size());
50
51 uint32_t total = 0;
52 for (const auto& dirent : files)
53 {
54 fmt::print("{} {:{}} {:6} {:4} {}\n",
55 fileTypeChar(dirent->file_type),
56 quote(dirent->filename),
57 maxlen + 2,
58 dirent->length,
59 dirent->mode,
60 dirent->attributes[Filesystem::CTIME]);
61 total += dirent->length;
62 }
63 fmt::print("({} files, {} bytes)\n", files.size(), total);
64 }
65 catch (const FilesystemException& e)
66 {
67 error("{}", e.message);
68 }
69
70 return 0;
71}

Callers

nothing calls this directly

Calls 9

showProfilesFunction · 0.85
quoteFunction · 0.85
printFunction · 0.85
fileTypeCharFunction · 0.85
errorFunction · 0.85
PathClass · 0.50
listMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected