• 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: /tmp folder ok?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: /tmp folder ok?


  • Subject: Re: /tmp folder ok?
  • From: "Chris Parker" <email@hidden>
  • Date: Wed, 14 Jan 2009 16:24:47 -0800

NSTemporaryDirectory() already does (effectively) that, and yields the
same resulting folder.

You should just use NSTemporaryDirectory().

.chris


On Wed, Jan 14, 2009 at 3:44 PM, Graham Cox <email@hidden> wrote:
>
> On 15 Jan 2009, at 10:31 am, Chunk 1978 wrote:
>
>> so an app doesn't need administrative rights to writeToFile in the /tmp
>> folder?
>> _______________________________________________
>
>
> Don't do that.
>
> Instead use the FindFolder with the 'kTemporaryFolderType' constant. Here's
> a Cocoa wrapper (a category on NSFileManager) to help:
>
> @implementation NSFileManager (FindFolder)
>
>
> - (NSString*)   pathToFolderOfType:(const OSType) folderType
> shouldCreateFolder:(BOOL) create
> {
>        OSErr           err;
>        FSRef           ref;
>        NSString*       path = nil;
>
>        err = FSFindFolder( kUserDomain, folderType, create, &ref);
>
>        if ( err == noErr )
>        {
>                // convert to CFURL and thence to path
>
>                CFURLRef url = CFURLCreateFromFSRef(
> kCFAllocatorSystemDefault, &ref );
>                path = (NSString*) CFURLCopyFileSystemPath( url,
> kCFURLPOSIXPathStyle );
>                CFRelease( url );
>        }
>
>        return [path autorelease];
> }
>
>
> @end
>
>
> But yes, once you have the path you should have write permission for it.
>
> Note also though, that for the case of "safe saving" (i.e. write to a
> temporary file then swap with the 'real' file), you don't need to do that
> yourself. Just pass yes in the 'atomically' parameter in methods such as
> [NSData writeToFile:atomically:];
>
> hth,
>
> Graham
>
>
> _______________________________________________
>
> 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
>
_______________________________________________

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

  • Follow-Ups:
    • Re: /tmp folder ok?
      • From: "Kyle Sluder" <email@hidden>
References: 
 >/tmp folder ok? (From: "Chunk 1978" <email@hidden>)
 >Re: /tmp folder ok? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Debugging objc_msg errors
  • Next by Date: Re: /tmp folder ok?
  • Previous by thread: Re: /tmp folder ok?
  • Next by thread: Re: /tmp folder ok?
  • Index(es):
    • Date
    • Thread