aboutsummaryrefslogtreecommitdiffstats
path: root/fileset.c
diff options
context:
space:
mode:
authorulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>2005-11-06 22:43:25 +0000
committerulfl <ulfl@f5534014-38df-0310-8fa8-9805f1628bb7>2005-11-06 22:43:25 +0000
commit0180a288fa38bef477488aecd025aade16614bbf (patch)
tree0eb95991cb932d74ca534ed0df29a3f2f256b1b8 /fileset.c
parent297440aa575eaffc35554650cb1dc938a5d4cc89 (diff)
replace *a lot* of file related calls by their GLib counterparts. This is necessary for the switch to GTK 2.6 (at least on WIN32).
to do this, I've added file_util.h to wiretap (would file_compat.h be a better name?), and provide compat_macros like eth_open() instead of open(). While at it, move other file related things there, like #include <io.h>, definition of O_BINARY and alike, so it's all in one place. deleted related things from config.h.win32 As of these massive changes, I'm almost certain that this will break the Unix build. I'll keep an eye on the buildbot so hopefully everything is working again soon. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@16403 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'fileset.c')
-rw-r--r--fileset.c42
1 files changed, 9 insertions, 33 deletions
diff --git a/fileset.c b/fileset.c
index b7d71d5471..b023d2b146 100644
--- a/fileset.c
+++ b/fileset.c
@@ -30,10 +30,6 @@
#include <unistd.h>
#endif
-#ifdef HAVE_IO_H
-#include <io.h>
-#endif
-
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
@@ -55,6 +51,7 @@
#include <glib.h>
+#include "file_util.h"
#include "globals.h"
#include <epan/filesystem.h>
@@ -183,7 +180,7 @@ fileset_add_file(const char *dirname, const char *fname, gboolean current)
path = g_strdup_printf("%s%s", dirname, fname);
- fh = open( path, O_RDONLY );
+ fh = eth_open( path, O_RDONLY, 0000 /* no creation so don't matter */);
if(fh != -1) {
/* Get statistics */
@@ -203,7 +200,7 @@ fileset_add_file(const char *dirname, const char *fname, gboolean current)
set.entries = g_list_append(set.entries, entry);
}
- close(fh);
+ eth_close(fh);
}
g_free(path);
@@ -242,15 +239,9 @@ void fileset_update_dlg(void)
void
fileset_add_dir(const char *fname)
{
-#if GLIB_MAJOR_VERSION < 2
- DIR *dir; /* scanned directory */
- struct dirent *file; /* current file */
- gchar *name;
-#else /* GLIB 2 */
- GDir *dir; /* scanned directory */
- GError **dummy;
+ ETH_DIR *dir; /* scanned directory */
+ ETH_DIRENT *file; /* current file */
const char *name;
-#endif
fileset_entry *entry;
GString *dirname;
gchar *fname_dup;
@@ -268,31 +259,16 @@ fileset_add_dir(const char *fname)
/* is the current file probably a part of any fileset? */
if(fileset_filename_match_pattern(fname)) {
/* yes, go through the files in the directory and check if the file in question is part of the current file set */
-#if GLIB_MAJOR_VERSION < 2
- if ((dir = opendir(dirname->str)) != NULL) {
- while ((file = readdir(dir)) != NULL) {
- name = (gchar *)file->d_name;
-#else
- dummy = g_malloc(sizeof(GError *));
- *dummy = NULL;
-
- if ((dir = g_dir_open(dirname->str, 0, dummy)) != NULL) {
- while ((name = g_dir_read_name(dir)) != NULL) {
-#endif
+ if ((dir = g_dir_open(dirname->str, 0, NULL)) != NULL) {
+ while ((file = eth_dir_read_name(dir)) != NULL) {
+ name = eth_dir_get_name(file);
if(fileset_filename_match_pattern(name) && fileset_is_file_in_set(name, get_basename(fname))) {
fileset_add_file(dirname->str, name, strcmp(name, get_basename(fname))== 0 /* current */);
}
} /* while */
-#if GLIB_MAJOR_VERSION < 2
- closedir(dir);
-#else
- g_dir_close(dir);
-#endif
+ eth_dir_close(dir);
} /* if */
-#if GLIB_MAJOR_VERSION >= 2
- g_free(dummy);
-#endif
} else {
/* no, this is a "standalone file", just add this one */
entry = fileset_add_file(dirname->str, get_basename(fname), TRUE /* current */);