| Server IP : 121.121.20.254 / Your IP : 216.73.216.202 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files (x86)/Windows Kits/10/Source/10.0.26100.0/ucrt/stdio/ |
Upload File : |
//
// gettemppath.cpp
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// The __acrt_GetTempPath2A() function, which calls GetTempPathW and converts the string to multibyte.
//
#include <corecrt_internal.h>
#include <io.h>
// This function simply calls __acrt_GetTempPath2W() and converts the wide string to multibyte.
// Note that GetTempPathA is not UTF-8 aware. This is because APIs using temporary paths
// must not depend on the current locale setting and must use the ACP or OEMCP since
// the returned data must be a static buffer and this behavior is guaranteed by MSDN documentation.
extern "C" DWORD __cdecl __acrt_GetTempPath2A(DWORD nBufferLength, LPSTR lpBuffer)
{
wchar_t wide_buffer[_MAX_PATH + 1] = {};
DWORD const get_temp_path_result = __acrt_GetTempPath2W(_countof(wide_buffer), wide_buffer);
if (get_temp_path_result == 0)
{
return 0;
}
bool const use_oem_code_page = !__acrt_AreFileApisANSI();
int const code_page = use_oem_code_page ? CP_OEMCP : CP_ACP;
#pragma warning(suppress:__WARNING_W2A_BEST_FIT) // 38021 Prefast recommends WC_NO_BEST_FIT_CHARS.
int const wctmb_result = __acrt_WideCharToMultiByte(code_page, 0, wide_buffer, -1, lpBuffer, nBufferLength, nullptr, nullptr);
if (wctmb_result == 0)
{
return 0;
}
// The return value of WideCharToMultiByte includes the null terminator; the
// return value of GetTempPathA does not.
return wctmb_result - 1;
}