- Home /
Where to save temporary files on Linux?
I'm developing a plugin for Unity which downloads files from a server.
Normally I'd want to save them into Application.temporaryCachePath
.
However, I want to use a location which isn't specific for a single game but is shared by many games.
I've tried System.Environment.GetFolderPath(System.Environment.SpecialFolder.InternetCache)
It works nicely on Windows and Mac. The paths returned are:
Windows: C:\Users\USER_NAME\AppData\Local\Microsoft\Windows\INetCache
Mac: /Users/USER_NAME/Library/Caches
However, on Linux it's empty.
For Linux I've tried:
"/var/cache/"
- writes the error "Access permission denied"
"~/.cache/"
- instead of writing into the folder ".cache" inside the user's Home folder, it just creates a "~" folder inside the game's folder, next to the .x86_64 file!
"/tmp"
doesn't seem like a good place because typically the files are deleted there are the app is closed, but I want the files to stay there between launches.
I'm thinking of using System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyVideos)
or some of the other default locations which aren't really destined to contain temporary files. Basically anything in this list: https://jimrich.sk/environment-specialfolder-on-windows-linux-and-os-x/ where there is a path defined for Linux would do. But that's not a good user experience.
What's the common "trashpile" location where Linux application can freely dump their garbage? How can I access that directory from Unity?
Answer by PZ2100 · Aug 09, 2019 at 09:25 PM
Ok it seems that downloading to "/var/tmp" works fine and solves my problem.
Your answer
Follow this Question
Related Questions
Assign a Material temporary (Will function in the built layer) 2 Answers
AppleTV persistanceDataStorage 0 Answers
Data Storage Access 0 Answers
Fastest way to store huge amounts of data? 2 Answers
Storing and Accessing Abilities 2 Answers