16template <
typename Character>
21 size_t quote_count = 0;
22 size_t source_length = 0;
23 for (Character
const* it =
source; *it; ++it)
35 size_t const destination_length = source_length - quote_count + 1;
36 __crt_unique_heap_ptr<Character> destination(_calloc_crt_t(Character, destination_length));
37 if (destination.get() ==
nullptr)
41 Character* destination_it = destination.get();
42 for (Character
const* source_it =
source; *source_it; ++source_it)
44 if (*source_it ==
'\"')
47 *destination_it++ = *source_it;
50 *destination_it =
'\0';
51 return destination.detach();
55template <
typename Character>
60 static Character
const tmp_name[] = {
'T',
'M',
'P',
'\0' };
62 Character* tmp_value =
nullptr;
76template <
typename Character>
78 Character
const*
const alternative,
79 Character
const**
const result
84 __crt_unique_heap_ptr<Character const> tmp(get_tmp_directory<Character>());
85 if (tmp.get() !=
nullptr)
87 if (stdio_traits::taccess_s(tmp.get(), 0) == 0)
88 return *
result = tmp.detach();
91 __crt_unique_heap_ptr<Character const> unquoted_tmp(
strip_quotes(tmp.get()));
92 if (unquoted_tmp.get() !=
nullptr && stdio_traits::taccess_s(unquoted_tmp.get(), 0) == 0)
93 return *
result = unquoted_tmp.detach();
98 if (alternative !=
nullptr && stdio_traits::taccess_s(alternative, 0) == 0)
99 return (*
result = alternative),
nullptr;
102 static Character
const root_fallback[] = {
'\\',
'\0' };
103 static Character
const cwd_fallback [] = {
'.',
'\0' };
105 if (stdio_traits::taccess_s(root_fallback, 0) == 0)
106 return (*
result = root_fallback),
nullptr;
108 return (*
result = cwd_fallback),
nullptr;
119template <
typename Character>
121 Character
const*
const path_buffer,
122 Character*
const suffix_pointer,
123 size_t const suffix_count,
124 size_t const prefix_length
138 bool return_value =
false;
146 _old_pfxlen =
static_cast<unsigned int>(prefix_length);
166 while (stdio_traits::taccess_s(path_buffer, 0) == 0 ||
errno ==
EACCES);
191template <
typename Character>
193static Character*
__cdecl common_tempnam(
211 unsigned const prefix_length =
prefix !=
nullptr
212 ?
static_cast<unsigned>(stdio_traits::tcslen(
prefix))
217 unsigned const buffer_size =
static_cast<unsigned>(stdio_traits::tcslen(
directory)) + prefix_length + 12;
219 __crt_unique_heap_ptr<Character, __crt_public_free_policy>
result(
235 static Character
const backslash[] = {
'\\',
'\0' };
244 Character*
const ptr =
result.get() + stdio_traits::tcslen(
result.get());
256 char const*
const alternative,
264 wchar_t const*
const alternative,
265 wchar_t const*
const prefix
274 char const*
const alternative,
285 wchar_t const*
const alternative,
286 wchar_t const*
const prefix,
void __cdecl __acrt_unlock(_In_ __acrt_lock_id lock)
#define _ERRCHECK_EINVAL(e)
bool __cdecl __crt_stdio_path_requires_backslash(char const *const first)
#define _tempnam_dbg(s1, s2, t, f, l)
#define _wtempnam_dbg(s1, s2, t, f, l)
#define _calloc_dbg(c, s, t, f, l)
__acrt_lock(__acrt_heap_lock)
int const char const *const int const line_number
static const DWORD ptr_size
#define UNREFERENCED_PARAMETER(P)
wchar_t const *const size_t const buffer_size
static bool __cdecl compute_name(Character const *const path_buffer, Character *const suffix_pointer, size_t const suffix_count, size_t const prefix_length)
Character const *const int const char const *const int const line_number throw()
Character const *const prefix
static Character const *__cdecl strip_quotes(Character const *const source)
Character const *const int const block_use
wchar_t *__cdecl _wtempnam(wchar_t const *const alternative, wchar_t const *const prefix)
char *__cdecl _tempnam(char const *const alternative, char const *const prefix)
static Character const *__cdecl get_tmp_directory()
static Character const *__cdecl get_directory(Character const *const alternative, Character const **const result)
Character const *const int const char const *const file_name