I need to create a directory full of data files. These files are are temporary, user-private files.
While the files are temporary, and it’s ok if they are deleted by the system, there’s a lot of them and I’d like to
reuse them if I can. Furthermore, I expect other applications (running as the same user) to access/create these files too. This means I need a standard protocol that will work across different programming languages.
Since I know someone will suggest it, I do not want to use ‘/tmp’ or ‘%TEMP% or the java system property java.io.tmpdir.
These directories are system-scoped. I’m also very interested in finding platform-standard or platform-approved methods over just finding a solution that works.
I’m trying to collect a list of where to locate these files for various platforms. Below is what I have so far, but I would really appreciate additional platforms and/or validation of what I’ve already found.
This is the best list I’ve found. If you have any corrections/suggestions, please let me know.
On Windows:
Create a directory “CompanyName” in the “local app data” directory. Find this via:
LOCALAPPDATA, orQuery the registry by executing the following command line:
On MacOSX:
$TMPDIRor Cocoa functionNSTemporaryDirectory()mkdir -m 700 ~/Library/Caches/CompanyOrProductNamemkdir -m 700 ~/Library/Application Support/CompanyOrProductNameOn Linux:
mkdir -m 700 ~/.company-nameOn Solaris / OpenSolaris:
References: