1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00
putty-source/windows/utils/get_system_dir.c
Simon Tatham 3de2f13b89 Factor out Windows utility function get_system_dir().
The code to find out the location of the c:\windows\system32 directory
was already present, in load_system32_dll(). Now it's moved out into a
function of its own, so it can be called in other contexts.
2021-05-08 17:18:17 +01:00

22 lines
466 B
C

/*
* Wrapper function around GetSystemDirectory that deals with
* allocating the output buffer, and also caches the result for future
* calls.
*/
#include "putty.h"
const char *get_system_dir(void)
{
static char *sysdir = NULL;
static size_t sysdirsize = 0;
if (!sysdir) {
size_t len;
while ((len = GetSystemDirectory(sysdir, sysdirsize)) >= sysdirsize)
sgrowarray(sysdir, sysdirsize, len);
}
return sysdir;
}