]>
git.proxmox.com Git - libgit2.git/blob - src/sysdir.h
2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
7 #ifndef INCLUDE_sysdir_h__
8 #define INCLUDE_sysdir_h__
15 * Find a "global" file (i.e. one in a user's home directory).
17 * @param path buffer to write the full path into
18 * @param filename name of file to find in the home directory
19 * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error
21 extern int git_sysdir_find_global_file(git_buf
*path
, const char *filename
);
24 * Find an "XDG" file (i.e. one in user's XDG config path).
26 * @param path buffer to write the full path into
27 * @param filename name of file to find in the home directory
28 * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error
30 extern int git_sysdir_find_xdg_file(git_buf
*path
, const char *filename
);
33 * Find a "system" file (i.e. one shared for all users of the system).
35 * @param path buffer to write the full path into
36 * @param filename name of file to find in the home directory
37 * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error
39 extern int git_sysdir_find_system_file(git_buf
*path
, const char *filename
);
42 * Find template directory.
44 * @param path buffer to write the full path into
45 * @return 0 if found, GIT_ENOTFOUND if not found, or -1 on other OS error
47 extern int git_sysdir_find_template_dir(git_buf
*path
);
50 GIT_SYSDIR_SYSTEM
= 0,
51 GIT_SYSDIR_GLOBAL
= 1,
53 GIT_SYSDIR_TEMPLATE
= 3,
58 * Configures global data for configuration file search paths.
60 * @return 0 on success, <0 on failure
62 extern int git_sysdir_global_init(void);
65 * Get the search path for global/system/xdg files
67 * @param out pointer to git_buf containing search path
68 * @param which which list of paths to return
69 * @return 0 on success, <0 on failure
71 extern int git_sysdir_get(const git_buf
**out
, git_sysdir_t which
);
74 * Get search path into a preallocated buffer
76 * @param out String buffer to write into
77 * @param outlen Size of string buffer
78 * @param which Which search path to return
79 * @return 0 on success, GIT_EBUFS if out is too small, <0 on other failure
82 extern int git_sysdir_get_str(char *out
, size_t outlen
, git_sysdir_t which
);
85 * Set search paths for global/system/xdg files
87 * The first occurrence of the magic string "$PATH" in the new value will
88 * be replaced with the old value of the search path.
90 * @param which Which search path to modify
91 * @param paths New search path (separated by GIT_PATH_LIST_SEPARATOR)
92 * @return 0 on success, <0 on failure (allocation error)
94 extern int git_sysdir_set(git_sysdir_t which
, const char *paths
);
97 * Free the configuration file search paths.
99 extern void git_sysdir_global_shutdown(void);
101 #endif /* INCLUDE_sysdir_h__ */