From 3573df534f1cc43abc18cd416e4536edbb2e062b Mon Sep 17 00:00:00 2001 From: Frode Solheim Date: Sat, 5 Sep 2015 10:40:27 +0200 Subject: [PATCH] use uae_tfopen instead of _tfopen (FS-UAE uses a custom fopen function) --- debug.cpp | 3 ++- epsonprinter.cpp | 5 +++-- fsdb.cpp | 5 +++-- include/uae/io.h | 13 +++++++++++++ moduleripper.cpp | 5 +++-- zfile.cpp | 7 ++++--- 6 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 include/uae/io.h diff --git a/debug.cpp b/debug.cpp index 82e20e3e..dc73b731 100644 --- a/debug.cpp +++ b/debug.cpp @@ -41,6 +41,7 @@ #include "ar.h" #include "pci.h" #include "ppc/ppcd.h" +#include "uae/io.h" #include "uae/ppc.h" int debugger_active; @@ -3735,7 +3736,7 @@ static void savemem (TCHAR **cc) if (!more_params (cc)) goto S_argh; len2 = len = readhex (cc); - fp = _tfopen (name, _T("wb")); + fp = uae_tfopen (name, _T("wb")); if (fp == NULL) { console_out_f (_T("Couldn't open file '%s'\n"), name); return; diff --git a/epsonprinter.cpp b/epsonprinter.cpp index a5adcbff..84dd2cc2 100644 --- a/epsonprinter.cpp +++ b/epsonprinter.cpp @@ -33,6 +33,7 @@ #include "win32.h" #include "parser.h" #include "threaddep/thread.h" +#include "uae/io.h" #include @@ -680,7 +681,7 @@ static void getfname (TCHAR *fname) for (;;) { FILE *fp; _stprintf (fname, _T("%sPRINT_%03d.png"), tmp, number); - if ((fp = _tfopen (fname, _T("rb"))) == NULL) + if ((fp = uae_tfopen(fname, _T("rb"))) == NULL) return; number++; fclose (fp); @@ -797,7 +798,7 @@ static void *prt_thread (void *p) getfname (fname); /* Open the actual file */ - fp=_tfopen(fname,_T("wb")); + fp = uae_tfopen(fname, _T("wb")); if (!fp) { write_log(_T("EPSONPRINTER: Can't open file %s for printer output\n"), fname); diff --git a/fsdb.cpp b/fsdb.cpp index 45bb3627..4bfaa51c 100644 --- a/fsdb.cpp +++ b/fsdb.cpp @@ -20,6 +20,7 @@ #include "fsusage.h" #include "scsidev.h" #include "fsdb.h" +#include "uae/io.h" /* The on-disk format is as follows: * Offset 0, 1 byte, valid @@ -81,7 +82,7 @@ static FILE *get_fsdb (a_inode *dir, const TCHAR *mode) if (!dir->nname) return NULL; n = build_nname (dir->nname, FSDB_FILE); - f = _tfopen (n, mode); + f = uae_tfopen (n, mode); xfree (n); return f; } @@ -127,7 +128,7 @@ void fsdb_clean_dir (a_inode *dir) if (!dir->nname) return; n = build_nname (dir->nname, FSDB_FILE); - f = _tfopen (n, _T("r+b")); + f = uae_tfopen (n, _T("r+b")); if (f == 0) { xfree (n); return; diff --git a/include/uae/io.h b/include/uae/io.h new file mode 100644 index 00000000..34be1838 --- /dev/null +++ b/include/uae/io.h @@ -0,0 +1,13 @@ +#ifndef UAE_IO_H +#define UAE_IO_H + +#include "uae/types.h" +#include + +#ifdef WINUAE +#define uae_tfopen _tfopen +#else +FILE *uae_tfopen(const TCHAR *path, const TCHAR *mode); +#endif + +#endif /* UAE_IO_H */ diff --git a/moduleripper.cpp b/moduleripper.cpp index 50014d99..5323858b 100644 --- a/moduleripper.cpp +++ b/moduleripper.cpp @@ -12,7 +12,9 @@ #ifdef PROWIZARD #include "options.h" +#include "uae/io.h" #include "memory.h" +#include "uae/seh.h" #include "moduleripper.h" #include "gui.h" #include "uae.h" @@ -139,7 +141,7 @@ FILE *moduleripper_fopen (const char *aname, const char *amode) moduleripper_filename(aname, outname, true); mode = au (amode); - f = _tfopen (outname, mode); + f = uae_tfopen (outname, mode); xfree (mode); return f; } @@ -170,7 +172,6 @@ FILE *moduleripper2_fopen (const char *name, const char *mode, const char *aid, void pw_write_log (const char *format,...) { } - } #else diff --git a/zfile.cpp b/zfile.cpp index e530bfbc..bf6c5fac 100644 --- a/zfile.cpp +++ b/zfile.cpp @@ -23,6 +23,7 @@ #include "zarchive.h" #include "diskutil.h" #include "fdi2raw.h" +#include "uae/io.h" #include "archivers/zip/unzip.h" #include "archivers/dms/pfile.h" @@ -1619,7 +1620,7 @@ static struct zfile *zfile_fopen_nozip (const TCHAR *name, const TCHAR *mode) l = zfile_create (NULL, name); l->name = my_strdup (name); l->mode = my_strdup (mode); - f = _tfopen (name, mode); + f = uae_tfopen (name, mode); if (!f) { zfile_fclose (l); return 0; @@ -1699,7 +1700,7 @@ static struct zfile *zfile_fopen_2 (const TCHAR *name, const TCHAR *mode, int ma f = my_opentext (l->name); l->textmode = 1; } else { - f = _tfopen (l->name, mode); + f = uae_tfopen (l->name, mode); } if (!f) { zfile_fclose (l); @@ -1992,7 +1993,7 @@ struct zfile *zfile_dup (struct zfile *zf) } if (!zf->name || !zf->mode) return NULL; - FILE *ff = _tfopen (zf->name, zf->mode); + FILE *ff = uae_tfopen (zf->name, zf->mode); if (!ff) return NULL; nzf = zfile_create (zf, NULL); -- 2.47.3