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:


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: Jaroslav IMRICH - Open Source Developer 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?

Ok it seems that downloading to “/var/tmp” works fine and solves my problem.