Browse Source

libobs: Remove non-USE_XDG code

That is, leave only the code that was under USE_XDG.  Previously the
Linux CMake build defined USE_XDG unconditionally, while it was not set
by the FreeBSD build.

The non-USE_XDG code was broken, and FreeBSD should follow the XDG
convention anyway (in particular, storing config files typically under
$HOME/.config/obs-studio).  Defining USE_XDG in the os-freebsd.cmake
files would leave the non-USE_XDG code unused anywhere, so instead just
remove it.
Ed Maste 1 year ago
parent
commit
c928fac339
3 changed files with 3 additions and 29 deletions
  1. 1 1
      UI/cmake/os-linux.cmake
  2. 0 1
      libobs/cmake/os-linux.cmake
  3. 2 27
      libobs/util/platform-nix.c

+ 1 - 1
UI/cmake/os-linux.cmake

@@ -1,7 +1,7 @@
 target_sources(obs-studio PRIVATE platform-x11.cpp)
 target_compile_definitions(
   obs-studio
-  PRIVATE USE_XDG OBS_INSTALL_PREFIX="${OBS_INSTALL_PREFIX}" $<$<BOOL:${ENABLE_PORTABLE_CONFIG}>:ENABLE_PORTABLE_CONFIG>
+  PRIVATE OBS_INSTALL_PREFIX="${OBS_INSTALL_PREFIX}" $<$<BOOL:${ENABLE_PORTABLE_CONFIG}>:ENABLE_PORTABLE_CONFIG>
 )
 target_link_libraries(obs-studio PRIVATE Qt::GuiPrivate Qt::DBus)
 

+ 0 - 1
libobs/cmake/os-linux.cmake

@@ -20,7 +20,6 @@ target_sources(
 target_compile_definitions(
   libobs
   PRIVATE
-    USE_XDG
     OBS_INSTALL_PREFIX="${OBS_INSTALL_PREFIX}"
     $<$<COMPILE_LANG_AND_ID:C,GNU>:ENABLE_DARRAY_TYPE_TEST>
     $<$<COMPILE_LANG_AND_ID:CXX,GNU>:ENABLE_DARRAY_TYPE_TEST>

+ 2 - 27
libobs/util/platform-nix.c

@@ -271,11 +271,9 @@ uint64_t os_gettime_ns(void)
 	return ((uint64_t)ts.tv_sec * 1000000000ULL + (uint64_t)ts.tv_nsec);
 }
 
-/* should return $HOME/.[name], or when using XDG,
- * should return $HOME/.config/[name] as default */
+/* should return $HOME/.config/[name] as default */
 int os_get_config_path(char *dst, size_t size, const char *name)
 {
-#ifdef USE_XDG
 	char *xdg_ptr = getenv("XDG_CONFIG_HOME");
 
 	// If XDG_CONFIG_HOME is unset,
@@ -296,23 +294,11 @@ int os_get_config_path(char *dst, size_t size, const char *name)
 		else
 			return snprintf(dst, size, "%s/%s", xdg_ptr, name);
 	}
-#else
-	char *path_ptr = getenv("HOME");
-	if (path_ptr == NULL)
-		bcrash("Could not get $HOME\n");
-
-	if (!name || !*name)
-		return snprintf(dst, size, "%s", path_ptr);
-	else
-		return snprintf(dst, size, "%s/.%s", path_ptr, name);
-#endif
 }
 
-/* should return $HOME/.[name], or when using XDG,
- * should return $HOME/.config/[name] as default */
+/* should return $HOME/.config/[name] as default */
 char *os_get_config_path_ptr(const char *name)
 {
-#ifdef USE_XDG
 	struct dstr path;
 	char *xdg_ptr = getenv("XDG_CONFIG_HOME");
 
@@ -332,17 +318,6 @@ char *os_get_config_path_ptr(const char *name)
 		dstr_cat(&path, name);
 	}
 	return path.array;
-#else
-	char *path_ptr = getenv("HOME");
-	if (path_ptr == NULL)
-		bcrash("Could not get $HOME\n");
-
-	struct dstr path;
-	dstr_init_copy(&path, path_ptr);
-	dstr_cat(&path, "/.");
-	dstr_cat(&path, name);
-	return path.array;
-#endif
 }
 
 int os_get_program_data_path(char *dst, size_t size, const char *name)