Does OS X have a separate temp folder for each user?
If so, how to retrieve the temp folder path for the current user programmatically?
PS Looking at my own OS X file system, I can't see such a folder.
Assuming you are using Objective-C and Foundation: NSTemporaryDirectory()
should return an NSString
with the users temporary directory. On my machine that directory is under /var/folders/
.
For example:
NSString *tempDirectory = NSTemporaryDirectory();
The documentation says that NSTemporaryDirectory()
returns "the path of the temporary directory for the current user. If no such directory is currently available, returns nil."
OS X does not (or did not, through early Lion releases; 10.7.3 seems to do so) set TMPDIR
for use by Unix-like scripts or programs, but many GUI programs make use of a per-user temporary directory under /var/folders
which you can retrieve using some AppleScript (temporary items folder
in Scripting Additions) or via NSTemporaryDirectory()
as noted elsewhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With