···55/*****************************************************************************
66 * File name: src/devices/cassette.c *
77 * Created: 2020-04-30 by Hampa Hug <hampa@hampa.ch> *
88- * Copyright: (C) 2020-2021 Hampa Hug <hampa@hampa.ch> *
88+ * Copyright: (C) 2020-2025 Hampa Hug <hampa@hampa.ch> *
99 *****************************************************************************/
10101111/*****************************************************************************
···1515 * *
1616 * This program is distributed in the hope that it will be useful, but *
1717 * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1818+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919 * Public License for more details. *
2020 *****************************************************************************/
2121···3333#include <lib/console.h>
3434#include <lib/msg.h>
3535#include <lib/string.h>
3636+#include <lib/sysdep.h>
363737383839typedef struct {
···404405 return (NULL);
405406}
406407407407-static
408408-int cas_file_exists (const char *name)
409409-{
410410- FILE *fp;
411411-412412- if ((fp = fopen (name, "rb")) == NULL) {
413413- return (0);
414414- }
415415-416416- fclose (fp);
417417-418418- return (1);
419419-}
420420-421408int cas_set_read_name (cassette_t *cas, const char *fname)
422409{
423410 cas_set_record (cas, 0);
···477464 }
478465479466 if (create) {
480480- if (cas_file_exists (fname) == 0) {
467467+ if (pce_file_exists (fname) == 0) {
481468 if ((cas->write_img = pti_img_new()) == NULL) {
482469 return (1);
483470 }
+4-17
src/lib/inidsk.c
···55/*****************************************************************************
66 * File name: src/lib/inidsk.c *
77 * Created: 2004-12-13 by Hampa Hug <hampa@hampa.ch> *
88- * Copyright: (C) 2004-2019 Hampa Hug <hampa@hampa.ch> *
88+ * Copyright: (C) 2004-2025 Hampa Hug <hampa@hampa.ch> *
99 *****************************************************************************/
10101111/*****************************************************************************
···1515 * *
1616 * This program is distributed in the hope that it will be useful, but *
1717 * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1818+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919 * Public License for more details. *
2020 *****************************************************************************/
2121···2828#include <lib/inidsk.h>
2929#include <lib/log.h>
3030#include <lib/path.h>
3131+#include <lib/sysdep.h>
31323233#include <drivers/block/blkchd.h>
3334#include <drivers/block/blkcow.h>
···101102 return (0);
102103}
103104104104-static
105105-int file_exists (const char *name)
106106-{
107107- FILE *fp;
108108-109109- if ((fp = fopen (name, "rb")) == NULL) {
110110- return (0);
111111- }
112112-113113- fclose (fp);
114114-115115- return (1);
116116-}
117117-118105disk_t *ini_get_cow (ini_sct_t *sct, disk_t *dsk)
119106{
120107 disk_t *cow;
···129116 return (NULL);
130117 }
131118132132- if (file_exists (cname) == 0) {
119119+ if (pce_file_exists (cname) == 0) {
133120 cow = dsk_create_cow (dsk, cname, 16384);
134121 }
135122 else {
+26-2
src/lib/sysdep.c
···55/*****************************************************************************
66 * File name: src/lib/sysdep.c *
77 * Created: 2006-06-19 by Hampa Hug <hampa@hampa.ch> *
88- * Copyright: (C) 2006-2015 Hampa Hug <hampa@hampa.ch> *
88+ * Copyright: (C) 2006-2025 Hampa Hug <hampa@hampa.ch> *
99 *****************************************************************************/
10101111/*****************************************************************************
···1515 * *
1616 * This program is distributed in the hope that it will be useful, but *
1717 * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1818+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919 * Public License for more details. *
2020 *****************************************************************************/
2121···37373838#ifdef HAVE_SYS_POLL_H
3939#include <sys/poll.h>
4040+#endif
4141+4242+#ifdef HAVE_SYS_STAT_H
4343+#include <sys/stat.h>
4044#endif
41454246#ifdef HAVE_TERMIOS_H
···184188 tcsetattr (fd, TCSANOW, &tios);
185189 }
186190#endif
191191+}
192192+193193+int pce_file_exists (const char *name)
194194+{
195195+#ifdef HAVE_SYS_STAT_H
196196+ struct stat st;
197197+198198+ if (stat (name, &st) != 0) {
199199+ return (0);
200200+ }
201201+#else
202202+ FILE *fp;
203203+204204+ if ((fp = fopen (name, "rb")) == NULL) {
205205+ return (0);
206206+ }
207207+208208+ fclose (fp);
209209+#endif
210210+ return (1);
187211}
188212189213void pce_start (unsigned *brk)
+3-2
src/lib/sysdep.h
···55/*****************************************************************************
66 * File name: src/lib/sysdep.h *
77 * Created: 2006-06-19 by Hampa Hug <hampa@hampa.ch> *
88- * Copyright: (C) 2006-2015 Hampa Hug <hampa@hampa.ch> *
88+ * Copyright: (C) 2006-2025 Hampa Hug <hampa@hampa.ch> *
99 *****************************************************************************/
10101111/*****************************************************************************
···1515 * *
1616 * This program is distributed in the hope that it will be useful, but *
1717 * WITHOUT ANY WARRANTY, without even the implied warranty of *
1818- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1818+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
1919 * Public License for more details. *
2020 *****************************************************************************/
2121···5656 *****************************************************************************/
5757int pce_fd_writeable (int fd, int t);
58585959+int pce_file_exists (const char *name);
59606061void pce_start (unsigned *brk);
6162