blob: edb7a70d8bf52f8d013ca5b71c189293ec9181b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
Copyright (C) 2025 Mikael Hildenborg
SPDX-License-Identifier: BSD-2-Clause
*/
#include <_ansi.h>
#include "atari-gem_errno.h"
#include "atari-traps.h"
int chdir(const char *path)
{
int err = GEM_E_OK;
if (path != 0)
{
if (path[1] == ':')
{
unsigned int drives = 0;
unsigned short drive = 0;
if (path[0] >= 'A' && path[0] <= 'Z')
{
drive = (unsigned short)(path[0] - 'A');
}
else if (path[0] >= 'a' && path[0] <= 'z')
{
drive = (unsigned short)(path[0] - 'a');
}
drives = trap1_e(drive);
if ((drives & (1 << drive)) == 0)
{
err = GEM_EDRIVE;
}
path += 2;
}
if (err == GEM_E_OK)
{
err = trap1_3b(path);
}
}
else
{
err = GEM_EPTHNF;
}
if (err < 0)
{
gem_error_to_errno(err);
return -1;
}
return 0;
}
|