Commit 04fdc10d by Romain Geissler

Fileops:retrieve_path_root_offset is now named gitfo_retrieve_path_root_offset…

Fileops:retrieve_path_root_offset is now named gitfo_retrieve_path_root_offset (like other public functions). Added platform specific directory separator definition.
parent 1e9b7a09
...@@ -301,8 +301,19 @@ int gitfo_dirent( ...@@ -301,8 +301,19 @@ int gitfo_dirent(
return GIT_SUCCESS; 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; int offset = 0;
...@@ -320,7 +331,6 @@ int retrieve_path_root_offset(const char *path) ...@@ -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 */ 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 gitfo_mkdir_recurs(const char *path, int mode)
{ {
int error, root_path_offset; int error, root_path_offset;
...@@ -333,7 +343,7 @@ int gitfo_mkdir_recurs(const char *path, int mode) ...@@ -333,7 +343,7 @@ int gitfo_mkdir_recurs(const char *path, int mode)
error = GIT_SUCCESS; error = GIT_SUCCESS;
pp = path_copy; 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) if (root_path_offset > 0)
pp += root_path_offset; /* On Windows, will skip the drive name (eg. C: or D:) */ 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) ...@@ -367,7 +377,7 @@ static int retrieve_previous_path_component_start(const char *path)
{ {
int offset, len, root_offset, start = 0; 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) if (root_offset > -1)
start += root_offset; start += root_offset;
...@@ -402,7 +412,7 @@ int gitfo_prettify_dir_path(char *buffer_out, size_t size, const char *path) ...@@ -402,7 +412,7 @@ int gitfo_prettify_dir_path(char *buffer_out, size_t size, const char *path)
buffer_end = path + strlen(path); buffer_end = path + strlen(path);
buffer_out_start = buffer_out; 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) { if (root_path_offset < 0) {
error = gitfo_getcwd(buffer_out, size); error = gitfo_getcwd(buffer_out, size);
if (error < GIT_SUCCESS) if (error < GIT_SUCCESS)
...@@ -519,16 +529,6 @@ int gitfo_cmp_path(const char *name1, int len1, int isdir1, ...@@ -519,16 +529,6 @@ int gitfo_cmp_path(const char *name1, int len1, int isdir1,
return 0; return 0;
} }
static void posixify_path(char *path)
{
while (*path) {
if (*path == '\\')
*path = '/';
path++;
}
}
int gitfo_getcwd(char *buffer_out, size_t size) int gitfo_getcwd(char *buffer_out, size_t size)
{ {
char *cwd_buffer; char *cwd_buffer;
......
...@@ -12,6 +12,14 @@ ...@@ -12,6 +12,14 @@
#include <fcntl.h> #include <fcntl.h>
#include <time.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 #ifdef GIT_WIN32
GIT_INLINE(int) link(const char *GIT_UNUSED(old), const char *GIT_UNUSED(new)) 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); ...@@ -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 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__ */ #endif /* INCLUDE_fileops_h__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment