ReactOS 0.4.16-dev-889-g9563c07
rename.cpp
Go to the documentation of this file.
1//
2// rename.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// The rename() function, which renames a file.
7//
8#include <corecrt_internal.h>
9#include <io.h>
11
12
13
14// See _wrename() for details about the behavior of this function. (This
15// function simply converts the multibyte strings to wide strings and calls
16// _wrename().)
17extern "C" int __cdecl rename(char const* const old_name, char const* const new_name)
18{
20
22
23 errno_t cvt1 = __acrt_mbs_to_wcs_cp(old_name, wide_old_name, code_page);
24 if (cvt1 != 0)
25 {
26 errno = cvt1;
27 return -1;
28 }
29
31 errno_t cvt2 = __acrt_mbs_to_wcs_cp(new_name, wide_new_name, code_page);
32 if (cvt2 != 0)
33 {
34 errno = cvt2;
35 return -1;
36 }
37
38 return _wrename(wide_old_name.data(), wide_new_name.data());
39}
#define __cdecl
Definition: accygwin.h:79
_Out_opt_ UINT * code_page
errno_t __acrt_mbs_to_wcs_cp(char const *const null_terminated_input_string, __crt_win32_buffer< wchar_t, ResizePolicy > &win32_buffer, unsigned int const code_page)
unsigned int __acrt_get_utf8_acp_compatibility_codepage()
int __cdecl rename(char const *const old_name, char const *const new_name)
Definition: rename.cpp:17
#define errno
Definition: errno.h:18
_Check_return_ _CRTIMP int __cdecl _wrename(_In_z_ const wchar_t *_NewFilename, _In_z_ const wchar_t *_OldFilename)
errno_t const cvt2
Definition: strftime.cpp:161
errno_t const cvt1
Definition: strftime.cpp:139
int errno_t
Definition: corecrt.h:615