Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
int pakfire_parser_read_file(struct pakfire_parser* parser, const char* path,
struct pakfire_parser_error** error) {
+ FILE* f = NULL;
+ int r;
+
DEBUG(parser->ctx, "Parsing %s...\n", path);
- FILE* f = fopen(path, "r");
+ // Open the file
+ f = fopen(path, "r");
if (!f)
- return 1;
+ return -errno;
+
+ // Run the parser
+ r = pakfire_parser_read(parser, f, error);
- int r = pakfire_parser_read(parser, f, error);
- fclose(f);
+ // Close the file
+ if (f)
+ fclose(f);
return r;
}