mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-03 19:52:36 +00:00
Merge pull request #5748 from J3RN/meet-xdg-base-directory-spec
Modified ospath's getConfigDir to meet XDG spec
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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
|
||||
-----------------
|
||||
|
||||
Reference in New Issue
Block a user