Skip to content

Commit 0b5f65d

Browse files
committed
Add jerry_module_path_join_and_normalize far more simplified
1 parent 8339d8b commit 0b5f65d

File tree

4 files changed

+571
-93
lines changed

4 files changed

+571
-93
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,12 @@ if(ENABLE_TESTS)
160160
create_test(DEFAULT join navigate_back)
161161
create_test(DEFAULT join empty)
162162
create_test(DEFAULT join two_absolute)
163+
create_test(DEFAULT join two_absolute_module)
163164
create_test(DEFAULT join two_unc)
164165
create_test(DEFAULT join with_two_roots)
165166
create_test(DEFAULT join back_after_root)
166167
create_test(DEFAULT join relative_back_after_root)
168+
create_test(DEFAULT join relative_back_after_root_module)
167169
create_test(DEFAULT join multiple)
168170
create_test(DEFAULT normalize do_nothing)
169171
create_test(DEFAULT normalize navigate_back)

include/cpj.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,29 @@ CPJ_PUBLIC size_t cpj_path_get_relative(enum cpj_path_style path_style,
141141
CPJ_PUBLIC size_t cpj_path_join(enum cpj_path_style path_style,
142142
const char *path_a, const char *path_b, char *buffer, size_t buffer_size);
143143

144+
/**
145+
* @brief Joins two paths together.
146+
*
147+
* This function generates a new path by combining the two submitted paths. It
148+
* will remove double separators, and unlike cpj_path_get_absolute it permits
149+
* the use of two relative paths to combine. The result will be written to a
150+
* buffer, which might be truncated if the buffer is not large enough to hold
151+
* the full path. However, the truncated result will always be
152+
* null-terminated. The returned value is the amount of characters which the
153+
* resulting path would take if it was not truncated (excluding the
154+
* null-terminating character).
155+
*
156+
* @param path_style Style depending on the operating system. So this should
157+
* detect whether we should use windows or unix paths.
158+
* @param path_a The first path which comes first.
159+
* @param path_b The second path which comes after the first.
160+
* @param buffer The buffer where the result will be written to.
161+
* @param buffer_size The size of the result buffer.
162+
* @return Returns the total amount of characters of the full, combined path.
163+
*/
164+
CPJ_PUBLIC size_t cpj_path_join_module(enum cpj_path_style path_style,
165+
const char *path_a, const char *path_b, char *buffer, size_t buffer_size);
166+
144167
/**
145168
* @brief Joins multiple paths together.
146169
*

0 commit comments

Comments
 (0)