Selectively replace fopen() with fopen_utf8()
[pcsx_rearmed.git] / libpcsxcore / cdriso.c
index 9e70ddf..c36c196 100644 (file)
@@ -19,6 +19,8 @@
  *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
  ***************************************************************************/
 
+#include <compat/fopen_utf8.h>
+
 #include "psxcommon.h"
 #include "plugins.h"
 #include "cdrom.h"
@@ -334,16 +336,16 @@ static int parsetoc(const char *isofile) {
                return -1;
        }
 
-       if ((fi = fopen(tocname, "r")) == NULL) {
+       if ((fi = fopen_utf8(tocname, "r")) == NULL) {
                // try changing extension to .cue (to satisfy some stupid tutorials)
                strcpy(tocname + strlen(tocname) - 4, ".cue");
-               if ((fi = fopen(tocname, "r")) == NULL) {
+               if ((fi = fopen_utf8(tocname, "r")) == NULL) {
                        // if filename is image.toc.bin, try removing .bin (for Brasero)
                        strcpy(tocname, isofile);
                        t = strlen(tocname);
                        if (t >= 8 && strcmp(tocname + t - 8, ".toc.bin") == 0) {
                                tocname[t - 4] = '\0';
-                               if ((fi = fopen(tocname, "r")) == NULL) {
+                               if ((fi = fopen_utf8(tocname, "r")) == NULL) {
                                        return -1;
                                }
                        }
@@ -486,7 +488,7 @@ static int parsecue(const char *isofile) {
                return -1;
        }
 
-       if ((fi = fopen(cuename, "r")) == NULL) {
+       if ((fi = fopen_utf8(cuename, "r")) == NULL) {
                return -1;
        }
 
@@ -590,7 +592,7 @@ static int parsecue(const char *isofile) {
                        else
                                tmp = tmpb;
                        strncpy(incue_fname, tmp, incue_max_len);
-                       ti[numtracks + 1].handle = fopen(filepath, "rb");
+                       ti[numtracks + 1].handle = fopen_utf8(filepath, "rb");
 
                        // update global offset if this is not first file in this .cue
                        if (numtracks + 1 > 1) {
@@ -611,7 +613,7 @@ static int parsecue(const char *isofile) {
                                strncasecmp(isofile + strlen(isofile) - 4, ".cd", 3) == 0)) {
                                // user selected .cue/.cdX as image file, use it's data track instead
                                fclose(cdHandle);
-                               cdHandle = fopen(filepath, "rb");
+                               cdHandle = fopen_utf8(filepath, "rb");
                        }
                }
        }
@@ -645,7 +647,7 @@ static int parseccd(const char *isofile) {
                return -1;
        }
 
-       if ((fi = fopen(ccdname, "r")) == NULL) {
+       if ((fi = fopen_utf8(ccdname, "r")) == NULL) {
                return -1;
        }
 
@@ -704,7 +706,7 @@ static int parsemds(const char *isofile) {
                return -1;
        }
 
-       if ((fi = fopen(mdsname, "rb")) == NULL) {
+       if ((fi = fopen_utf8(mdsname, "rb")) == NULL) {
                return -1;
        }
 
@@ -1144,7 +1146,7 @@ static int opensubfile(const char *isoname) {
                return -1;
        }
 
-       subHandle = fopen(subname, "rb");
+       subHandle = fopen_utf8(subname, "rb");
        if (subHandle == NULL) {
                return -1;
        }
@@ -1623,7 +1625,7 @@ static long CALLBACK ISOopen(void) {
                return 0; // it's already open
        }
 
-       cdHandle = fopen(GetIsoFile(), "rb");
+       cdHandle = fopen_utf8(GetIsoFile(), "rb");
        if (cdHandle == NULL) {
                SysPrintf(_("Could't open '%s' for reading: %s\n"),
                        GetIsoFile(), strerror(errno));
@@ -1695,7 +1697,7 @@ static long CALLBACK ISOopen(void) {
                        p = alt_bin_filename + strlen(alt_bin_filename) - 4;
                        for (i = 0; i < sizeof(exts) / sizeof(exts[0]); i++) {
                                strcpy(p, exts[i]);
-                               tmpf = fopen(alt_bin_filename, "rb");
+                               tmpf = fopen_utf8(alt_bin_filename, "rb");
                                if (tmpf != NULL)
                                        break;
                        }
@@ -1731,7 +1733,7 @@ static long CALLBACK ISOopen(void) {
 
        // make sure we have another handle open for cdda
        if (numtracks > 1 && ti[1].handle == NULL) {
-               ti[1].handle = fopen(bin_filename, "rb");
+               ti[1].handle = fopen_utf8(bin_filename, "rb");
        }
        cdda_cur_sector = 0;
        cdda_file_offset = 0;