From 216baaf7992872344679913509d960b3f955252c Mon Sep 17 00:00:00 2001 From: jp9000 Date: Mon, 29 Jun 2015 00:39:21 -0700 Subject: [PATCH] libobs/util: Add os_rmdir function Adds a function to remove a directory. --- libobs/util/platform-nix.c | 5 +++++ libobs/util/platform-windows.c | 15 +++++++++++++++ libobs/util/platform.h | 1 + 3 files changed, 21 insertions(+) diff --git a/libobs/util/platform-nix.c b/libobs/util/platform-nix.c index 52a906dc8..e236ede21 100644 --- a/libobs/util/platform-nix.c +++ b/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) diff --git a/libobs/util/platform-windows.c b/libobs/util/platform-windows.c index 150a83ec0..efbc07ef4 100644 --- a/libobs/util/platform-windows.c +++ b/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; diff --git a/libobs/util/platform.h b/libobs/util/platform.h index de637146b..291c994ee 100644 --- a/libobs/util/platform.h +++ b/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