aboutsummaryrefslogtreecommitdiff
path: root/sys/base/os.c
blob: a76e1830050c900f095962bc72c75b2b5c63b0a1 (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
#include <u.h>
#include <base.h>

int
os·exists(byte *path, int flag)
{
    return access(path, flag) == 0;
}

int
os·sep(void)
{
#if defined(UNIX) || defined(__linux__)
    return '/';
#elif defined(WIN32)
    return '\\';
#else
    panicf("unrecognized operating system");
    return '\0';
#endif
}

byte*
os·basename(byte *path)
{
    byte *sep;

    sep = strrchr(path, os·sep());
    return (sep == nil) ? path : sep+1;
}