Reactos
1//
2// wrename.cpp
3//
4// Copyright (c) Microsoft Corporation. All rights reserved.
5//
6// The _wrename() function, which renames a file.
7//
8#include <corecrt_internal.h>
9#include <io.h>
10
11
12
13// Renames the file named 'old_name' to be named 'new_name'. Returns zero if
14// successful; returns -1 and sets errno and _doserrno on failure.
15extern "C" int __cdecl _wrename(wchar_t const* const old_name, wchar_t const* const new_name)
16{
17 // The MOVEFILE_COPY_ALLOWED flag alloes moving to a different volume.
18 if (!MoveFileExW(old_name, new_name, MOVEFILE_COPY_ALLOWED))
19 {
20 __acrt_errno_map_os_error(GetLastError());
21 return -1;
22 }
23
24 return 0;
25}