Check for .itch or too long tmp path and fallback to shorter ones where needed. Create tmp dir if doesn't exist
import { remote } from "electron";
+import fs from "fs-extra";
export default () => {
- const tmpPath = remote.app.getPath("temp");
- if (tmpPath.indexOf(" ") === -1) {
+ let tmpPath = remote.app.getPath("temp");
+ if (
+ tmpPath.indexOf(" ") === -1 &&
+ tmpPath.indexOf(".itch") === -1 &&
+ (process.platform !== "win32" || tmpPath.length < 35)
+ ) {
+ // Ok
+ } else if (process.platform === "win32") {
+ tmpPath = "C:\\tmp";
+ } else tmpPath = "/tmp";
+ fs.ensureDirSync(tmpPath);
return tmpPath;
- }
- if (process.platform === "win32") {
- return "C:\tmp";
- }
- return "/tmp";
};
