From 677a3c07f47f46dcbab4a3ee8a1e2aace6f999b0 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Tue, 15 Mar 2011 22:07:01 +0100 Subject: Add failing test for issue 84 see https://github.com/libgit2/libgit2/issues#issue/84 --- src/fileops.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/fileops.c') diff --git a/src/fileops.c b/src/fileops.c index a884b4002..4ed53bc97 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -633,3 +633,34 @@ int gitfo_cmp_path(const char *name1, int len1, int isdir1, return 0; } +static void posixify_path(char *path) +{ + while (*path) { + if (*path == '\\') + *path = '/'; + + path++; + } +} + +int gitfo_getcwd(char *buffer_out, size_t size) +{ + char *cwd_buffer; + + assert(buffer_out && size > 0); + +#ifdef GIT_WIN32 + cwd_buffer = _getcwd(buffer_out, size); +#else + cwd_buffer = getcwd(buffer_out, size); //TODO: Fixme. Ensure the required headers are correctly included +#endif + + if (cwd_buffer == NULL) + return GIT_EOSERR; + + posixify_path(buffer_out); + + git__joinpath(buffer_out, buffer_out, ""); //Ensure the path ends with a trailing slash + + return GIT_SUCCESS; +} -- cgit v1.2.1