Fileops:retrieve_path_root_offset is now named gitfo_retrieve_path_root_offset (like other public functions). Added platform specific directory separator definition.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
diff --git a/src/fileops.c b/src/fileops.c
index 7393934..da4e97e 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -301,8 +301,19 @@ int gitfo_dirent(
return GIT_SUCCESS;
}
+static void posixify_path(char *path)
+{
+ #if GIT_PLATFORM_PATH_SEP != '/'
+ while (*path) {
+ if (*path == GIT_PLATFORM_PATH_SEP)
+ *path = '/';
+
+ path++;
+ }
+ #endif
+}
-int retrieve_path_root_offset(const char *path)
+int gitfo_retrieve_path_root_offset(const char *path)
{
int offset = 0;
@@ -320,7 +331,6 @@ int retrieve_path_root_offset(const char *path)
return -1; /* Not a real error. Rather a signal than the path is not rooted */
}
-
int gitfo_mkdir_recurs(const char *path, int mode)
{
int error, root_path_offset;
@@ -333,7 +343,7 @@ int gitfo_mkdir_recurs(const char *path, int mode)
error = GIT_SUCCESS;
pp = path_copy;
- root_path_offset = retrieve_path_root_offset(pp);
+ root_path_offset = gitfo_retrieve_path_root_offset(pp);
if (root_path_offset > 0)
pp += root_path_offset; /* On Windows, will skip the drive name (eg. C: or D:) */
@@ -367,7 +377,7 @@ static int retrieve_previous_path_component_start(const char *path)
{
int offset, len, root_offset, start = 0;
- root_offset = retrieve_path_root_offset(path);
+ root_offset = gitfo_retrieve_path_root_offset(path);
if (root_offset > -1)
start += root_offset;
@@ -402,7 +412,7 @@ int gitfo_prettify_dir_path(char *buffer_out, size_t size, const char *path)
buffer_end = path + strlen(path);
buffer_out_start = buffer_out;
- root_path_offset = retrieve_path_root_offset(path);
+ root_path_offset = gitfo_retrieve_path_root_offset(path);
if (root_path_offset < 0) {
error = gitfo_getcwd(buffer_out, size);
if (error < GIT_SUCCESS)
@@ -519,16 +529,6 @@ 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;
diff --git a/src/fileops.h b/src/fileops.h
index d0381b6..0334bb1 100644
--- a/src/fileops.h
+++ b/src/fileops.h
@@ -12,6 +12,14 @@
#include <fcntl.h>
#include <time.h>
+#define GIT_PATH_LIST_SEPARATOR ':'
+
+#ifdef GIT__WIN32
+#define GIT_PLATFORM_PATH_SEP '/'
+#else
+#define GIT_PLATFORM_PATH_SEP '\\'
+#endif
+
#ifdef GIT_WIN32
GIT_INLINE(int) link(const char *GIT_UNUSED(old), const char *GIT_UNUSED(new))
{
@@ -187,5 +195,6 @@ int gitfo_prettify_dir_path(char *buffer_out, size_t size, const char *path);
*/
int gitfo_prettify_file_path(char *buffer_out, size_t size, const char *path);
-int retrieve_path_root_offset(const char *path);
+int gitfo_retrieve_path_root_offset(const char *path);
+
#endif /* INCLUDE_fileops_h__ */