File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -983,15 +983,15 @@ char* __clove_path_to_absolute(const char* rel_path) {
983
983
984
984
//case where rel_path not really exists on fs
985
985
//(in this case only the first subpath of the rel_path is added by realpath)
986
- if (!__clove_string_endswith (rel_path )) {
986
+ if (!__clove_string_endswith (result , rel_path )) {
987
987
if (__clove_path_is_absolute (rel_path )) {
988
- __clove_string_strcpy (result , _MAX_PATH , rel_path );
988
+ __clove_string_strcpy (result , PATH_MAX , rel_path );
989
989
} else { //relative
990
- realpath (result , "." );
990
+ realpath ("." , result );
991
991
if (!__clove_string_endswith (result , "/" )) {
992
- __clove_string_strcat (result , _MAX_PATH , "/" );
992
+ __clove_string_strcat (result , PATH_MAX , "/" );
993
993
}
994
- __clove_string_strcat (result , _MAX_PATH , rel_path );
994
+ __clove_string_strcat (result , PATH_MAX , rel_path );
995
995
}
996
996
}
997
997
#endif
Original file line number Diff line number Diff line change @@ -82,7 +82,7 @@ CLOVE_TEST(GetRelativePathFromAbsPath) {
82
82
CLOVE_STRING_EQ (abs_path , result );
83
83
}
84
84
85
- CLOVE_TEST (ConvertToAbsolutePath ) {
85
+ CLOVE_TEST (ConvertAbsToAbsolutePath ) {
86
86
char * result = __clove_path_to_absolute ("/abs/path/file.c" );
87
87
88
88
#ifdef _WIN32
@@ -95,3 +95,16 @@ CLOVE_TEST(ConvertToAbsolutePath) {
95
95
__clove_memory_free (result );
96
96
}
97
97
98
+ CLOVE_TEST (ConvertRelToAbsolutePath ) {
99
+ char * result = __clove_path_to_absolute ("rel/path/file.c" );
100
+
101
+ #ifdef _WIN32
102
+ const char * result_without_unit = result + 2 ; //e.g. c:\abs\path\file.c => \abs\path\file.c
103
+ CLOVE_STRING_EQ ("\\rel\\path\\file.c" , result_without_unit );
104
+ #else
105
+ CLOVE_IS_TRUE (__clove_string_startswith (result , "/" ));
106
+ CLOVE_IS_TRUE (__clove_string_endswith (result , "/rel/path/file.c" ));
107
+ #endif
108
+
109
+ __clove_memory_free (result );
110
+ }
You can’t perform that action at this time.
0 commit comments