• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Where to save temporary files?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Where to save temporary files?


  • Subject: Re: Where to save temporary files?
  • From: Greg Parker <email@hidden>
  • Date: Mon, 13 Oct 2008 18:46:09 -0700

Andre-John Mas wrote:
I am try to find out what the right place is to save a temporary file on the Mac is. I have looked at the following places:
/tmp
~/Library/Caches/<app name>


Are there other locations and are there any suggested usage policies?

To elaborate: what I am looking at is a file to be downloaded by a web browser, in order to directly be opened up by another application. In order for the other application to have access to it I will have to save it somewhere, though I am not sure where I should be saving it and what sort of life-span this file should have on the user's hard- disk.

Good options include the following. The "right" choice depends in part on the auto-deletion policy you want.


confstr(_CS_DARWIN_USER_TEMP_DIR, ...)
confstr(_CS_DARWIN_USER_CACHE_DIR, ...)
NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, ...)


_CS_DARWIN_USER_TEMP_DIR is a temp directory. Files there are deleted if they are not accessed after a few days.
_CS_DARWIN_USER_CACHE_DIR is a cache directory. Files there survive longer than those in USER_TEMP_DIR, but may be deleted during OS upgrades or safe boot, for example.
NSDownloadsDirectory is ~/Downloads (probably), which is the same download location that Safari uses by default. Files there are not automatically deleted.


The confstr() directories are on the local disk (probably), while NSDownloadsDirectory and ~/Library/Caches may be on a slower network home directory.

All of these are per-user directories, while /tmp and /Library/Caches are shared among all users which can cause security problems if you're not careful.


-- Greg Parker email@hidden Runtime Wrangler


_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Prev by Date: Re: Problems with aio_read
  • Next by Date: Re: New to Mac
  • Previous by thread: Re: Where to save temporary files?
  • Next by thread: ipfw2 and fwd in Darwin
  • Index(es):
    • Date
    • Thread