aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/fileset_dlg.c28
-rw-r--r--ui/qt/file_set_dialog.cpp14
2 files changed, 31 insertions, 11 deletions
diff --git a/ui/gtk/fileset_dlg.c b/ui/gtk/fileset_dlg.c
index cc28f2b152..540da82fdd 100644
--- a/ui/gtk/fileset_dlg.c
+++ b/ui/gtk/fileset_dlg.c
@@ -158,15 +158,25 @@ fileset_dlg_add_file(fileset_entry *entry, void *window _U_) {
created = fileset_dlg_name2date_dup(entry->name);
if (!created) {
/* if this file doesn't follow the file set pattern, */
- /* use the creation time of that file */
- local = localtime(&entry->ctime);
- if (local != NULL) {
- created = g_strdup_printf("%04u-%02u-%02u %02u:%02u:%02u",
- local->tm_year+1900, local->tm_mon+1, local->tm_mday,
- local->tm_hour, local->tm_min, local->tm_sec);
- } else {
- created = g_strdup("Time not representable");
- }
+ /* use the creation time of that file if available */
+ /*
+ * macOS provides 0 if the file system doesn't support the
+ * creation time; FreeBSD provides -1.
+ *
+ * If this OS doesn't provide the creation time with stat(),
+ * it will be 0.
+ */
+ if (entry->ctime > 0) {
+ local = localtime(&entry->ctime);
+ if (local != NULL) {
+ created = g_strdup_printf("%04u-%02u-%02u %02u:%02u:%02u",
+ local->tm_year+1900, local->tm_mon+1, local->tm_mday,
+ local->tm_hour, local->tm_min, local->tm_sec);
+ } else {
+ created = g_strdup("Time not representable");
+ }
+ } else
+ created = g_strdup("Not available");
}
local = localtime(&entry->mtime);
diff --git a/ui/qt/file_set_dialog.cpp b/ui/qt/file_set_dialog.cpp
index 525d446e7d..f62f8ce8c9 100644
--- a/ui/qt/file_set_dialog.cpp
+++ b/ui/qt/file_set_dialog.cpp
@@ -103,9 +103,19 @@ void FileSetDialog::addFile(fileset_entry *entry) {
created = nameToDate(entry->name);
if(created.length() < 1) {
/* if this file doesn't follow the file set pattern, */
- /* use the creation time of that file */
+ /* use the creation time of that file if available */
/* http://en.wikipedia.org/wiki/ISO_8601 */
- created = QDateTime::fromTime_t(entry->ctime).toLocalTime().toString("yyyy-MM-dd HH:mm:ss");
+ /*
+ * macOS provides 0 if the file system doesn't support the
+ * creation time; FreeBSD provides -1.
+ *
+ * If this OS doesn't provide the creation time with stat(),
+ * it will be 0.
+ */
+ if (entry->ctime > 0)
+ created = QDateTime::fromTime_t(entry->ctime).toLocalTime().toString("yyyy-MM-dd HH:mm:ss");
+ else
+ created = "Not available";
}
modified = QDateTime::fromTime_t(entry->mtime).toLocalTime().toString("yyyy-MM-dd HH:mm:ss");