Closed wrenashe closed 4 years ago
Hi @wrenashe
If I understand you correctly, you would like to generate an absolute path, using a base path and a relative path. If that's the case, cwk_path_get_absolute may be helpful:
char buffer[FILENAME_MAX];
cwk_path_get_absolute("/hello/there", "./world", buffer, sizeof(buffer));
printf("The absolute path is: %s", buffer);
// Output: The absolute path is: /hello/there/world
If you'd like to get the realpath using the current working directory, you can just pass the current working directory to the first parameter. Are you actually looking for a function which automatically applies the current working directory?
Thanks.
Could you please also add one more API, getting realpath of file from its relative file path, like void cwk_realpath_from_relative(const char relativepath, char realpath, size_t *length);
cwk_realpath_from_relative("my/mine.txt", realpath, length), once it is returned, *realpath = "/work/path/my/mine.txt"....