Re: File not closing
Re: File not closing
- Subject: Re: File not closing
- From: Chris Ridd <email@hidden>
- Date: Fri, 09 May 2003 10:19:44 +0100
On 8/5/03 7:50 pm, Trygve Inda <email@hidden> wrote:
>
This is possibly a Cocoa/Carbon hybrid question but...
>
>
I have a Carbon app that creates a series of image files in my App Support
>
folder. These images are set to the desktop with NotificationCenter. Once
>
the desktop is replaced, the old file (created by my app) is deleted.
>
>
I am running into a conflict with another developer's app (Cocoa) that is
>
reading the desktop picture whenever it changes and loading it for its own
>
use...
>
>
So my app sets the desktop, and then a Cocoa app reads in the new desktop
>
image, but somehow prevents me from deleting it after I have set a new image
>
about a minute later.
>
>
NSImage *deskImage = [[[NSImage alloc] initWithContentsOfFile:imagePath]
>
autorelease];
>
>
It seems this call (made by another app) prevents my app from being able to
>
delete the files it is generating.
>
>
As I am not experienced with Cocoa, what might be causing this? Is there a
>
better way to do this such that the file is not left open? What does
>
"autorelease" really do?
>
>
(In My Carbon app, FSDeleteObject returns -47 (file busy)).
There should be no problem with deleting a file that's open - Unix file
semantics allow that (the blocks used by the deleted file are still usable
and only freed when the file is not open by anything.) Dunno what the Carbon
semantics are, perhaps they're different.
Try using unlink instead of that Carbon call.
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.