summaryrefslogtreecommitdiff
path: root/src/fileops.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2011-03-15 22:07:01 +0100
committerVicent Marti <tanoku@gmail.com>2011-03-23 00:17:24 +0200
commit677a3c07f47f46dcbab4a3ee8a1e2aace6f999b0 (patch)
tree9e638926a6d72f963d5102b676d574702b8d36c3 /src/fileops.c
parentae6ba7f713804e1c04febee81a8f52ea0abf443b (diff)
downloadlibgit2-677a3c07f47f46dcbab4a3ee8a1e2aace6f999b0.tar.gz
Add failing test for issue 84
see https://github.com/libgit2/libgit2/issues#issue/84
Diffstat (limited to 'src/fileops.c')
-rw-r--r--src/fileops.c31
1 files changed, 31 insertions, 0 deletions
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;
+}