static int pakfire_db_load_file(struct pakfire_db* db, struct pakfire_filelist* filelist,
sqlite3_stmt* stmt) {
struct pakfire_file* file = NULL;
- char abspath[PATH_MAX];
int r;
// Create a new file object
if (path)
pakfire_file_set_path(file, path);
- // Abspath
- r = pakfire_path(db->pakfire, abspath, "%s", path);
- if (r)
- goto ERROR;
-
- pakfire_file_set_abspath(file, abspath);
-
// Size
size_t size = sqlite3_column_int64(stmt, 1);
if (size)
}
PAKFIRE_EXPORT int pakfire_file_set_path(struct pakfire_file* file, const char* path) {
+ int r;
+
// Check if path is set and absolute
if (!path || *path != '/') {
errno = EINVAL;
return 1;
}
- return pakfire_string_set(file->path, path);
+ // Store path
+ r = pakfire_string_set(file->path, path);
+ if (r)
+ return r;
+
+ // Set abspath if it isn't set, yet
+ if (!*file->abspath) {
+ r = pakfire_path(file->pakfire, file->abspath, "%s", path);
+ if (r)
+ return r;
+ }
+
+ return r;
}
PAKFIRE_EXPORT const char* pakfire_file_get_hardlink(struct pakfire_file* file) {