From 5c3114c81477298e9eb78ed3a070752f8d24b8a5 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Mon, 18 May 2020 20:29:16 -0700 Subject: feat: pulled out os specific code into its own file --- sys/libn/os.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 sys/libn/os.c (limited to 'sys') diff --git a/sys/libn/os.c b/sys/libn/os.c new file mode 100644 index 0000000..c9cc0ae --- /dev/null +++ b/sys/libn/os.c @@ -0,0 +1,30 @@ +#include +#include + +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; +} -- cgit v1.2.1