Pakfire pakfire;
int nrefs;
- char path[PATH_MAX];
+ const char* path;
+ char abspath[PATH_MAX];
char type;
ssize_t size;
return file->path;
}
-PAKFIRE_EXPORT void pakfire_file_set_path(PakfireFile file, const char* path) {
- snprintf(file->path, sizeof(file->path) - 1, "%s", path);
+PAKFIRE_EXPORT int pakfire_file_set_path(PakfireFile file, const char* path) {
+ char* p = pakfire_make_path(file->pakfire, path);
+ if (!p)
+ return 1;
+
+ // Copy to abspath
+ snprintf(file->abspath, sizeof(file->abspath) - 1, "%s", p);
+ free(p);
+
+ // Store relative path
+ file->path = file->abspath + strlen(file->abspath) - strlen(path);
+
+ return 0;
}
PAKFIRE_EXPORT char* pakfire_file_get_dirname(PakfireFile file) {
int pakfire_file_copy_stat(PakfireFile file, struct stat* stat);
const char* pakfire_file_get_path(PakfireFile file);
-void pakfire_file_set_path(PakfireFile file, const char* path);
+int pakfire_file_set_path(PakfireFile file, const char* path);
char* pakfire_file_get_dirname(PakfireFile file);
char* pakfire_file_get_basename(PakfireFile file);