Skip to content

Commit

Permalink
Refactor to use RCUTILS_PATH_DELIMITER
Browse files Browse the repository at this point in the history
  • Loading branch information
ruffsl committed Sep 19, 2018
1 parent 95ad53f commit 7319110
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/filesystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ extern "C"
#include "rcutils/format_string.h"
#include "rcutils/repl_str.h"

#ifdef _WIN32
# define RCUTILS_PATH_DELIMITER "\\"
#else
# define RCUTILS_PATH_DELIMITER "/"
#endif // _WIN32

bool
rcutils_get_cwd(char * buffer, size_t max_length)
{
Expand Down Expand Up @@ -153,13 +159,7 @@ rcutils_join_path(
return NULL;
}

#ifdef _WIN32
const char * delimiter = "\\";
#else
const char * delimiter = "/";
#endif // _WIN32

return rcutils_format_string(allocator, "%s%s%s", left_hand_path, delimiter, right_hand_path);
return rcutils_format_string(allocator, "%s%s%s", left_hand_path, RCUTILS_PATH_DELIMITER, right_hand_path);
}

char *
Expand All @@ -171,13 +171,7 @@ rcutils_norm_path(
return NULL;
}

#ifdef _WIN32
const char * delimiter = "\\";
#else
const char * delimiter = "/";
#endif // _WIN32

return rcutils_repl_str(path, "/", delimiter, &allocator);
return rcutils_repl_str(path, "/", RCUTILS_PATH_DELIMITER, &allocator);
}

#ifdef __cplusplus
Expand Down

0 comments on commit 7319110

Please sign in to comment.