| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| #include <stdio.h>
|
| #include <direct.h>
|
| #include <errno.h>
|
| #include <stdlib.h>
|
| #include <corecrt_internal_traits.h>
|
| #include <windows.h>
|
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| template <typename Character>
|
| _Success_(return != 0)
|
| static Character* __cdecl common_fullpath(
|
| _Out_writes_z_(max_count) Character* const user_buffer,
|
| Character const* const path,
|
| size_t const max_count,
|
| int const block_use,
|
| char const* const file_name,
|
| int const line_number
|
| ) throw()
|
| {
|
|
|
| UNREFERENCED_PARAMETER(block_use);
|
| UNREFERENCED_PARAMETER(file_name);
|
| UNREFERENCED_PARAMETER(line_number);
|
|
|
| typedef __crt_char_traits<Character> traits;
|
|
|
|
|
| if (path == nullptr || path[0] == '\0')
|
| {
|
| #pragma warning(suppress:__WARNING_POSTCONDITION_NULLTERMINATION_VIOLATION)
|
| return traits::tgetcwd(user_buffer, static_cast<int>(__min(max_count, INT_MAX)));
|
| }
|
|
|
| if (user_buffer != nullptr) {
|
|
|
| __crt_no_alloc_win32_buffer<Character> buffer(user_buffer, max_count);
|
| if (!traits::get_full_path_name(path, buffer)) {
|
| return user_buffer;
|
| } else {
|
| return nullptr;
|
| }
|
| } else {
|
|
|
| __crt_public_win32_buffer<Character> buffer(
|
| __crt_win32_buffer_debug_info(block_use, file_name, line_number)
|
| );
|
| traits::get_full_path_name(path, buffer);
|
| return buffer.detach();
|
| }
|
| }
|
|
|
|
|
|
|
| extern "C" char* __cdecl _fullpath(
|
| char* const user_buffer,
|
| char const* const path,
|
| size_t const max_count
|
| )
|
| {
|
| return common_fullpath(user_buffer, path, max_count, _NORMAL_BLOCK, nullptr, 0);
|
| }
|
|
|
| extern "C" wchar_t* __cdecl _wfullpath(
|
| wchar_t* const user_buffer,
|
| wchar_t const* const path,
|
| size_t const max_count
|
| )
|
| {
|
| return common_fullpath(user_buffer, path, max_count, _NORMAL_BLOCK, nullptr, 0);
|
| }
|
|
|
| #ifdef _DEBUG
|
|
|
| #undef _fullpath_dbg
|
| #undef _wfullpath_dbg
|
|
|
| extern "C" char* __cdecl _fullpath_dbg(
|
| char* const user_buffer,
|
| char const* const path,
|
| size_t const max_count,
|
| int const block_use,
|
| char const* const file_name,
|
| int const line_number
|
| )
|
| {
|
| return common_fullpath(user_buffer, path, max_count, block_use, file_name, line_number);
|
| }
|
|
|
| extern "C" wchar_t* __cdecl _wfullpath_dbg(
|
| wchar_t* const user_buffer,
|
| wchar_t const* const path,
|
| size_t const max_count,
|
| int const block_use,
|
| char const* const file_name,
|
| int const line_number
|
| )
|
| {
|
| return common_fullpath(user_buffer, path, max_count, block_use, file_name, line_number);
|
| }
|
|
|
| #endif
|
|
|