ReactOS 0.4.16-dev-853-g88d9285
gettemppath.cpp File Reference
#include <corecrt_internal.h>
#include <io.h>
Include dependency graph for gettemppath.cpp:

Go to the source code of this file.

Functions

DWORD __cdecl __acrt_GetTempPath2A (DWORD nBufferLength, LPSTR lpBuffer)
 

Function Documentation

◆ __acrt_GetTempPath2A()

DWORD __cdecl __acrt_GetTempPath2A ( DWORD  nBufferLength,
LPSTR  lpBuffer 
)

Definition at line 17 of file gettemppath.cpp.

18{
19 wchar_t wide_buffer[_MAX_PATH + 1] = {};
20
21 DWORD const get_temp_path_result = __acrt_GetTempPath2W(_countof(wide_buffer), wide_buffer);
22 if (get_temp_path_result == 0)
23 {
24 return 0;
25 }
26
27 bool const use_oem_code_page = !__acrt_AreFileApisANSI();
28 int const code_page = use_oem_code_page ? CP_OEMCP : CP_ACP;
29#pragma warning(suppress:__WARNING_W2A_BEST_FIT) // 38021 Prefast recommends WC_NO_BEST_FIT_CHARS.
30 int const wctmb_result = __acrt_WideCharToMultiByte(code_page, 0, wide_buffer, -1, lpBuffer, nBufferLength, nullptr, nullptr);
31 if (wctmb_result == 0)
32 {
33 return 0;
34 }
35
36 // The return value of WideCharToMultiByte includes the null terminator; the
37 // return value of GetTempPathA does not.
38 return wctmb_result - 1;
39}
return __acrt_WideCharToMultiByte(code_page, 0, buffer.get(), -1, result_size !=0 ? result :nullptr, result_size, nullptr, nullptr)
int WINAPI __acrt_GetTempPath2W(_In_ DWORD nBufferLength, _Out_writes_to_opt_(BufferLength, return+1) LPWSTR lpBuffer)
_Out_opt_ UINT * code_page
BOOL WINAPI __acrt_AreFileApisANSI(void)
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define CP_ACP
Definition: compat.h:109
unsigned long DWORD
Definition: ntddk_ex.h:95
#define _MAX_PATH
Definition: utility.h:77
#define _countof(array)
Definition: sndvol32.h:70
_In_ LPCSTR _In_opt_ LPCSTR _In_ DWORD nBufferLength
Definition: winbase.h:3098
#define CP_OEMCP
Definition: winnls.h:233