Browse Source

libobs/util: Add os_rmdir function

Adds a function to remove a directory.
jp9000 10 years ago
parent
commit
216baaf799
3 changed files with 21 additions and 0 deletions
  1. 5 0
      libobs/util/platform-nix.c
  2. 15 0
      libobs/util/platform-windows.c
  3. 1 0
      libobs/util/platform.h

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

@@ -296,6 +296,11 @@ int os_unlink(const char *path)
 	return unlink(path);
 }
 
+int os_rmdir(const char *path)
+{
+	return rmdir(path);
+}
+
 int os_mkdir(const char *path)
 {
 	if (mkdir(path, 0777) == 0)

+ 15 - 0
libobs/util/platform-windows.c

@@ -395,6 +395,21 @@ int os_unlink(const char *path)
 	return success ? 0 : -1;
 }
 
+int os_rmdir(const char *path)
+{
+	wchar_t *w_path;
+	bool success;
+
+	os_utf8_to_wcs_ptr(path, 0, &w_path);
+	if (!w_path)
+		return -1;
+
+	success = !!RemoveDirectoryW(w_path);
+	bfree(w_path);
+
+	return success ? 0 : -1;
+}
+
 int os_mkdir(const char *path)
 {
 	wchar_t *path_utf16;

+ 1 - 0
libobs/util/platform.h

@@ -128,6 +128,7 @@ EXPORT int os_glob(const char *pattern, int flags, os_glob_t **pglob);
 EXPORT void os_globfree(os_glob_t *pglob);
 
 EXPORT int os_unlink(const char *path);
+EXPORT int os_rmdir(const char *path);
 
 #define MKDIR_EXISTS   1
 #define MKDIR_SUCCESS  0