From b08a8dc949731d237b70614ba5b9f6ff3f080bbe Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 4 Jul 2016 12:27:42 +0800 Subject: [PATCH] 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 --- gio/gio-tool-cat.c | 14 +++++++++++++- gio/gio-tool-save.c | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/gio/gio-tool-cat.c b/gio/gio-tool-cat.c index c4f5189cd..c05726452 100644 --- a/gio/gio-tool-cat.c +++ b/gio/gio-tool-cat.c @@ -23,6 +23,18 @@ #include #include +#ifdef G_OS_WIN32 +#include +#endif + +#ifndef STDOUT_FILENO +#define STDOUT_FILENO 1 +#endif + +#ifdef HAVE_UNISTD_H +#include +#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) diff --git a/gio/gio-tool-save.c b/gio/gio-tool-save.c index 17989aeb1..a955a24c0 100644 --- a/gio/gio-tool-save.c +++ b/gio/gio-tool-save.c @@ -22,8 +22,19 @@ #include #include -#include "gio-tool.h" +#ifdef G_OS_WIN32 +#include +#endif +#ifndef STDIN_FILENO +#define STDIN_FILENO 0 +#endif + +#ifdef HAVE_UNISTD_H +#include +#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)