]> git.draconx.ca Git - liblbx.git/blobdiff - src/lbx.c
liblbx: Properly report errors in lbx_(img_)fopen.
[liblbx.git] / src / lbx.c
index 57a72b082e70158ff8abd6d2205f90cce4f13caa..a2d37961a77d33b95d8761a5a1216913ce4e9d33 100644 (file)
--- a/src/lbx.c
+++ b/src/lbx.c
@@ -1,7 +1,7 @@
 /*
  *  2ooM: The Master of Orion II Reverse Engineering Project
  *  Library for working with LBX archive files.
- *  Copyright (C) 2006-2010 Nick Bowler
+ *  Copyright © 2006-2010, 2013 Nick Bowler
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -166,14 +166,17 @@ struct lbx *lbx_fopen(const char *file)
        FILE *f;
 
        f = fopen(file, "rb");
-       if (!f)
+       if (!f) {
+               lbx_error_raise(-errno);
                return NULL;
+       }
 
        if (fseek(f, 0, SEEK_CUR) == 0)
                return lbx_open(f, &lbx_default_fops, file_close, name);
 
        p = malloc(sizeof *p);
        if (!p) {
+               lbx_error_raise(LBX_ENOMEM);
                fclose(f);
                return NULL;
        }