summary refs log tree commit diff stats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/util.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/common/util.c b/src/common/util.c
index be3dcac2..316ac9d4 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1462,14 +1462,24 @@ int
 portable_mode (void)
 {
 #ifdef WIN32
-	if ((_access( "portable-mode", 0 )) != -1)
-	{
-		return 1;
-	}
-	else
+	static int is_portable = -1;
+
+	if (G_UNLIKELY(is_portable == -1))
 	{
-		return 0;
+		char *path = g_win32_get_package_installation_directory_of_module (NULL);
+		char *filename;
+
+		if (path == NULL)
+			path = g_strdup (".");
+
+		filename = g_build_filename (path, "portable-mode", NULL);
+		is_portable = g_file_test (filename, G_FILE_TEST_EXISTS);
+
+		g_free (path);
+		g_free (filename);
 	}
+
+	return is_portable;
 #else
 	return 0;
 #endif