int r;
// Check input
- if (!file) {
- errno = EINVAL;
- return 1;
- }
+ if (!file)
+ return -EINVAL;
// Fetch path
const char* path = pakfire_file_get_path(file);
// Files cannot have an empty path
if (!path || !*path) {
ERROR(packager->ctx, "Cannot add a file with an empty path\n");
- errno = EPERM;
- return 1;
+ return -EPERM;
// Hidden files cannot be added
} else if (*path == '.') {
ERROR(packager->ctx, "Hidden files cannot be added to a package: %s\n", path);
- errno = EPERM;
- return 1;
+ return -EPERM;
}
DEBUG(packager->ctx, "Adding file to payload: %s\n", path);
// Detect the MIME type
r = pakfire_file_detect_mimetype(file);
- if (r)
+ if (r < 0)
return r;
// Overwrite a couple of things for source archives
int pakfire_packager_add_scriptlet(struct pakfire_packager* packager,
struct pakfire_scriptlet* scriptlet) {
- if (!scriptlet) {
- errno = EINVAL;
- return 1;
- }
+ if (!scriptlet)
+ return -EINVAL;
// Extend array
packager->scriptlets = reallocarray(packager->scriptlets,
packager->num_scriptlets + 1, sizeof(*packager->scriptlets));
if (!packager->scriptlets)
- return 1;
+ return -errno;
// Append scriptlet
packager->scriptlets[packager->num_scriptlets++] = pakfire_scriptlet_ref(scriptlet);