This file is part of MXE. See LICENSE.md for licensing information.

Contains ad hoc patches for cross building.

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MXE User <user@mxe>
Date: Thu, 6 Feb 2025 12:00:00 +0000
Subject: [PATCH] Wine compatibility: use fopen for file I/O

Use direct fopen() instead of GIO for file operations to work
around Wine Z:\ path issues.

diff --git a/rsvg-file-util.c b/rsvg-file-util.c
index 1111111..2222222 100644
--- a/rsvg-file-util.c
+++ b/rsvg-file-util.c
@@ -126,6 +126,31 @@ rsvg_pixbuf_from_file_with_size_data (const gchar * file_name,
 {
     GdkPixbuf *pixbuf;
     char *data;
+    
+    /* Wine compatibility: try direct file I/O first */
+    FILE *f = fopen(file_name, "rb");
+    if (f) {
+        gsize data_len;
+        GString *base_uri = g_string_new (file_name);
+        
+        fseek(f, 0, SEEK_END);
+        data_len = ftell(f);
+        fseek(f, 0, SEEK_SET);
+        
+        data = g_malloc(data_len);
+        if (data && fread(data, 1, data_len, f) == data_len) {
+            pixbuf = rsvg_pixbuf_from_stdio_file_with_size_data (data, data_len,
+                                                                 cb_data, base_uri->str, error);
+            g_free (data);
+        } else {
+            g_set_error(error, G_FILE_ERROR, G_FILE_ERROR_IO, "Failed to read file");
+            pixbuf = NULL;
+        }
+        fclose(f);
+        g_string_free (base_uri, TRUE);
+        return pixbuf;
+    }
+    /* If fopen failed, fall through to original GIO code */
     gsize data_len;
     GString *base_uri = g_string_new (file_name);
 
