• 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: NSTask and 10.9
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTask and 10.9


  • Subject: Re: NSTask and 10.9
  • From: Pax <email@hidden>
  • Date: Tue, 26 Nov 2013 15:56:52 +0000

Why would you delete files in this manner? It's more efficient to delete them directly from your Objective C code, thus:

    NSArray *fileArray = [@"path1",@"path2"];
    for (NSString *filename in fileArray)
    {
        [fileMgr removeItemAtPath:filename error:NULL];
    }

You already know what paths you need to use…

I hope that this helps.


On 26 Nov 2013, at 15:47, koko <email@hidden> wrote:

> I need to remove hidden files from removable media and have been doing so successfully until 10.9.
>
> I use NSTask as follows:
>
> NSTask *task;
> task = [[NSTask alloc] init];
> [task setLaunchPath:rootScriptPath];
> [task setArguments:[NSArray arrayWithObjects:rootpath, nil]];
> [task waitUntilExit];
> [task launch];
> [task release];
>
>
> where rootScriptPath is from:
>
> NSString *rootScriptPath = [[NSBundle mainBundle] pathForResource:@"DeleteHiddenRoot" ofType:nil];
>
> and DeleteHiddenRoot is:
>
> #!/bin/sh
> rm -dfR "$1".f*
> rm -dfR "$1"._*
> rm -dfR "$1".DS*
> rm -dfR "$1".S*
> chmod ugo+rw "$1".Trashes
> rm -dfR "$1".T*
>
>
> finally, rootpath is from:
>
> 	NSArray *pathComponents = [[NSString stringWithCString:(const char*)dir encoding:NSASCIIStringEncoding] pathComponents];
> 	NSString *mediapath = [pathComponents objectAtIndex:0];
> 	mediapath = [mediapath stringByAppendingPathComponent:[pathComponents objectAtIndex:1]];
> 	mediapath = [mediapath stringByAppendingPathComponent:[pathComponents objectAtIndex:2]];
>    NSString *rootpath = [mediapath stringByAppendingString:@"/"];
>
>
> This works just fine up to and including 10.8.5 BUT throws an exception at [task launch] on 10.9
>
> Google reveals nothing about this … at first I thought that sh was not available but in Terminal on 10.9 entering !#/bin/sh puts you into sh
>
> any help is much appreciated … !
>
> -koko
>
>
> _______________________________________________
>
> 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

_______________________________________________

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: NSTask and 10.9
      • From: koko <email@hidden>
References: 
 >NSTask and 10.9 (From: koko <email@hidden>)

  • Prev by Date: Re: NSTask and 10.9
  • Next by Date: Re: Best way to put a fixed view in a UITableViewController scene?
  • Previous by thread: Re: NSTask and 10.9 [SOLVED]
  • Next by thread: Re: NSTask and 10.9
  • Index(es):
    • Date
    • Thread