Fix the description of dissector_try_uint_new().
[metze/wireshark/wip.git] / fileset.c
index 2d022957a58046d9c140130403a47f7329010404..b2bda3bc68452af19299f6faeefe4afc90380135 100644 (file)
--- a/fileset.c
+++ b/fileset.c
@@ -49,6 +49,23 @@ typedef struct _fileset {
 /* this is the fileset's global data */
 static fileset set = { NULL, NULL};
 
+/*
+ * Given a stat structure, get the creation time of the file if available,
+ * or 0 if not.
+ */
+#ifdef _WIN32
+  /* Microsoft's documentation says this is the creation time */
+  #define ST_CREATE_TIME(statb) ((statb).st_ctime)
+#else /* _WIN32 */
+  /* UN*X - do we have a creation time? */
+  #if defined(HAVE_STRUCT_STAT_ST_BIRTHTIME)
+    #define ST_CREATE_TIME(statb) ((statb).st_birthtime)
+  #elif defined(HAVE_STRUCT_STAT___ST_BIRTHTIME)
+    #define ST_CREATE_TIME(statb) ((statb).__st_birthtime)
+  #else /* nothing */
+    #define ST_CREATE_TIME(statb) (0)
+  #endif /* creation time on UN*X */
+#endif /* _WIN32 */
 
 /* is this a probable file of a file set (does the naming pattern match)? */
 gboolean
@@ -186,7 +203,7 @@ fileset_update_file(const char *path)
 
             if (entry_list) {
                 entry = (fileset_entry *) entry_list->data;
-                entry->ctime    = buf.st_ctime;
+                entry->ctime    = ST_CREATE_TIME(buf);
                 entry->mtime    = buf.st_mtime;
                 entry->size     = buf.st_size;
             }
@@ -220,7 +237,7 @@ fileset_add_file(const char *dirname, const char *fname, gboolean current)
 
             entry->fullname = g_strdup(path);
             entry->name     = g_strdup(fname);
-            entry->ctime    = buf.st_ctime;
+            entry->ctime    = ST_CREATE_TIME(buf);
             entry->mtime    = buf.st_mtime;
             entry->size     = buf.st_size;
             entry->current  = current;
@@ -254,7 +271,7 @@ void fileset_update_dlg(void *window)
     GList         *le;
 
 
-    /* add all entires to the dialog */
+    /* add all entries to the dialog */
     le = g_list_first(set.entries);
     while(le) {
         fileset_dlg_add_file((fileset_entry *)le->data, window);
@@ -275,8 +292,8 @@ fileset_add_dir(const char *fname, void *window)
 
 
     /* get (convert) directory name, but don't touch the given string */
-    fname_dup = get_dirname(g_strdup(fname));
-    dirname = g_string_new(fname_dup);
+    fname_dup = g_strdup(fname);
+    dirname = g_string_new(get_dirname(fname_dup));
     g_free(fname_dup);
 
     set.dirname = g_strdup(dirname->str);
@@ -327,7 +344,7 @@ fileset_get_current(void)
     fileset_entry *entry;
 
 
-    /* add all entires to the dialog */
+    /* add all entries to the dialog */
     le = g_list_first(set.entries);
     while(le) {
         entry = (fileset_entry *)le->data;