mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 00:14:11 +09:00
[core,settings] unify config path determination
This commit is contained in:
@@ -748,6 +748,7 @@ extern "C"
|
||||
/** \brief return the configuration directory for the library
|
||||
* @return The current configuration path or \b NULL
|
||||
* @since version 3.6.0
|
||||
* @note Since 3.17.1 this is a wrapper for \ref freerdp_GetConfigFilePath(FALSE, "")
|
||||
*/
|
||||
WINPR_ATTR_MALLOC(free, 1)
|
||||
FREERDP_API char* freerdp_settings_get_config_path(void);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <winpr/wtsapi.h>
|
||||
|
||||
#include <freerdp/settings.h>
|
||||
#include <freerdp/utils/helpers.h>
|
||||
#include <freerdp/build-config.h>
|
||||
|
||||
#include "../crypto/certificate.h"
|
||||
@@ -752,35 +753,9 @@ BOOL freerdp_settings_set_default_order_support(rdpSettings* settings)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if !defined(WITH_FULL_CONFIG_PATH)
|
||||
static char* freerdp_settings_get_legacy_config_path(void)
|
||||
{
|
||||
char product[sizeof(FREERDP_PRODUCT_STRING)] = { 0 };
|
||||
|
||||
for (size_t i = 0; i < sizeof(product); i++)
|
||||
product[i] = (char)tolower(FREERDP_PRODUCT_STRING[i]);
|
||||
|
||||
return GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME, product);
|
||||
}
|
||||
#endif
|
||||
|
||||
char* freerdp_settings_get_config_path(void)
|
||||
{
|
||||
char* path = NULL;
|
||||
/* For default FreeRDP continue using same config directory
|
||||
* as in old releases.
|
||||
* Custom builds use <Vendor>/<Product> as config folder. */
|
||||
#if !defined(WITH_FULL_CONFIG_PATH)
|
||||
if (_stricmp(FREERDP_VENDOR_STRING, FREERDP_PRODUCT_STRING) == 0)
|
||||
return freerdp_settings_get_legacy_config_path();
|
||||
#endif
|
||||
|
||||
char* base = GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME, FREERDP_VENDOR_STRING);
|
||||
if (base)
|
||||
path = GetCombinedPath(base, FREERDP_PRODUCT_STRING);
|
||||
free(base);
|
||||
|
||||
return path;
|
||||
return freerdp_GetConfigFilePath(FALSE, "");
|
||||
}
|
||||
|
||||
rdpSettings* freerdp_settings_new(DWORD flags)
|
||||
|
||||
@@ -18,14 +18,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include <freerdp/utils/helpers.h>
|
||||
|
||||
#include <winpr/path.h>
|
||||
#include <freerdp/version.h>
|
||||
#include <freerdp/build-config.h>
|
||||
|
||||
#if defined(WITH_RESOURCE_VERSIONING)
|
||||
#define STR(x) #x
|
||||
#if !defined(WITH_FULL_CONFIG_PATH)
|
||||
static char* freerdp_settings_get_legacy_config_path(void)
|
||||
{
|
||||
char product[sizeof(FREERDP_PRODUCT_STRING)] = { 0 };
|
||||
|
||||
for (size_t i = 0; i < sizeof(product); i++)
|
||||
product[i] = (char)tolower(FREERDP_PRODUCT_STRING[i]);
|
||||
|
||||
return GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME, product);
|
||||
}
|
||||
#endif
|
||||
|
||||
char* freerdp_GetConfigFilePath(BOOL system, const char* filename)
|
||||
@@ -35,15 +45,20 @@ char* freerdp_GetConfigFilePath(BOOL system, const char* filename)
|
||||
#if defined(FREERDP_USE_VENDOR_PRODUCT_CONFIG_DIR)
|
||||
char* vendor = GetKnownSubPath(id, FREERDP_VENDOR_STRING);
|
||||
#else
|
||||
#if !defined(WITH_FULL_CONFIG_PATH)
|
||||
if (!system && (_stricmp(FREERDP_VENDOR_STRING, FREERDP_PRODUCT_STRING) == 0))
|
||||
return freerdp_settings_get_legacy_config_path();
|
||||
#endif
|
||||
|
||||
char* vendor = GetKnownPath(id);
|
||||
#endif
|
||||
if (!vendor)
|
||||
return NULL;
|
||||
|
||||
#if defined(WITH_RESOURCE_VERSIONING)
|
||||
char* verstr = FREERDP_PRODUCT_STRING STR(FREERDP_VERSION_MAJOR);
|
||||
const char* verstr = FREERDP_PRODUCT_STRING FREERDP_API_VERSION;
|
||||
#else
|
||||
char* verstr = FREERDP_PRODUCT_STRING;
|
||||
const char* verstr = FREERDP_PRODUCT_STRING;
|
||||
#endif
|
||||
|
||||
char* base = GetCombinedPath(vendor, verstr);
|
||||
|
||||
Reference in New Issue
Block a user