diff options
| author | Vicent Martà <vicent@github.com> | 2013-09-17 10:21:22 -0700 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2013-09-17 10:21:22 -0700 |
| commit | 3d4f169867faf79abcfdff6667b361d88bb2e3b3 (patch) | |
| tree | 89e3162ae00a27e2a63f947b27fe0fa80a2fa247 /src/fileops.c | |
| parent | bb371b62e950e3307d3acf2f772495a60565d266 (diff) | |
| parent | a025907e0d751ed1022e65365243ae97acf3f598 (diff) | |
| download | libgit2-3d4f169867faf79abcfdff6667b361d88bb2e3b3.tar.gz | |
Merge pull request #1858 from linquize/win32-template-dir
Configurable template dir for Win32
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/fileops.c b/src/fileops.c index bd845e982..5a5041cc3 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -583,7 +583,7 @@ clean_up: static int git_futils_guess_system_dirs(git_buf *out) { #ifdef GIT_WIN32 - return git_win32__find_system_dirs(out); + return git_win32__find_system_dirs(out, L"etc\\"); #else return git_buf_sets(out, "/etc"); #endif @@ -615,15 +615,25 @@ static int git_futils_guess_xdg_dirs(git_buf *out) #endif } +static int git_futils_guess_template_dirs(git_buf *out) +{ +#ifdef GIT_WIN32 + return git_win32__find_system_dirs(out, L"share\\git-core\\templates"); +#else + return git_buf_sets(out, "/usr/share/git-core/templates"); +#endif +} + typedef int (*git_futils_dirs_guess_cb)(git_buf *out); static git_buf git_futils__dirs[GIT_FUTILS_DIR__MAX] = - { GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT }; + { GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT, GIT_BUF_INIT }; static git_futils_dirs_guess_cb git_futils__dir_guess[GIT_FUTILS_DIR__MAX] = { git_futils_guess_system_dirs, git_futils_guess_global_dirs, git_futils_guess_xdg_dirs, + git_futils_guess_template_dirs, }; static void git_futils_dirs_global_shutdown(void) @@ -746,7 +756,8 @@ static int git_futils_find_in_dirlist( continue; GITERR_CHECK_ERROR(git_buf_set(path, scan, len)); - GITERR_CHECK_ERROR(git_buf_joinpath(path, path->ptr, name)); + if (name) + GITERR_CHECK_ERROR(git_buf_joinpath(path, path->ptr, name)); if (git_path_exists(path->ptr)) return 0; @@ -775,6 +786,12 @@ int git_futils_find_xdg_file(git_buf *path, const char *filename) path, filename, GIT_FUTILS_DIR_XDG, "global/xdg"); } +int git_futils_find_template_dir(git_buf *path) +{ + return git_futils_find_in_dirlist( + path, NULL, GIT_FUTILS_DIR_TEMPLATE, "template"); +} + int git_futils_fake_symlink(const char *old, const char *new) { int retcode = GIT_ERROR; |
