Re: temporary files and subsequent cleanup
Re: temporary files and subsequent cleanup
- Subject: Re: temporary files and subsequent cleanup
- From: Alastair Houghton <email@hidden>
- Date: Fri, 26 Oct 2007 17:34:01 +0100
On 26 Oct 2007, at 17:09, Chris Heimark wrote:
I think the /var/tmp folder, BTW, is the one that you get if you
ask various Carbon/Cocoa APIs for a temporary folder.
If by that, you mean NSTemporaryDirectory(), I get /private/var/tmp/
folders.501/temporaryitems/.
Sorry, I should have been clearer. The Carbon and Cocoa APIs give
you a location *inside* /var/tmp (which is the same as /private/var/
tmp). I haven't looked to see exactly which APIs give which results
and I'm not sure where it's actually documented anywhere either, but
I'd noticed some time ago that that's where Carbon and Cocoa apps
tended to put temporary files.
Do you mean lower level BSD calls?
No, no. The BSD/UNIX APIs will return paths in /tmp (which is
symlinked to /private/tmp). UNIX programs generally either hard-code
"/tmp", or use the environment variable TMPDIR. This kind of thing
seems horrible to a lot of people who don't have a UNIX background,
but since the filesystem layout is standardised, it isn't as nasty as
it first feels.
The biggest problem with the UNIX approach is that you have to be
very careful when creating files in the shared /tmp folder to avoid
creating security holes. A common way to prevent them is to make a
folder based on the user's UID and maybe some other information,
setting the permission bits on the folder carefully, and then you
create files inside that. I think the /var/tmp thing that the Carbon
and Cocoa temporary folder APIs do is simply an implementation of
that that won't be interfered with by UNIX software (since that won't
normally be looking in /var/tmp).
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden