forked from osmocom/wireshark
file_util.c is only for Windows; don't build it on UN*X. Put in a check
to cause it to fail when built on UN*X, and get rid of code that's not needed on Windows. svn path=/trunk/; revision=25362
This commit is contained in:
parent
4b87014937
commit
d6e94dafb3
|
@ -39,8 +39,10 @@ libwsutil_la_SOURCES = \
|
||||||
libwsutil_la_LIBADD = @GLIB_LIBS@
|
libwsutil_la_LIBADD = @GLIB_LIBS@
|
||||||
|
|
||||||
EXTRA_DIST = \
|
EXTRA_DIST = \
|
||||||
Makefile.common \
|
Makefile.common \
|
||||||
Makefile.nmake
|
Makefile.nmake \
|
||||||
|
file_util.c \
|
||||||
|
file_util.h
|
||||||
|
|
||||||
CLEANFILES = \
|
CLEANFILES = \
|
||||||
libwsutil.a \
|
libwsutil.a \
|
||||||
|
|
|
@ -29,10 +29,8 @@
|
||||||
# generated from YACC or Lex files (as Automake doesn't want them in
|
# generated from YACC or Lex files (as Automake doesn't want them in
|
||||||
# _SOURCES variables).
|
# _SOURCES variables).
|
||||||
LIBWSUTIL_SRC = \
|
LIBWSUTIL_SRC = \
|
||||||
file_util.c \
|
|
||||||
mpeg-audio.c
|
mpeg-audio.c
|
||||||
|
|
||||||
# Header files that are not generated from other files
|
# Header files that are not generated from other files
|
||||||
LIBWSUTIL_INCLUDES = \
|
LIBWSUTIL_INCLUDES = \
|
||||||
file_util.h \
|
|
||||||
mpeg-audio.h
|
mpeg-audio.h
|
||||||
|
|
|
@ -22,7 +22,7 @@ CVARSDLL=-DWIN32 -DNULL=0 -D_MT -D_DLL
|
||||||
# For use when making libwsutil.dll
|
# For use when making libwsutil.dll
|
||||||
libwsutil_LIBS = $(GLIB_LIBS)
|
libwsutil_LIBS = $(GLIB_LIBS)
|
||||||
|
|
||||||
OBJECTS = $(LIBWSUTIL_SRC:.c=.obj)
|
OBJECTS = file_util.obj $(LIBWSUTIL_SRC:.c=.obj)
|
||||||
|
|
||||||
|
|
||||||
# For use when making libwsutil.dll
|
# For use when making libwsutil.dll
|
||||||
|
|
|
@ -30,19 +30,21 @@
|
||||||
* the following code is stripped down code copied from the GLib file glib/gstdio.h
|
* the following code is stripped down code copied from the GLib file glib/gstdio.h
|
||||||
* stipped down, because this is used on _WIN32 only and we use only wide char functions */
|
* stipped down, because this is used on _WIN32 only and we use only wide char functions */
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#error "This is only for Windows"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
/*#include <direct.h>*/
|
/*#include <direct.h>*/
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "file_util.h"
|
#include "file_util.h"
|
||||||
|
|
||||||
|
@ -74,8 +76,6 @@ ws_stdio_open (const gchar *filename,
|
||||||
int flags,
|
int flags,
|
||||||
int mode)
|
int mode)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
{
|
|
||||||
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
||||||
int retval;
|
int retval;
|
||||||
int save_errno;
|
int save_errno;
|
||||||
|
@ -93,10 +93,6 @@ ws_stdio_open (const gchar *filename,
|
||||||
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
|
||||||
#else
|
|
||||||
return open (filename, flags, mode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +117,6 @@ int
|
||||||
ws_stdio_rename (const gchar *oldfilename,
|
ws_stdio_rename (const gchar *oldfilename,
|
||||||
const gchar *newfilename)
|
const gchar *newfilename)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
wchar_t *woldfilename = g_utf8_to_utf16 (oldfilename, -1, NULL, NULL, NULL);
|
wchar_t *woldfilename = g_utf8_to_utf16 (oldfilename, -1, NULL, NULL, NULL);
|
||||||
wchar_t *wnewfilename;
|
wchar_t *wnewfilename;
|
||||||
int retval;
|
int retval;
|
||||||
|
@ -168,9 +163,6 @@ ws_stdio_rename (const gchar *oldfilename,
|
||||||
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return retval;
|
return retval;
|
||||||
#else
|
|
||||||
return rename (oldfilename, newfilename);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,7 +184,6 @@ int
|
||||||
ws_stdio_mkdir (const gchar *filename,
|
ws_stdio_mkdir (const gchar *filename,
|
||||||
int mode)
|
int mode)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
||||||
int retval;
|
int retval;
|
||||||
int save_errno;
|
int save_errno;
|
||||||
|
@ -210,9 +201,6 @@ ws_stdio_mkdir (const gchar *filename,
|
||||||
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return retval;
|
return retval;
|
||||||
#else
|
|
||||||
return mkdir (filename, mode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -235,7 +223,6 @@ int
|
||||||
ws_stdio_stat (const gchar *filename,
|
ws_stdio_stat (const gchar *filename,
|
||||||
struct stat *buf)
|
struct stat *buf)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
||||||
int retval;
|
int retval;
|
||||||
int save_errno;
|
int save_errno;
|
||||||
|
@ -261,9 +248,6 @@ ws_stdio_stat (const gchar *filename,
|
||||||
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return retval;
|
return retval;
|
||||||
#else
|
|
||||||
return stat (filename, buf);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -287,7 +271,6 @@ ws_stdio_stat (const gchar *filename,
|
||||||
int
|
int
|
||||||
ws_stdio_unlink (const gchar *filename)
|
ws_stdio_unlink (const gchar *filename)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
|
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
|
||||||
int retval;
|
int retval;
|
||||||
int save_errno;
|
int save_errno;
|
||||||
|
@ -305,9 +288,6 @@ ws_stdio_unlink (const gchar *filename)
|
||||||
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return retval;
|
return retval;
|
||||||
#else
|
|
||||||
return unlink (filename);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -339,7 +319,6 @@ ws_stdio_unlink (const gchar *filename)
|
||||||
int
|
int
|
||||||
ws_stdio_remove (const gchar *filename)
|
ws_stdio_remove (const gchar *filename)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
||||||
int retval;
|
int retval;
|
||||||
int save_errno;
|
int save_errno;
|
||||||
|
@ -359,9 +338,6 @@ ws_stdio_remove (const gchar *filename)
|
||||||
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return retval;
|
return retval;
|
||||||
#else
|
|
||||||
return remove (filename);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -384,7 +360,6 @@ FILE *
|
||||||
ws_stdio_fopen (const gchar *filename,
|
ws_stdio_fopen (const gchar *filename,
|
||||||
const gchar *mode)
|
const gchar *mode)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
||||||
wchar_t *wmode;
|
wchar_t *wmode;
|
||||||
FILE *retval;
|
FILE *retval;
|
||||||
|
@ -413,9 +388,6 @@ ws_stdio_fopen (const gchar *filename,
|
||||||
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return retval;
|
return retval;
|
||||||
#else
|
|
||||||
return fopen (filename, mode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -440,7 +412,6 @@ ws_stdio_freopen (const gchar *filename,
|
||||||
const gchar *mode,
|
const gchar *mode,
|
||||||
FILE *stream)
|
FILE *stream)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
|
||||||
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
|
||||||
wchar_t *wmode;
|
wchar_t *wmode;
|
||||||
FILE *retval;
|
FILE *retval;
|
||||||
|
@ -469,8 +440,4 @@ ws_stdio_freopen (const gchar *filename,
|
||||||
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return retval;
|
return retval;
|
||||||
#else
|
|
||||||
return freopen (filename, mode, stream);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue