summaryrefslogtreecommitdiff
path: root/src/fileops.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-03-18 14:19:35 -0700
committerRussell Belfer <rb@github.com>2013-03-18 14:19:35 -0700
commit41954a49c12a72eda3b3fe02c2752f6831b5dbf9 (patch)
tree4b9cff17fbd7172efddde4dba8e1d2f6b31e0c45 /src/fileops.h
parent5540d9477ed143707435324e785336d254b12e47 (diff)
downloadlibgit2-41954a49c12a72eda3b3fe02c2752f6831b5dbf9.tar.gz
Switch search paths to classic delimited strings
This switches the APIs for setting and getting the global/system search paths from using git_strarray to using a simple string with GIT_PATH_LIST_SEPARATOR delimited paths, just as the environment PATH variable would contain. This makes it simpler to get and set the value. I also added code to expand "$PATH" when setting a new value to embed the old value of the path. This means that I no longer require separate actions to PREPEND to the value.
Diffstat (limited to 'src/fileops.h')
-rw-r--r--src/fileops.h39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/fileops.h b/src/fileops.h
index 57ab91837..627a6923d 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -306,25 +306,42 @@ typedef enum {
} git_futils_dir_t;
/**
- * Get the strarray of search paths for global/system files
+ * Get the search path for global/system/xdg files
*
- * @param out git_strarray of search paths
+ * @param out pointer to git_buf containing search path
* @param which which list of paths to return
- * @return 0 on success, <0 on failure (allocation error)
+ * @return 0 on success, <0 on failure
+ */
+extern int git_futils_dirs_get(const git_buf **out, git_futils_dir_t which);
+
+/**
+ * Get search path into a preallocated buffer
+ *
+ * @param out String buffer to write into
+ * @param outlen Size of string buffer
+ * @param which Which search path to return
+ * @return 0 on success, GIT_EBUFS if out is too small, <0 on other failure
*/
-extern int git_futils_dirs_get(
- const git_strarray **out, git_futils_dir_t which);
+
+extern int git_futils_dirs_get_str(
+ char *out, size_t outlen, git_futils_dir_t which);
/**
- * Set or prepend strarray of search paths for global/system files
+ * Set search paths for global/system/xdg files
+ *
+ * The first occurrence of the magic string "$PATH" in the new value will
+ * be replaced with the old value of the search path.
*
- * @param which which list of paths to modify
- * @param dirs new list of search paths
- * @param replace true to replace old, false to prepend to old
+ * @param which Which search path to modify
+ * @param paths New search path (separated by GIT_PATH_LIST_SEPARATOR)
* @return 0 on success, <0 on failure (allocation error)
*/
-extern int git_futils_dirs_set(
- git_futils_dir_t which, const git_strarray *dirs, bool replace);
+extern int git_futils_dirs_set(git_futils_dir_t which, const char *paths);
+
+/**
+ * Release / reset all search paths
+ */
+extern void git_futils_dirs_free(void);
/**
* Create a "fake" symlink (text file containing the target path).