[gdk-pixbuf: 2/5] tests/pixbuf-reftest: Work around broken symlinks on Windows



commit 8ae5adcf00bfe63f631013f48865c0539b888599
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Tue Dec 11 13:41:19 2018 +0100

    tests/pixbuf-reftest: Work around broken symlinks on Windows
    
    When cloning the repo with git on Windows the symlinks end up being
    normal files which contain the target path as text.
    
    Make this kinda work by detecting if the files contain ascii only
    and then treating the content as a filename in the parent directory.

 tests/pixbuf-reftest.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
---
diff --git a/tests/pixbuf-reftest.c b/tests/pixbuf-reftest.c
index fd5414618..caf841c6c 100644
--- a/tests/pixbuf-reftest.c
+++ b/tests/pixbuf-reftest.c
@@ -85,6 +85,28 @@ make_ref_file (GFile *file)
 
   result = g_file_new_for_uri (ref_uri);
 
+#ifdef G_OS_WIN32
+  /* XXX: The .ref.png files are symlinks and on Windows git will create
+   * files containing the symlink target instead of symlinks. */
+  {
+    char *contents;
+    gboolean success;
+
+    success = g_file_load_contents (result, NULL, &contents, NULL, NULL, NULL);
+    if (success)
+      {
+        if (g_str_is_ascii (contents))
+          {
+            GFile *parent = g_file_get_parent (result);
+            g_object_unref (result);
+            result = g_file_get_child (parent, contents);
+            g_object_unref (parent);
+          }
+        g_free (contents);
+      }
+  }
+#endif
+
   g_free (ref_uri);
   g_free (uri);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]