1
0
Эх сурвалжийг харах

removed os_gettime_ms, added os_file_exists

jp9000 12 жил өмнө
parent
commit
de21e622b5

+ 5 - 5
libobs/util/platform-cocoa.m

@@ -97,11 +97,6 @@ uint64_t os_gettime_ns(void)
 	return *(uint64_t*) &nano;
 	return *(uint64_t*) &nano;
 }
 }
 
 
-uint64_t os_gettime_ms(void)
-{
-	return  os_gettime_ns()/1000000;
-}
-
 char *os_get_home_path(void)
 char *os_get_home_path(void)
 {
 {
 	NSArray *paths = NSSearchPathForDirectoriesInDomains(
 	NSArray *paths = NSSearchPathForDirectoriesInDomains(
@@ -124,6 +119,11 @@ char *os_get_home_path(void)
 	return path;
 	return path;
 }
 }
 
 
+bool os_file_exists(const char *path)
+{
+	return access(path, F_OK) == 0;
+}
+
 int os_mkdir(const char *path)
 int os_mkdir(const char *path)
 {
 {
 	if(!mkdir(path, 0777))
 	if(!mkdir(path, 0777))

+ 5 - 5
libobs/util/platform-nix.c

@@ -89,11 +89,6 @@ uint64_t os_gettime_ns(void)
 	return tp.tv_nsec;
 	return tp.tv_nsec;
 }
 }
 
 
-uint64_t os_gettime_ms(void)
-{
-	return  os_gettime_ns()/1000000;
-}
-
 /* should return $HOME/ */
 /* should return $HOME/ */
 char *os_get_home_path(void)
 char *os_get_home_path(void)
 {
 {
@@ -107,6 +102,11 @@ char *os_get_home_path(void)
 	return path;
 	return path;
 }
 }
 
 
+bool os_file_exists(const char *path)
+{
+	return access(path, F_OK) == 0;
+}
+
 int os_mkdir(const char *path)
 int os_mkdir(const char *path)
 {
 {
 	int errorcode = mkdir(path, S_IRWXU);
 	int errorcode = mkdir(path, S_IRWXU);

+ 17 - 13
libobs/util/platform-windows.c

@@ -135,19 +135,6 @@ uint64_t os_gettime_ns(void)
 	return (uint64_t)time_val;
 	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 */
 /* returns %appdata% on windows */
 char *os_get_home_path(void)
 char *os_get_home_path(void)
 {
 {
@@ -161,6 +148,23 @@ char *os_get_home_path(void)
 	return out;
 	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)
 int os_mkdir(const char *path)
 {
 {
 	wchar_t *path_utf16;
 	wchar_t *path_utf16;

+ 2 - 1
libobs/util/platform.h

@@ -68,10 +68,11 @@ EXPORT void os_sleepto_ns(uint64_t time_target);
 EXPORT void os_sleep_ms(uint32_t duration);
 EXPORT void os_sleep_ms(uint32_t duration);
 
 
 EXPORT uint64_t os_gettime_ns(void);
 EXPORT uint64_t os_gettime_ns(void);
-EXPORT uint64_t os_gettime_ms(void);
 
 
 EXPORT char *os_get_home_path(void);
 EXPORT char *os_get_home_path(void);
 
 
+EXPORT bool os_file_exists(const char *path);
+
 #define MKDIR_EXISTS   1
 #define MKDIR_EXISTS   1
 #define MKDIR_SUCCESS  0
 #define MKDIR_SUCCESS  0
 #define MKDIR_ERROR   -1
 #define MKDIR_ERROR   -1