diff --git a/src/fileops.c b/src/fileops.c index 73939349d..da4e97efb 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 = '/'; -int retrieve_path_root_offset(const char *path) + path++; + } + #endif +} + +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 d0381b675..0334bb176 100644 --- a/src/fileops.h +++ b/src/fileops.h @@ -12,6 +12,14 @@ #include #include +#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__ */