summaryrefslogtreecommitdiffhomepage
path: root/app/lib/tempdir.js
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2018-02-23 15:00:33 +0100
committerAndrej Mihajlov <and@mullvad.net>2018-03-05 10:58:50 +0100
commitc6ea9cd28de4099d2353d34a183bafe38bc95806 (patch)
treee6dddbc78f1c7f04b1ccde0bb723f4bcf6a641b7 /app/lib/tempdir.js
parentf556ff313190aece18bb2c0a6a09fb189cdc0cd9 (diff)
downloadmullvadvpn-c6ea9cd28de4099d2353d34a183bafe38bc95806.tar.xz
mullvadvpn-c6ea9cd28de4099d2353d34a183bafe38bc95806.zip
Fix the path to system temp directory on windows
Diffstat (limited to 'app/lib/tempdir.js')
-rw-r--r--app/lib/tempdir.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/app/lib/tempdir.js b/app/lib/tempdir.js
new file mode 100644
index 0000000000..e9f65cd03b
--- /dev/null
+++ b/app/lib/tempdir.js
@@ -0,0 +1,21 @@
+// @flow
+
+import path from 'path';
+
+export function getSystemTemporaryDirectory() {
+ switch(process.platform) {
+ case 'win32': {
+ const windowsPath = process.env.windir;
+ if(windowsPath) {
+ return path.join(windowsPath, 'Temp');
+ } else {
+ throw new Error('Missing windir in environment variables.');
+ }
+ }
+ case 'darwin':
+ case 'linux':
+ return '/tmp';
+ default:
+ throw new Error(`Not implemented for ${process.platform}`);
+ }
+}