aboutsummaryrefslogtreecommitdiff
path: root/dir_monitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'dir_monitor.c')
-rw-r--r--dir_monitor.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/dir_monitor.c b/dir_monitor.c
index 42d90dc..9903b12 100644
--- a/dir_monitor.c
+++ b/dir_monitor.c
@@ -51,8 +51,8 @@ void print_list(struct list_head *list);
/* === GLOBAL VARIABLES === */
-bool show_hidden_entries = false;
-
+bool option_show_hidden_entries = false;
+bool option_timestamp_short = true;
/* === IMPLEMENTATION === */
@@ -134,6 +134,7 @@ inline int insert_sorted_by_size(struct list_head *list, struct list_node *node)
void print_list(struct list_head *list) {
struct list_node *ptr;
struct tm *tm = NULL;
+ char timestamp[128];
if (list == NULL) return;
@@ -141,7 +142,16 @@ void print_list(struct list_head *list) {
while (ptr != NULL) {
printf(" %8lu %2s ", ((ptr->fsize>=1024) ? (ptr->fsize/1024) : ptr->fsize),
((ptr->fsize >= 1024) ? "kB" : ""));
- /* TODO: time here */
+
+ tm = localtime(&ptr->ftime);
+ if (option_timestamp_short) {
+ strftime(timestamp, sizeof(timestamp), "%H:%M:%S", tm);
+ printf(" %8s ", timestamp);
+ } else {
+ strftime(timestamp, sizeof(timestamp), "%Y%m%d %H:%M:%S %Z", tm);
+ printf(" %20s ", timestamp);
+ }
+
printf(" %s\n", ptr->fname);
ptr = ptr->next;
}
@@ -188,7 +198,7 @@ struct list_head *get_data_from_directory(char *path) {
errno = 0;
/* Show hidden entries code is UNIXoid specific, needs to be adjusted for portability */
while ((de = readdir(dir)) != NULL) {
- if (de->d_name[0] == '.' && show_hidden_entries == false)
+ if (de->d_name[0] == '.' && option_show_hidden_entries == false)
continue;
sprintf(fname_in_path, "%s", de->d_name);