aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-10-21 22:19:46 -0700
committerGuy Harris <guy@alum.mit.edu>2016-10-22 05:20:22 +0000
commit528894e72f973c5db5dc76c975620754f7bbe5aa (patch)
treebd4fc32180655bd1f9e935a2b75220c80ac8e3dd /ui/gtk
parentd16295bc9b48a526f12237467536bac4220e53da (diff)
On UN*X, st_ctime is the last status change time, not the creation time.
That's the time the file's inode last changed, so size changes, permission changes, etc. affect it. It's *not* the time the file was created; most UN*Xes don't provide that. Newer versions of FreeBSD, NetBSD, OpenBSD, and macOS do, but other UN*Xes don't appear to. On Windows, at least according to Microsoft's documentation, st_ctime *is* the creation time. Hopefully that's not the result of confusion on the part of somebody at Microsoft. Change-Id: I20743703f6ef66e40dff9004dc91bed46af6fad0 Reviewed-on: https://code.wireshark.org/review/18378 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/gtk')
-rw-r--r--ui/gtk/fileset_dlg.c28
1 files changed, 19 insertions, 9 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);