summaryrefslogtreecommitdiff
path: root/source/kit/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/kit/file.c')
-rw-r--r--source/kit/file.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/source/kit/file.c b/source/kit/file.c
index ec878c2..07e18f4 100644
--- a/source/kit/file.c
+++ b/source/kit/file.c
@@ -150,17 +150,17 @@ kit_str_builder_t kit_path_user(kit_allocator_t *alloc) {
kit_str_builder_t kit_path_cache(kit_allocator_t *alloc) {
kit_str_builder_t cache, user;
-#if defined(_WIN32) && !defined(__CYGWIN__)
- cache = kit_get_env_("LOCALAPPDATA", alloc);
+ cache = kit_get_env_("XDG_CACHE_HOME", alloc);
if (cache.size != 0)
return cache;
DA_DESTROY(cache);
-#endif
- cache = kit_get_env_("XDG_CACHE_HOME", alloc);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ cache = kit_get_env_("TEMP", alloc);
if (cache.size != 0)
return cache;
DA_DESTROY(cache);
+#endif
user = kit_path_user(alloc);
cache =
@@ -175,6 +175,34 @@ kit_str_builder_t kit_path_cache(kit_allocator_t *alloc) {
return cache;
}
+kit_str_builder_t kit_path_data(kit_allocator_t *alloc) {
+ kit_str_builder_t data, user;
+
+ data = kit_get_env_("XDG_DATA_HOME", alloc);
+ if (data.size != 0)
+ return data;
+ DA_DESTROY(data);
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ data = kit_get_env_("LOCALAPPDATA", alloc);
+ if (data.size != 0)
+ return data;
+ DA_DESTROY(data);
+#endif
+
+ user = kit_path_user(alloc);
+ data =
+#ifdef __APPLE__
+ kit_path_join(WRAP_STR(user), SZ("Library"), alloc);
+#else
+ kit_path_join(WRAP_STR(user), SZ(".local" PATH_DELIM "share"),
+ alloc);
+#endif
+ DA_DESTROY(user);
+
+ return data;
+}
+
kit_str_t kit_path_index(kit_str_t path, i64 index) {
str_t s = { .size = 0, .values = NULL };