* 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 */
+#ifndef _WIN32
+#error "This is only for Windows"
+#endif
+
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <glib.h>
-#ifdef _WIN32
#include <windows.h>
#include <errno.h>
#include <wchar.h>
/*#include <direct.h>*/
#include <io.h>
-#endif
#include "file_util.h"
int flags,
int mode)
{
-#ifdef _WIN32
- {
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
errno = save_errno;
return retval;
- }
-#else
- return open (filename, flags, mode);
-#endif
}
ws_stdio_rename (const gchar *oldfilename,
const gchar *newfilename)
{
-#ifdef _WIN32
wchar_t *woldfilename = g_utf8_to_utf16 (oldfilename, -1, NULL, NULL, NULL);
wchar_t *wnewfilename;
int retval;
errno = save_errno;
return retval;
-#else
- return rename (oldfilename, newfilename);
-#endif
}
/**
ws_stdio_mkdir (const gchar *filename,
int mode)
{
-#ifdef _WIN32
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
errno = save_errno;
return retval;
-#else
- return mkdir (filename, mode);
-#endif
}
/**
ws_stdio_stat (const gchar *filename,
struct stat *buf)
{
-#ifdef _WIN32
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
errno = save_errno;
return retval;
-#else
- return stat (filename, buf);
-#endif
}
/**
int
ws_stdio_unlink (const gchar *filename)
{
-#ifdef _WIN32
gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
errno = save_errno;
return retval;
-#else
- return unlink (filename);
-#endif
}
/**
int
ws_stdio_remove (const gchar *filename)
{
-#ifdef _WIN32
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
int retval;
int save_errno;
errno = save_errno;
return retval;
-#else
- return remove (filename);
-#endif
}
/**
ws_stdio_fopen (const gchar *filename,
const gchar *mode)
{
-#ifdef _WIN32
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
wchar_t *wmode;
FILE *retval;
errno = save_errno;
return retval;
-#else
- return fopen (filename, mode);
-#endif
}
/**
const gchar *mode,
FILE *stream)
{
-#ifdef _WIN32
wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
wchar_t *wmode;
FILE *retval;
errno = save_errno;
return retval;
-#else
- return freopen (filename, mode, stream);
-#endif
}
-