• 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: using 'cp' with NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using 'cp' with NSTask


  • Subject: Re: using 'cp' with NSTask
  • From: The Karl Adam <email@hidden>
  • Date: Fri, 28 Jan 2005 11:26:08 -0500

Why are you doing all of that, this is one call to NSFileManager.

-Karl


On Fri, 28 Jan 2005 16:15:56 +0000, Peter Browne
<email@hidden> wrote:
> I want to be able to copy an image file to a new location. There is an
> NSImageView that the user can load a picture into, and I want the user
> to be able to save this image to a new location. I've tried doing this
> using NSTask and 'cp', passing the file path (taken from the open panel
> when the user loads an image into the view) and the target path as
> arguments. However, when it tries to run 'cp' the program chokes. Here
> is the relevent code:
>
> When the open panel is closed:
>
>      if (returnCode == NSOKButton) {
>          mapPath = [openPanel filename];                <- mapPath is an NSString
>
>                 [self setFilePath:mapPath];                     <- sets the filePath variable to the
> result of the open panel
>                 NSLog(@"map file path is now %@", [self filePath]);
>
>          newMap = [[NSImage alloc] initWithContentsOfFile:mapPath];
>                 [self setImage:newMap];
>          [newMap release];
>                 }
>
> This is the 'getting' method to access the filePath from other classes
>
> - (NSString *)filePath   // Used for getting to path to the image so it
> can be copied
> {
>         return filePath;
> }
>
> When the users clicks save:
>
>                 NSString *copyPath = [mapView filePath];
>                 NSString *targetPath = [NSString
> stringWithFormat:@"%@/Desktop/blah.pdf", NSHomeDirectory()];
>
>                 NSLog(@"Going to copy from %@ to %@.", copyPath, targetPath);
>
>                 NSArray *args = [NSArray arrayWithObjects:copyPath, targetPath];
>
>                 // the task to handle copying of the map image
>                 NSTask *cp = [NSTask launchedTaskWithLaunchPath:@"/bin/cp"
> arguments:args];
>
>                 [cp launch];
>
> Any ideas? Thanks in advance, Peter
>
>  _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Cocoa-dev mailing list      (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
>
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >using 'cp' with NSTask (From: Peter Browne <email@hidden>)

  • Prev by Date: Cocoa Bundle and weak-linking
  • Next by Date: VideoConference.framework question
  • Previous by thread: using 'cp' with NSTask
  • Next by thread: Re: using 'cp' with NSTask
  • Index(es):
    • Date
    • Thread