aboutsummaryrefslogtreecommitdiff
path: root/sys/libn/os.c
blob: c9cc0ae46be7fef9b1ee664bf42ac6333146cdd5 (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 <libn.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 = utf8·findrrune(path, os·sep());
    return sep+1;
}