Reactos
1//
2// rmdir.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// The _rmdir() function, which removes a directory.
7//
8#include <corecrt_internal.h>
9#include <direct.h>
10#include <corecrt_internal_win32_buffer.h>
11
12// Removes the directory specified by the path. The directory must be empty, it
13// must not be the current working directory, and it must not be the root of any
14// drive. Returns 0 on success; returns -1 and sets errno and _doserrno on
15// failure.
16extern "C" int __cdecl _rmdir(char const* const path)
17{
18 if (path == nullptr) {
19 return _wrmdir(nullptr);
20 }
21
22 __crt_internal_win32_buffer<wchar_t> wide_path;
23
24 errno_t const cvt = __acrt_mbs_to_wcs_cp(path, wide_path, __acrt_get_utf8_acp_compatibility_codepage());
25
26 if (cvt != 0) {
27 return -1;
28 }
29
30 return _wrmdir(wide_path.data());
31}