struct archive_entry* entry = NULL;
int r = 1;
+ // Root must be absolute
+ if (!pakfire_path_is_absolute(root)) {
+ errno = EINVAL;
+ return 1;
+ }
+
DEBUG(list->pakfire, "Scanning %s...\n", root);
if (includes) {
if (!tree)
goto ERROR;
- FTSENT* node;
+ FTSENT* node = NULL;
+ const char* path = NULL;
+
while ((node = fts_read(tree))) {
// Ignore any directories in post order
if (node->fts_info == FTS_DP)
continue;
// Compute the relative path
- const char* path = pakfire_path_relpath(root, node->fts_path);
+ path = pakfire_path_relpath(root, node->fts_path);
if (!path || !*path)
continue;
__pakfire_path_join(dest, sizeof(dest), first, second)
int __pakfire_path_join(char* dest, const size_t length,
const char* first, const char* second);
+int pakfire_path_is_absolute(const char* path);
const char* pakfire_path_abspath(const char* path);
const char* pakfire_path_relpath(const char* root, const char* path);
return __pakfire_string_format(dest, length, "%s/%s", first, second);
}
+int pakfire_path_is_absolute(const char* path) {
+ if (!path) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return (*path == '/');
+}
+
const char* pakfire_path_abspath(const char* path) {
static char buffer[PATH_MAX];
int r;