3 * UWP w32file support for Mono.
5 * Copyright 2016 Microsoft
6 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
10 #include "mono/utils/mono-compiler.h"
12 #include "mono/metadata/w32file-win32-internals.h"
13 #include "mono/metadata/w32subset.h"
14 #include "icall-decl.h"
16 #if !HAVE_API_SUPPORT_WIN32_MOVE_FILE && HAVE_API_SUPPORT_WIN32_MOVE_FILE_EX
18 mono_w32file_move (const gunichar2
*path
, const gunichar2
*dest
, gint32
*error
)
20 gboolean result
= FALSE
;
23 result
= MoveFileExW (path
, dest
, MOVEFILE_COPY_ALLOWED
);
24 if (result
== FALSE
) {
25 *error
=GetLastError ();
33 #if !HAVE_API_SUPPORT_WIN32_COPY_FILE && HAVE_API_SUPPORT_WIN32_COPY_FILE2
35 mono_w32file_copy (const gunichar2
*path
, const gunichar2
*dest
, gboolean overwrite
, gint32
*error
)
37 gboolean result
= FALSE
;
38 COPYFILE2_EXTENDED_PARAMETERS copy_param
= {0};
40 copy_param
.dwSize
= sizeof (COPYFILE2_EXTENDED_PARAMETERS
);
41 copy_param
.dwCopyFlags
= (!overwrite
) ? COPY_FILE_FAIL_IF_EXISTS
: 0;
45 result
= SUCCEEDED (CopyFile2 (path
, dest
, ©_param
));
46 if (result
== FALSE
) {
47 *error
=GetLastError ();
55 #if !HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE
57 mono_w32file_get_console_output (void)
61 g_unsupported_api ("GetStdHandle (STD_OUTPUT_HANDLE)");
63 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "GetStdHandle (STD_OUTPUT_HANDLE)");
64 mono_error_set_pending_exception (error
);
66 SetLastError (ERROR_NOT_SUPPORTED
);
68 return INVALID_HANDLE_VALUE
;
72 mono_w32file_get_console_input (void)
76 g_unsupported_api ("GetStdHandle (STD_INPUT_HANDLE)");
78 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "GetStdHandle (STD_INPUT_HANDLE)");
79 mono_error_set_pending_exception (error
);
81 SetLastError (ERROR_NOT_SUPPORTED
);
83 return INVALID_HANDLE_VALUE
;
87 mono_w32file_get_console_error (void)
91 g_unsupported_api ("GetStdHandle (STD_ERROR_HANDLE)");
93 mono_error_set_not_supported (error
, G_UNSUPPORTED_API
, "GetStdHandle (STD_ERROR_HANDLE)");
94 mono_error_set_pending_exception (error
);
96 SetLastError (ERROR_NOT_SUPPORTED
);
98 return INVALID_HANDLE_VALUE
;
100 #endif // HAVE_API_SUPPORT_WIN32_GET_STD_HANDLE
102 MONO_EMPTY_SOURCE_FILE (file_io_windows_uwp
);