summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorEcorous <exo@frogastudios.com>2023-05-12 13:44:29 +0100
committerGitHub <noreply@github.com>2023-05-12 20:44:29 +0800
commit871e4af6ef384ef27c9357dab24ab727a2006eae (patch)
treee990ee83edd4bf8121b98e5b0d7a6bf359198ff7 /lib
parent9c40dd2406e6e83799aa4e3a22e23922318aabd6 (diff)
downloadNim-871e4af6ef384ef27c9357dab24ab727a2006eae.tar.gz
add getDataDir to std/appdirs.nim (#21754)
* add getDataDir to std/appdirs.nim

* reuse `osappdirs.getDataDir`

* Update lib/std/appdirs.nim

---------

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/std/appdirs.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/std/appdirs.nim b/lib/std/appdirs.nim
index c945ba8ec..963451efe 100644
--- a/lib/std/appdirs.nim
+++ b/lib/std/appdirs.nim
@@ -17,6 +17,23 @@ proc getHomeDir*(): Path {.inline, tags: [ReadEnvEffect, ReadIOEffect].} =
   ## * `getTempDir proc`_
   result = Path(osappdirs.getHomeDir())
 
+proc getDataDir*(): Path {.inline, tags: [ReadEnvEffect, ReadIOEffect].} =
+  ## Returns the data 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_DATA_HOME` environment
+  ## variable if it is set, otherwise it returns the default configuration
+  ## directory ("~/.local/share" or "~/Library/Application Support" on macOS).
+  ## 
+  ## See also:
+  ## * `getHomeDir proc`_
+  ## * `getConfigDir proc`_
+  ## * `getTempDir proc`_
+  ## * `expandTilde proc`_
+  ## * `getCurrentDir proc`_
+  ## * `setCurrentDir proc`_
+  result = Path(osappdirs.getDataDir())
+
 proc getConfigDir*(): Path {.inline, tags: [ReadEnvEffect, ReadIOEffect].} =
   ## Returns the config directory of the current user for applications.
   ##