diff options
author | Guy Harris <guy@alum.mit.edu> | 2016-10-21 22:19:46 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-10-22 05:20:22 +0000 |
commit | 528894e72f973c5db5dc76c975620754f7bbe5aa (patch) | |
tree | bd4fc32180655bd1f9e935a2b75220c80ac8e3dd /ui/qt | |
parent | d16295bc9b48a526f12237467536bac4220e53da (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/qt')
-rw-r--r-- | ui/qt/file_set_dialog.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
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"); |