• 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: Removing a file via NSFileWrapper
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing a file via NSFileWrapper


  • Subject: Re: Removing a file via NSFileWrapper
  • From: Colas B <email@hidden>
  • Date: Sun, 30 Mar 2014 15:26:46 +0100 (BST)

Thanks Mike for your answer.

I did more tests.

1) the wrappers are not nil

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)
       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


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).


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 think I am going to manage the contents of the attached files without NSFileWrapper.

Thanks

Colas
Le Samedi 29 mars 2014 17h51, Mike Abdullah <email@hidden> a écrit :


On 29 Mar 2014, at 16:43, Colas B <email@hidden> wrote:

> Dear cocoa-dev,
>
> There is a problem when I try to remove a file from a folder via NSFileWrapper. I don't know if this is an important info, but the folder is inside a "package" (a folder with an extension).
>
> I have a folder "(...)/attached_files" on my disk.
> I create a NSFileWrapper with
> self.fileWrapper= [[NSFileWrapperalloc] initWithURL:myURL
>                                               options:0
>                                                 error:error] ;
>
>
> Then, I remove one of the sub-subwrappers with the command
> NSFileWrapper * theSubWrapper = [[self.fileWrapper fileWrappers] valueForKey:@"subFolder_1"] ;
> NSFileWrapper * theSubSubWrapper = [[theSubWrapper fileWrappers] valueForKey:@"subSubFolder_1"] ;
> [theSubWrapper removeFileWrapper:theSubSubWrapper] ;

Are you sure both theSubWrapper and theSubSubWrapper aren't nil?

>
>
> Then, I save with
> [self.fileWrapper writeToURL:myURL
>                      options:NSFileWrapperWritingAtomic| NSFileWrapperWritingWithNameUpdating
>          originalContentsURL:myURL
>                        error:error] ;
>
> If I open the folder and check if the file has been removed, the file is still there.
> But, if I try to open it, the Finder throws an error "The Application does not exist".
>
> If anyone has a good experience with NSFileWrapper, more information about the options of the writeToUrl:... command would be appreciated. Indeed, if I don't use the "NSFileWrapperWritingAtomic", I have an error : "can't write because the file already exists".
>
> Thanks to all !!
_______________________________________________

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: Removing a file via NSFileWrapper
      • From: Quincey Morris <email@hidden>
References: 
 >Removing a file via NSFileWrapper (From: Colas B <email@hidden>)
 >Re: Removing a file via NSFileWrapper (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: How does Core Data validate transient attributes?
  • Next by Date: Preparation for doing a bug report for CIPageCurlTransition
  • Previous by thread: Re: Removing a file via NSFileWrapper
  • Next by thread: Re: Removing a file via NSFileWrapper
  • Index(es):
    • Date
    • Thread