提交 de21e622 编写于 作者: J jp9000

removed os_gettime_ms, added os_file_exists

上级 467362f5
......@@ -97,11 +97,6 @@ uint64_t os_gettime_ns(void)
return *(uint64_t*) &nano;
}
uint64_t os_gettime_ms(void)
{
return os_gettime_ns()/1000000;
}
char *os_get_home_path(void)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(
......@@ -124,6 +119,11 @@ char *os_get_home_path(void)
return path;
}
bool os_file_exists(const char *path)
{
return access(path, F_OK) == 0;
}
int os_mkdir(const char *path)
{
if(!mkdir(path, 0777))
......
......@@ -89,11 +89,6 @@ uint64_t os_gettime_ns(void)
return tp.tv_nsec;
}
uint64_t os_gettime_ms(void)
{
return os_gettime_ns()/1000000;
}
/* should return $HOME/ */
char *os_get_home_path(void)
{
......@@ -107,6 +102,11 @@ char *os_get_home_path(void)
return path;
}
bool os_file_exists(const char *path)
{
return access(path, F_OK) == 0;
}
int os_mkdir(const char *path)
{
int errorcode = mkdir(path, S_IRWXU);
......
......@@ -135,19 +135,6 @@ uint64_t os_gettime_ns(void)
return (uint64_t)time_val;
}
uint64_t os_gettime_ms(void)
{
LARGE_INTEGER current_time;
uint64_t time_val;
QueryPerformanceCounter(&current_time);
time_val = current_time.QuadPart;
time_val *= 1000;
time_val /= get_clockfreq();
return time_val;
}
/* returns %appdata% on windows */
char *os_get_home_path(void)
{
......@@ -161,6 +148,23 @@ char *os_get_home_path(void)
return out;
}
bool os_file_exists(const char *path)
{
WIN32_FIND_DATA wfd;
HANDLE hFind;
wchar_t *path_utf16;
if (!os_utf8_to_wcs(path, 0, &path_utf16))
return false;
hFind = FindFirstFileW(path_utf16, &wfd);
if (hFind != INVALID_HANDLE_VALUE)
FindClose(hFind);
bfree(path_utf16);
return hFind != INVALID_HANDLE_VALUE;
}
int os_mkdir(const char *path)
{
wchar_t *path_utf16;
......
......@@ -68,10 +68,11 @@ EXPORT void os_sleepto_ns(uint64_t time_target);
EXPORT void os_sleep_ms(uint32_t duration);
EXPORT uint64_t os_gettime_ns(void);
EXPORT uint64_t os_gettime_ms(void);
EXPORT char *os_get_home_path(void);
EXPORT bool os_file_exists(const char *path);
#define MKDIR_EXISTS 1
#define MKDIR_SUCCESS 0
#define MKDIR_ERROR -1
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册