• 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
temporary files and subsequent cleanup
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

temporary files and subsequent cleanup


  • Subject: temporary files and subsequent cleanup
  • From: Chris Heimark <email@hidden>
  • Date: Fri, 26 Oct 2007 07:50:39 -0400

I am creating a temporary file structure in which to store my application required files. That Cocoa method looks like this:

// base:@"some/directory/path/in/file/system"
// path:@"ScratchFolderTemplate.XXXXXX"
- (NSString *)setupDirectory:(NSString *)base path:(NSString *)path
{
NSString *tempPath = nil;
if (!base)
{
tempPath = NSTemporaryDirectory ();
[tempPath retain];
}
else if (path)
{
tempPath = [base stringByAppendingPathComponent:path];
char pathChars[PATH_MAX + 1];
pathChars[PATH_MAX] = 0;
[tempPath getFileSystemRepresentation:pathChars maxLength:(PATH_MAX + 1)];
char *result = (char *) mkdtemp (pathChars);
if (result == pathChars)
{
tempPath = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:pathChars length:strlen (pathChars)];
[tempPath retain];
}
else
tempPath = nil;
}
return tempPath;
}


And it is functioning as I expect. And I cleanup as follows upon a clean exit from my application, which also works great.

- (void)applicationWillTerminate:(NSNotification *)aNotification
{
// these files MUST be eliminated from the world upon program termination
[[NSFileManager defaultManager] removeFileAtPath:tempApplication handler:self];
}


All of this is based on best, most recently discussed ideas garnered from this list.

My question is this though. If my application fails, which I am certain it will never do - hah ;-) - I will have some temp files left over. Does Tiger+ have a daemon for temporary file removal that will care of these files from NSTemporaryDirectory() rooted temporary space here: /private/var/tmp/folders.501/temporaryitems/ and if so, when and how often does it run to take care of this? For instance, this directory on my machine has leftovers from some Apple applications, as follows:

drwx------ 2 chris wheel 68 Oct 24 10:07 TEMP_com.apple.iWork.Numbers_19857_214927641_1
drwx------ 3 chris wheel 102 Oct 23 16:19 com.apple.iWeb_19217_SFED_214863580_1
drwx------ 22 chris wheel 748 Oct 23 21:40 com.apple.iWeb_19317_SFED_214882158_1
drwx------ 12 chris wheel 408 Oct 24 12:27 com.apple.iWeb_19730_SFED_214922039_1
drwx------ 173 chris wheel 5882 Oct 24 16:45 com.apple.iWeb_21452_SFED_214951447_4
drwx------ 2 chris wheel 68 Oct 22 22:26 com.apple.mail


Bottom line question - will these be removed at some point in time by Tiger+ daemons?

Thanks.

Chris
_______________________________________________

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: temporary files and subsequent cleanup
      • From: Brian Stern <email@hidden>
  • Prev by Date: Re: [Moderator] Leopard Discussion Embargo Lifted at 6PM Pacific Time on Friday
  • Next by Date: Re: [Moderator] Leopard Discussion Embargo Lifted at 6PM Pacific Time on Friday
  • Previous by thread: Re: [Moderator] Leopard Discussion Embargo Lifted at 6PM Pacific Time on Friday
  • Next by thread: Re: temporary files and subsequent cleanup
  • Index(es):
    • Date
    • Thread