Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mRemoteNG/PuTTYNG.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'windows/utils/get_system_dir.c')
-rw-r--r--windows/utils/get_system_dir.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/windows/utils/get_system_dir.c b/windows/utils/get_system_dir.c
new file mode 100644
index 00000000..049cd7fc
--- /dev/null
+++ b/windows/utils/get_system_dir.c
@@ -0,0 +1,21 @@
+/*
+ * 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;
+}