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

NSTask and uudecode


  • Subject: NSTask and uudecode
  • From: "gMail.com" <email@hidden>
  • Date: Wed, 27 Jan 2010 18:37:44 +0100
  • Thread-topic: NSTask and uudecode

I have to decode a uuencoded NSString in memory so I use NSTask to launch
the unix command uudecode. If I set the output to a file, it works. But if I
setStandardOutput to a NSFileHandle I cannot later get any availableData.
Can you please tell me why?

    // -p should set the standard output. Even without this args, it fails.
    NSArray  *args = [NSArray arrayWithObjects:@"-p", nil];
    [task setLaunchPath:@"/usr/bin/uudecode"];
    [task setArguments:args];

I set the Standard input to the handle managing the string

    NSPipe            *writePipe = [NSPipe pipe];
    NSFileHandle    *writeHandle = [writePipe fileHandleForWriting];
    [task setStandardInput:writePipe];
    [writeHandle writeData:[uuencodedString
dataUsingEncoding:NSMacOSRomanStringEncoding]];
    [writeHandle closeFile];

I set a StandardOutput to a readHandle

    NSPipe            *readPipe = [NSPipe pipe];
    NSFileHandle    *readHandle = [readPipe fileHandleForReading];
    [task setStandardOutput:readHandle];

Then I launch and wait
    [task launch];
    [task waitUntilExit];

I cannot later get any data with

    NSData    *dataOut = [readHandle availableData];

The application doesn't go further. It remains blocked here.
What do I miss? Please note that if I set the standard output to a file

    NSArray  *args = [NSArray arrayWithObjects:@"-o", outFilePath, nil];

it properly works.


--
Leonardo


_______________________________________________

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 uudecode
      • From: "Stephen J. Butler" <email@hidden>
    • Re: NSTask and uudecode
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: Global in NSApplication
  • Next by Date: Re: Global in NSApplication
  • Previous by thread: Re: Localization help
  • Next by thread: Re: NSTask and uudecode
  • Index(es):
    • Date
    • Thread