From 9193bcaeecd567d40015e352a5320b657edea34a Mon Sep 17 00:00:00 2001 From: Jonathan Arnett Date: Sat, 22 Apr 2017 15:19:15 -0400 Subject: Modified ospath's getConfigDir to meet XDG spec I added a check for the XDG_CONFIG_DIR environment variable to meet the [freedesktop XDG Base Directory Specification](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html) --- lib/pure/ospaths.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pure/ospaths.nim b/lib/pure/ospaths.nim index 71991e35a..4c667dd92 100644 --- a/lib/pure/ospaths.nim +++ b/lib/pure/ospaths.nim @@ -517,6 +517,7 @@ when declared(getEnv) or defined(nimscript): tags: [ReadEnvEffect, ReadIOEffect].} = ## Returns the config directory of the current user for applications. when defined(windows): return string(getEnv("APPDATA")) & "\\" + elif getEnv("XDG_CONFIG_DIR"): return string(getEnv("XDG_CONFIG_DIR")) & "/" else: return string(getEnv("HOME")) & "/.config/" proc getTempDir*(): string {.rtl, extern: "nos$1", -- cgit 1.4.1-2-gfad0 From a9de33643b1503b87359bda0828beeea2ed0162e Mon Sep 17 00:00:00 2001 From: Jonathan Arnett Date: Fri, 28 Apr 2017 11:26:39 -0400 Subject: Appended to comment --- lib/pure/ospaths.nim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/pure/ospaths.nim b/lib/pure/ospaths.nim index 4c667dd92..050482279 100644 --- a/lib/pure/ospaths.nim +++ b/lib/pure/ospaths.nim @@ -516,6 +516,14 @@ when declared(getEnv) or defined(nimscript): proc getConfigDir*(): string {.rtl, extern: "nos$1", tags: [ReadEnvEffect, ReadIOEffect].} = ## Returns the config directory of the current user for applications. + ## + ## On non-Windows OSs, this proc conforms to the XDG Base Directory + ## spec. Thus, this proc returns the value of the XDG_CONFIG_DIR environment + ## variable if it is set, and returns the default configuration directory, + ## "~/.config/", otherwise. + ## + ## An OS-dependent trailing slash is always present at the end of the + ## returned string; `\\` on Windows and `/` on all other OSs. when defined(windows): return string(getEnv("APPDATA")) & "\\" elif getEnv("XDG_CONFIG_DIR"): return string(getEnv("XDG_CONFIG_DIR")) & "/" else: return string(getEnv("HOME")) & "/.config/" -- cgit 1.4.1-2-gfad0 From eb9721a804a7beff701e1aa6a3f0c049b7e53c71 Mon Sep 17 00:00:00 2001 From: Jonathan Arnett Date: Fri, 28 Apr 2017 14:31:12 -0400 Subject: Added getConfigDir changes to breaking changes doc --- web/news/e031_version_0_16_2.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/web/news/e031_version_0_16_2.rst b/web/news/e031_version_0_16_2.rst index b38f0c159..a0d727fe1 100644 --- a/web/news/e031_version_0_16_2.rst +++ b/web/news/e031_version_0_16_2.rst @@ -61,6 +61,10 @@ Changes affecting backwards compatibility compile-time value. - On posix, the results of `waitForExit`, `peekExitCode`, `execCmd` will return 128 + signal number if the application terminates via signal. +- ``ospaths.getConfigDir`` now conforms to the XDG Base Directory specification + on non-Windows OSs. It returns the value of the XDG_CONFIG_DIR environment + variable if it is set, and returns the default configuration directory, + "~/.config/", otherwise. Library Additions ----------------- -- cgit 1.4.1-2-gfad0