Pakfire pakfire;
int nrefs;
- const char* path;
+ char path[PATH_MAX];
char abspath[PATH_MAX];
char type;
ssize_t size;
}
int pakfire_file_copy_archive_entry(PakfireFile file, struct archive_entry* entry) {
+ // Set abspath
+ pakfire_file_set_abspath(file, archive_entry_sourcepath(entry));
+
// Set path
pakfire_file_set_path(file, archive_entry_pathname(entry));
return file->abspath;
}
+int pakfire_file_set_abspath(PakfireFile file, const char* path) {
+ return snprintf(file->abspath, sizeof(file->abspath) - 1, "%s", path);
+}
+
PAKFIRE_EXPORT const char* pakfire_file_get_path(PakfireFile file) {
return file->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;
+ return snprintf(file->path, sizeof(file->path) - 1, "%s", path);
}
PAKFIRE_EXPORT int pakfire_file_get_type(PakfireFile file) {
int pakfire_file_copy_archive_entry(PakfireFile file, struct archive_entry* entry);
const char* pakfire_file_get_abspath(PakfireFile file);
+int pakfire_file_set_abspath(PakfireFile file, const char* path);
+
FILE* pakfire_file_fopen(PakfireFile file, const char* mode);
#endif