Lagrange [work/v1.11]

Windows: Directory for temporary files

=> 16e4f4cfe2566a69667dac18568cc026323dcdc3

diff --git a/src/app.c b/src/app.c
index 2b256025..1c782173 100644
--- a/src/app.c
+++ b/src/app.c
@@ -1277,7 +1277,10 @@ const iString *downloadPathForUrl_App(const iString *url, const iString *mime) {
 
 const iString *temporaryPathForUrl_App(const iString *url, const iString *mime) {
     iApp *d = &app_;
-#if defined (P_tmpdir)
+#if defined (iPlatformMsys)
+    iString *      tmpPath = collectNew_String();
+    const iRangecc tmpDir  = range_String(collect_String(tempDirectory_Win32()));
+#elif defined (P_tmpdir)
     iString *      tmpPath = collectNew_String();
     const iRangecc tmpDir  = range_CStr(P_tmpdir);
 #else
diff --git a/src/win32.c b/src/win32.c
index f5aba1ed..287c11e9 100644
--- a/src/win32.c
+++ b/src/win32.c
@@ -26,6 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
 #include "prefs.h"
 #include "app.h"
 
+#include 

 #include 
 #include 
 
@@ -245,6 +246,21 @@ iString *windowsDirectory_Win32(void) {
     return newUtf16_String(winDir);
 }
 
+iString *tempDirectory_Win32(void) {

+    /* Calling GetTempPathW would just return C:\WINDOWS? A local config issue? */

+    WCHAR buf[32768];

+    if (GetEnvironmentVariableW(L"TMP", buf, sizeof(buf))) {

+        return newUtf16_String(buf);

+    }

+    if (GetEnvironmentVariableW(L"TEMP", buf, sizeof(buf))) {

+        return newUtf16_String(buf);

+    }

+    if (GetEnvironmentVariableW(L"USERPROFILE", buf, sizeof(buf))) {

+        return concatCStr_Path(collect_String(newUtf16_String(buf)), "AppData\\Local\\Temp");

+    }

+    return concatCStr_Path(collect_String(windowsDirectory_Win32()), "Temp");

+}

+

 void useExecutableIconResource_SDLWindow(SDL_Window *win) {
     HINSTANCE handle = GetModuleHandle(NULL);
     HICON icon = LoadIcon(handle, "IDI_ICON1");
diff --git a/src/win32.h b/src/win32.h
index 1732f305..6e7882a9 100644
--- a/src/win32.h
+++ b/src/win32.h
@@ -35,6 +35,7 @@ void  useExecutableIconResource_SDLWindow(SDL_Window *);
 void  enableDarkMode_SDLWindow(SDL_Window *);
 void  handleCommand_Win32(const char *cmd);
 iString *windowsDirectory_Win32(void);
+iString *tempDirectory_Win32(void);

 
 #if defined (LAGRANGE_ENABLE_CUSTOM_FRAME)
 iInt2 cursor_Win32(void);
Proxy Information
Original URL
gemini://git.skyjake.fi/lagrange/work%2Fv1.11/cdiff/16e4f4cfe2566a69667dac18568cc026323dcdc3
Status Code
Success (20)
Meta
text/gemini; charset=utf-8
Capsule Response Time
65.431556 milliseconds
Gemini-to-HTML Time
0.619411 milliseconds

This content has been proxied by September (ba2dc).