mirror of
				https://gitlab.gnome.org/GNOME/glib.git
				synced 2025-11-04 10:08:56 +01:00 
			
		
		
		
	gio/tests: Clean up inclusion of unistd.h
Include unistd.h only on *NIX and define items as necessary on Windows, also replace instances of ssize_t with the GLib-equivilant gssize so to fix the build on platforms that do not have ssize_t, such as Visual C++. https://bugzilla.gnome.org/show_bug.cgi?id=711047
This commit is contained in:
		@@ -23,13 +23,22 @@
 | 
				
			|||||||
#include <config.h>
 | 
					#include <config.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <locale.h>
 | 
					#include <locale.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <glib.h>
 | 
					#include <glib.h>
 | 
				
			||||||
#include <gio/gio.h>
 | 
					#include <gio/gio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef G_OS_UNIX
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef G_OS_WIN32
 | 
				
			||||||
 | 
					#ifndef STDOUT_FILENO
 | 
				
			||||||
 | 
					#define STDOUT_FILENO 1
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static gchar **locations = NULL;
 | 
					static gchar **locations = NULL;
 | 
				
			||||||
static char *from_charset = NULL;
 | 
					static char *from_charset = NULL;
 | 
				
			||||||
static char *to_charset = NULL;
 | 
					static char *to_charset = NULL;
 | 
				
			||||||
@@ -157,7 +166,7 @@ cat (GFile * file)
 | 
				
			|||||||
	g_input_stream_read (in, buffer, sizeof (buffer) - 1, NULL, &error);
 | 
						g_input_stream_read (in, buffer, sizeof (buffer) - 1, NULL, &error);
 | 
				
			||||||
      if (res > 0)
 | 
					      if (res > 0)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	  ssize_t written;
 | 
						  gssize written;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  p = buffer;
 | 
						  p = buffer;
 | 
				
			||||||
	  while (res > 0)
 | 
						  while (res > 0)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,8 +3,8 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <errno.h>
 | 
					#include <errno.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#ifdef G_OS_UNIX
 | 
					#ifdef G_OS_UNIX
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
#include <gio/gunixinputstream.h>
 | 
					#include <gio/gunixinputstream.h>
 | 
				
			||||||
#include <gio/gunixoutputstream.h>
 | 
					#include <gio/gunixoutputstream.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
@@ -20,7 +20,7 @@ write_all (int           fd,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  while (len > 0)
 | 
					  while (len > 0)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      ssize_t bytes_written = write (fd, buf, len);
 | 
					      gssize bytes_written = write (fd, buf, len);
 | 
				
			||||||
      if (bytes_written < 0)
 | 
					      if (bytes_written < 0)
 | 
				
			||||||
	g_error ("Failed to write to fd %d: %s",
 | 
						g_error ("Failed to write to fd %d: %s",
 | 
				
			||||||
		 fd, strerror (errno));
 | 
							 fd, strerror (errno));
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,12 @@
 | 
				
			|||||||
#include <glib/glib.h>
 | 
					#include <glib/glib.h>
 | 
				
			||||||
#include <glib/gstdio.h>
 | 
					#include <glib/gstdio.h>
 | 
				
			||||||
#include <gio/gio.h>
 | 
					#include <gio/gio.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef G_OS_UNIX
 | 
				
			||||||
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const char *original_data = "This is some test data that we can put in a file...";
 | 
					static const char *original_data = "This is some test data that we can put in a file...";
 | 
				
			||||||
static const char *new_data = "new data..";
 | 
					static const char *new_data = "new data..";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,7 +28,9 @@
 | 
				
			|||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include <stdlib.h>
 | 
					#include <stdlib.h>
 | 
				
			||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					#ifdef G_OS_UNIX
 | 
				
			||||||
#include <unistd.h>
 | 
					#include <unistd.h>
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <gio/gio.h>
 | 
					#include <gio/gio.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,7 +27,6 @@
 | 
				
			|||||||
#include <string.h>
 | 
					#include <string.h>
 | 
				
			||||||
#include <fcntl.h>
 | 
					#include <fcntl.h>
 | 
				
			||||||
#include <io.h>
 | 
					#include <io.h>
 | 
				
			||||||
#include <unistd.h>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <windows.h>
 | 
					#include <windows.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user