Reactos
1//
2// unlink.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// The remove() and unlink() functions, which remove (delete) files.
7//
8#include <corecrt_internal.h>
9#include <stdio.h>
10#include <corecrt_internal_win32_buffer.h>
11
12// Deletes the specified file. Returns zero if successful; returns -1 and sets
13// errno and _doserrno on failure.
14extern "C" int __cdecl remove(char const* const path)
15{
16 if (path == nullptr)
17 return _wremove(nullptr);
18
19 __crt_internal_win32_buffer<wchar_t> wide_path;
20
21 errno_t const cvt = __acrt_mbs_to_wcs_cp(path, wide_path, __acrt_get_utf8_acp_compatibility_codepage());
22
23 if (cvt != 0) {
24 return -1;
25 }
26
27 return _wremove(wide_path.data());
28}
29
30
31
32extern "C" int __cdecl _unlink(char const* const path)
33{
34 return remove(path);
35}