// Compile using
// gcc test.c `pkg-config --cflags --libs gio-2.0`

#include <gio/gio.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

main() {
	// Make sure that $PWD is longer than PATH_MAX
	char long_dir_name[100];
	memset(long_dir_name, 'A', 100);
	long_dir_name[100] = 0;

	for(int i=0; i<50; i++) {
		mkdir(long_dir_name, 0700);
		chdir(long_dir_name);
	}

	// Create some local file
	FILE *foo = fopen("my-file", "w");
	fprintf(foo, "Hello world.\n");
	fclose(foo);

	// Create a GFile for this file
	GFile *my_file = g_file_new_for_commandline_arg("./my-file");

	// Read from it
	GError *error = NULL;
	GFileInputStream *input_stream = g_file_read(my_file, NULL, &error);

	// Output info
	if(input_stream == NULL) {
		perror(error->message);
	}
}
