Skip to content

Commit af02175

Browse files
committed
Fix path_exists() with trailing backslash
In TOS it is critical that Fattrib() is called without the trailing backslash (FreeMiNT doesn't care, though).
1 parent ef7fea0 commit af02175

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

fsexists.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,21 @@ int path_exists(char *pathname)
3838

3939
if (pathname[0] != '\0')
4040
{
41+
size_t len = strlen(pathname);
42+
int trailing_backslash = pathname[len-1] == '\\';
43+
44+
if (trailing_backslash)
45+
pathname[len-1] = '\0';
46+
4147
if ((attr = Fattrib(pathname, 0, 0)) >= 0 && (attr & FA_DIR) != 0)
4248
r = TRUE;
4349

44-
/* Work-around fr MagiCPC, wo der stat(<Laufwerk>) nicht funkt! */
50+
if (trailing_backslash)
51+
pathname[len-1] = '\\';
52+
53+
/* Work-around fuer MagiCPC, wo der stat(<Laufwerk>) nicht funkt! */
4554
if (cf_magxPC && !r)
4655
{
47-
int len = (int)strlen(pathname);
48-
4956
if (pathname[1] == ':' && len <= 3) /* nur Laufwerk 'X:' oder 'X:\' */
5057
{
5158
char p[80];

0 commit comments

Comments
 (0)