Re: Removing a file via NSFileWrapper
Re: Removing a file via NSFileWrapper
- Subject: Re: Removing a file via NSFileWrapper
- From: Quincey Morris <email@hidden>
- Date: Sun, 30 Mar 2014 10:45:16 -0700
On Mar 30, 2014, at 07:26 , Colas B <email@hidden> wrote:
> 2) the problem occurs also when "creating" a file via the "write" method of NSFileWrapper if I do the following
> a) in my "packaged file" myFolder.myApp, I create a file "file1"
> b) I ask the Finder to "show the content" of myFolder.myApp.
>
> In this case, I am able to see "file1".
> c) I create a new file, "file 2"
>
> d) this time, if I check again the content of myFolder.myApp, I don't see "file2" (but "file1" is still there)
What does “check again” mean? Did you close the window showing the contents of myFolder.myApp, then open another one?
> e-1) If I check the content of myFolder.myApp with
> [[NSWorkspacesharedWorkspace] activateFileViewerSelectingURLs:@[URLOfFile2]];
> then it works, I can see it in the Finder
> e-2) other solution : if I relaunch the Finder, I can see "file2" in the Finder
What you have demonstrated is that your code works, but there is a display inconsistency in the Finder. So, this is about the Finder, not about NSFileWrapper.
> 3) I thinkthis problem comes from the "packaged files" (by this, I mean the folder with an extension, which are shown by the Finder as files). I tried to reproduce this problemwith normal folders, but it this case all is ok (creation and removing).
It’s not true that a folder with an extension is treated as a file package. Rather, a folder is a package if:
(a) it’s marked with the file system attribute that says its a package, or
(b) it belongs to an application that declares it to be a package, or
(c) it is recognized as a special folder that is assumed to be a package
In case (b), the folder will have an extension that associates it with a specific application, but it’s not the extension that makes it a package. In case (c), the folder will have a pre-defined extension (such as .bdmv) — actually, this is just a special case of (b).
> 4) I checked also with the options, and only the NSFileWrapperWritingAtomic option allows me to "update" a folder "linked" with a NSFileWrapper via the "write..." method. Do you understand this ? The document of NSFileWrapperWritingAtomic does not mention that.
I don’t understand this. ‘NSFileWrapperWritingAtomic’ does what the documentation says it does. That is, conceptually, it:
1. Writes the file(s) corresponding the the file wrapper in a temporary location. This produces a single file or folder (which may contain other files and folders).
2. It swaps the temporary file or folder with the original file or folder, atomically in the file system.
The effect is the same as a non-atomic write (assuming that both complete successfully), except that some of the lowest level details (such as file system inode numbers) may differ. But this shouldn’t have any impact on whether you can “update” a folder.
_______________________________________________
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