diff options
author | Jehan <jehan@girinstud.io> | 2019-11-22 15:45:28 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2019-11-25 17:52:49 +0000 |
commit | 9215030085873ff4317d2f1c47c3455194cd42d7 (patch) | |
tree | 5c52d0b2ac7ab14766e18c2a4beb76e451cf9c26 | |
parent | 5cc8e4fc723b7b7d502cf91f245144f149c68d22 (diff) | |
download | appstream-glib-9215030085873ff4317d2f1c47c3455194cd42d7.tar.gz |
Use _fullpath() instead of GetFullPathNameA().
Win32 docs says that GetFullPathNameA() is not recommended with
multi-threaded applications, since it uses a global variable. As
appstream-glib is a library and can potentially be used in any software,
included in multi-thread cases, let's use _fullpath() instead.
-rw-r--r-- | libappstream-glib/as-self-test.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c index 6ed3116..47ad937 100644 --- a/libappstream-glib/as-self-test.c +++ b/libappstream-glib/as-self-test.c @@ -93,15 +93,12 @@ as_test_get_filename (const gchar *filename) } #ifdef _WIN32 { - DWORD retval; - TCHAR full_path[PATH_MAX]; - - retval = GetFullPathNameA (path, PATH_MAX, full_path, NULL); - - if (retval > 0) - return g_strdup (full_path); - else + char full_path[PATH_MAX]; + if (_fullpath (full_path, path, PATH_MAX) == NULL) + return NULL; + if (!g_file_test (full_path, G_FILE_TEST_EXISTS)) return NULL; + return g_strdup (full_path); } #else return realpath (path, NULL); |