diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2005-11-06 22:43:25 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2005-11-06 22:43:25 +0000 |
commit | c3187174bfe39f05c8aa8c6b411952e4b502477d (patch) | |
tree | 0eb95991cb932d74ca534ed0df29a3f2f256b1b8 /wiretap/file_access.c | |
parent | 4e954caec384454ebf4eb61140c466e8787daabe (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.
svn path=/trunk/; revision=16403
Diffstat (limited to 'wiretap/file_access.c')
-rw-r--r-- | wiretap/file_access.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/wiretap/file_access.c b/wiretap/file_access.c index 08b4d72384..abc147afaf 100644 --- a/wiretap/file_access.c +++ b/wiretap/file_access.c @@ -32,19 +32,13 @@ #include <fcntl.h> #endif -#ifdef HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #include <errno.h> -#ifdef HAVE_IO_H -#include <io.h> /* open/close on win32 */ -#endif +#include "file_util.h" #include "wtap-int.h" #include "file_wrappers.h" @@ -179,7 +173,7 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info, return NULL; } } else { - if (stat(filename, &statb) < 0) { + if (eth_stat(filename, &statb) < 0) { *err = errno; return NULL; } @@ -233,11 +227,6 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info, return NULL; } -/* Win32 needs the O_BINARY flag for open() */ -#ifndef O_BINARY -#define O_BINARY 0 -#endif - /* Open the file */ errno = WTAP_ERR_CANT_OPEN; if (use_stdin) { @@ -246,12 +235,12 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info, * an fclose or gzclose of wth->fh closing the standard * input of the process. */ - wth->fd = dup(0); + wth->fd = eth_dup(0); #ifdef _WIN32 _setmode(wth->fd, O_BINARY); #endif } else - wth->fd = open(filename, O_RDONLY|O_BINARY); + wth->fd = eth_open(filename, O_RDONLY|O_BINARY, 0000 /* no creation so don't matter */); if (wth->fd < 0) { *err = errno; g_free(wth); @@ -259,13 +248,13 @@ wtap* wtap_open_offline(const char *filename, int *err, char **err_info, } if (!(wth->fh = filed_open(wth->fd, "rb"))) { *err = errno; - close(wth->fd); + eth_close(wth->fd); g_free(wth); return NULL; } if (do_random) { - if (!(wth->random_fh = file_open(filename, "rb"))) { + if (!(wth->random_fh = file_open(filename, O_RDONLY|O_BINARY, "rb"))) { *err = errno; file_close(wth->fh); g_free(wth); @@ -631,7 +620,7 @@ wtap_dumper* wtap_dump_open(const char *filename, int filetype, int encap, opening it. */ if (wdh->fh != stdout) { wtap_dump_file_close(wdh); - unlink(filename); + eth_unlink(filename); } g_free(wdh); return NULL; @@ -820,7 +809,7 @@ static FILE *wtap_dump_file_open(wtap_dumper *wdh, const char *filename) } else #endif { - return fopen(filename, "wb"); + return eth_fopen(filename, "wb"); } } |