File jstest-gtk-use-datadir.patch of Package jstest-gtk-git
From c05a98275b956c6d25181d562083740875f8a9df Mon Sep 17 00:00:00 2001
From: Daniel Bomar <dbdaniel42@gmail.com>
Date: Tue, 17 Mar 2015 14:37:56 -0500
Subject: [PATCH] If data not found in default directory, use /usr/share/
instead.
---
src/main.cpp | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/main.cpp b/src/main.cpp
index 2d18ac6..15714e0 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -216,12 +216,36 @@ std::string find_datadir()
{
throw std::runtime_error("Error: Couldn't find prefix");
}
+ struct stat pathExists;
+ std::string prefix;
+
+ /* Check for the presence of generic.png to ensure we have the correct data folder */
+ char* fileCheck = br_strcat(c_prefix, "/data/generic.png");
+ if (stat (fileCheck, &pathExists) == 0)
+ {
+ prefix = c_prefix;
+ prefix += "/data/";
+ }
+
+ /* If the data was not found in the first location, check a more common
+ location for system installs. For most people this will be /usr/share/ */
else
{
- std::string prefix = c_prefix;
free(c_prefix);
- return prefix + "/data/";
+ c_prefix = br_find_data_dir(NULL);
+ if (!c_prefix)
+ {
+ throw std::runtime_error("Error: Couldn't find prefix");
+ }
+ else
+ {
+ prefix = c_prefix;
+ prefix += "/jstest-gtk/data/";
+ }
}
+ free (c_prefix);
+ free (fileCheck);
+ return prefix;
}
}