removed os_gettime_ms, added os_file_exists

This commit is contained in:
jp9000 2013-12-12 21:41:46 -07:00
parent 467362f584
commit de21e622b5
4 changed files with 29 additions and 24 deletions

View File

@ -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))

View File

@ -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);

View File

@ -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;

View File

@ -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