gio tool: Fix build on Windows/non-GCC

The recently-added GIO tools is intended to be built on all platforms, so
adjust the code a bit to enable this:

-Use gssize instead of ssize_t, as ssize_t is not supported by all
 compilers.
-Include io.h on Windows, and define STDIN_FILENO and STDOUT_FILENO if
 necessary on Windows.

https://bugzilla.gnome.org/show_bug.cgi?id=768357
This commit is contained in:
Chun-wei Fan 2016-07-04 12:27:42 +08:00 committed by Matthias Clasen
parent ca03753853
commit b08a8dc949
2 changed files with 26 additions and 3 deletions

View File

@ -23,6 +23,18 @@
#include <gi18n.h>
#include <errno.h>
#ifdef G_OS_WIN32
#include <io.h>
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gio-tool.h"
@ -56,7 +68,7 @@ cat (GFile *file)
res = g_input_stream_read (in, buffer, sizeof (buffer) - 1, NULL, &error);
if (res > 0)
{
ssize_t written;
gssize written;
p = buffer;
while (res > 0)

View File

@ -22,8 +22,19 @@
#include <gio/gio.h>
#include <gi18n.h>
#include "gio-tool.h"
#ifdef G_OS_WIN32
#include <io.h>
#endif
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "gio-tool.h"
static char *etag = NULL;
static gboolean backup = FALSE;
@ -84,7 +95,7 @@ save (GFile *file)
res = read (STDIN_FILENO, buffer, 1024);
if (res > 0)
{
ssize_t written;
gssize written;
p = buffer;
while (res > 0)