Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Temporary files best practice?



What about creating temporary folder subfolders, though? Looking at the mkstemp man page, it doesn't sound as though mkstemp supports making folders. If one wishes to write property-list-style data, the file descriptor from mkstemp() would be inadequate unless on wishes to convert to NSData, right?

Best wishes,
    Andrew

On Sep 2, 2007, at 7:34 AM, Wincent Colaiuta wrote:

El 2/9/2007, a las 16:10, Andrew Merenbach escribió:

What about using -[NSProcessInfo globallyUniqueString] to name your folder?

Cheers,
    Andrew

Any method based on generating/getting a name and then testing for existence and creating a folder or file with that name has a race condition. See the mkstemp man page for a better solution:


The mkstemp() function makes the same replacement to the template and
creates the template file, mode 0600, returning a file descriptor opened
for reading and writing. This avoids the race between testing for a
file's existence and opening it for use.


Cheers,
Wincent


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Temporary files best practice? (From: Knut Lorenzen <email@hidden>)
 >Re: Temporary files best practice? (From: Andrew Merenbach <email@hidden>)
 >Re: Temporary files best practice? (From: Wincent Colaiuta <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.