toggle file details
This commit is contained in:
parent
a7e9f9ea14
commit
95fd5fb964
2 changed files with 18 additions and 5 deletions
1
ccc.c
1
ccc.c
|
@ -268,6 +268,7 @@ int main(int argc, char** argv)
|
|||
case 'i':
|
||||
file_details = !file_details;
|
||||
change_dir(cwd, 0, 0);
|
||||
break;
|
||||
|
||||
/* mark one file */
|
||||
case SPACE:
|
||||
|
|
20
file.c
20
file.c
|
@ -132,15 +132,27 @@ char *get_line(ArrayList *list, long index, bool detail)
|
|||
{
|
||||
file file = list->items[index];
|
||||
char *name = strdup(file.path);
|
||||
char *stats = strdup(file.stats);
|
||||
size_t length = strlen(name) + strlen(stats) + 2; /* one for space and one for null */
|
||||
char *stats = NULL;
|
||||
size_t length;
|
||||
if (detail) {
|
||||
stats = strdup(file.stats);
|
||||
length = strlen(name) + strlen(stats) + 2; /* one for space and one for null */
|
||||
if (stats == NULL) {
|
||||
perror("ccc");
|
||||
}
|
||||
} else {
|
||||
length = strlen(name) + 2; /* one for space and one for null */
|
||||
}
|
||||
char *line = memalloc(length * sizeof(char));
|
||||
|
||||
name = basename(name);
|
||||
if (name == NULL || stats == NULL)
|
||||
if (name == NULL)
|
||||
perror("ccc");
|
||||
|
||||
if (detail) {
|
||||
snprintf(line, length, "%s %s", stats, name);
|
||||
} else {
|
||||
snprintf(line, length, "%s", name);
|
||||
}
|
||||
|
||||
return line;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue