diff --git a/src/tools/imgtool/main.cpp b/src/tools/imgtool/main.cpp index f1087798c0d..6ea34d6d6d7 100644 --- a/src/tools/imgtool/main.cpp +++ b/src/tools/imgtool/main.cpp @@ -177,12 +177,21 @@ static int cmd_dir(const struct command *c, int argc, char *argv[]) imgtool::partition::ptr partition; imgtool::directory::ptr imgenum; imgtool_dirent ent; - char buf[512]; char last_modified[19]; const char *path; int partition_index = 0; std::string info; + // build the separator + const int columnwidth_filename = 30; + const int columnwidth_filesize = 8; + const int columnwidth_attributes = 15; + const int columnwidth_lastmodified = 18; + std::string separator = std::string(columnwidth_filename, '-') + " " + + std::string(columnwidth_filesize, '-') + " " + + std::string(columnwidth_attributes, '-') + " " + + std::string(columnwidth_lastmodified, '-'); + // attempt to open image err = imgtool::image::open(argv[0], argv[1], OSD_FOPEN_READ, image); if (err) @@ -209,14 +218,14 @@ static int cmd_dir(const struct command *c, int argc, char *argv[]) info = image->info(); if (!info.empty()) fprintf(stdout, "%s\n", info.c_str()); - fprintf(stdout, "------------------------------ -------- --------------- ------------------\n"); + + fprintf(stdout, "%s\n", separator.c_str()); while (((err = imgenum->get_next(ent)) == 0) && !ent.eof) { - if (ent.directory) - snprintf(buf, sizeof(buf), "