Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion libmpq/mpq.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "common.h"

/* generic includes. */
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -91,10 +92,11 @@ int32_t libmpq__archive_open(mpq_archive_s **mpq_archive, const char *mpq_filena
}

/* check if file exists and is readable */
errno = 0;
if (((*mpq_archive)->fp = fopen(mpq_filename, "rb")) == NULL) {

/* file could not be opened. */
result = LIBMPQ_ERROR_OPEN;
result = errno == ENOENT ? LIBMPQ_ERROR_EXIST : LIBMPQ_ERROR_OPEN;
goto error;
}

Expand Down
2 changes: 1 addition & 1 deletion libmpq/mpq.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern "C" {
#define LIBMPQ_ERROR_FORMAT -7 /* format errror. */
#define LIBMPQ_ERROR_NOT_INITIALIZED -8 /* libmpq__init() wasn't called. */
#define LIBMPQ_ERROR_SIZE -9 /* buffer size is to small. */
#define LIBMPQ_ERROR_EXIST -10 /* file or block does not exist in archive. */
#define LIBMPQ_ERROR_EXIST -10 /* archive does not exist, or file or block does not exist in archive. */
#define LIBMPQ_ERROR_DECRYPT -11 /* we don't know the decryption seed. */
#define LIBMPQ_ERROR_UNPACK -12 /* error on unpacking file. */

Expand Down