Merge pull request #5748 from J3RN/meet-xdg-base-directory-spec

Modified ospath's getConfigDir to meet XDG spec
This commit is contained in:
Dominik Picheta
2017-05-16 14:11:31 +01:00
committed by GitHub
2 changed files with 13 additions and 0 deletions

View File

@@ -516,7 +516,16 @@ 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/"
proc getTempDir*(): string {.rtl, extern: "nos$1",

View File

@@ -63,6 +63,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
-----------------