From: Michael Tremer Date: Sat, 26 Oct 2024 12:24:42 +0000 (+0000) Subject: path: Move pakfire_path_realpath X-Git-Tag: 0.9.30~841 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d4f34f7569ef9c502d35c42539746e1a8b2d196c;p=pakfire.git path: Move pakfire_path_realpath Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/include/pakfire/path.h b/src/libpakfire/include/pakfire/path.h index a8d1339ac..e67f8313c 100644 --- a/src/libpakfire/include/pakfire/path.h +++ b/src/libpakfire/include/pakfire/path.h @@ -59,4 +59,8 @@ int pakfire_path_match(const char* p, const char* s); __pakfire_path_replace_extension(path, sizeof(path), extension) int __pakfire_path_replace_extension(char* path, const size_t length, const char* extension); +#define pakfire_path_realpath(dest, path) \ + __pakfire_path_realpath(dest, sizeof(dest), path) +int __pakfire_path_realpath(char* dest, const size_t length, const char* path); + #endif /* PAKFIRE_PATH_H */ diff --git a/src/libpakfire/include/pakfire/util.h b/src/libpakfire/include/pakfire/util.h index 16c33bb7f..22d781a7e 100644 --- a/src/libpakfire/include/pakfire/util.h +++ b/src/libpakfire/include/pakfire/util.h @@ -63,10 +63,6 @@ int __pakfire_unhexlify(unsigned char* dst, const size_t l, const char* src); const char* pakfire_path_relpath(const char* root, const char* path); -#define pakfire_path_realpath(dest, path) \ - __pakfire_path_realpath(dest, sizeof(dest), path) -int __pakfire_path_realpath(char* dest, const size_t length, const char* path); - // File stuff int pakfire_file_write(struct pakfire* pakfire, const char* path, diff --git a/src/libpakfire/path.c b/src/libpakfire/path.c index 5e820aa8a..cc0a37153 100644 --- a/src/libpakfire/path.c +++ b/src/libpakfire/path.c @@ -667,3 +667,14 @@ int __pakfire_path_replace_extension(char* path, const size_t length, const char // Compose the new string return __pakfire_string_format(path, length, "%s.%s", buffer, extension); } + +int __pakfire_path_realpath(char* dest, const size_t length, const char* path) { + char buffer[PATH_MAX]; + + // Resolve path to its absolute path and store it in buffer + char* p = realpath(path, buffer); + if (!p) + return 1; + + return __pakfire_string_set(dest, length, buffer); +} diff --git a/src/libpakfire/util.c b/src/libpakfire/util.c index 0c709d731..1464b1e97 100644 --- a/src/libpakfire/util.c +++ b/src/libpakfire/util.c @@ -68,17 +68,6 @@ const char* pakfire_path_relpath(const char* root, const char* path) { return NULL; } -int __pakfire_path_realpath(char* dest, const size_t length, const char* path) { - char buffer[PATH_MAX]; - - // Resolve path to its absolute path and store it in buffer - char* p = realpath(path, buffer); - if (!p) - return 1; - - return __pakfire_string_set(dest, length, buffer); -} - int pakfire_path_exists(const char* path) { return !access(path, F_OK); }