NSTask & curl
NSTask & curl
- Subject: NSTask & curl
- From: Ammar Ibrahim <email@hidden>
- Date: Sun, 7 Jun 2009 00:18:48 +0300
I'm using NSTask to spawn a process to do some work as per the code below:
-(void)downloadFile:(NSString *)downloadURL
{
mode = @"download";
downloadFilePath = [self generateUniqueTemporaryFileName];
task = [[NSTask init] alloc];
[task setLaunchPath:@"/usr/bin/curl"];
[task setArguments:[NSArray arrayWithObjects:@"-s",
[NSString stringWithFormat:@"-o %@", [downloadFilePath lastPathComponent]],
downloadURL,
nil]
];
[task setCurrentDirectoryPath:[downloadFilePath
stringByDeletingLastPathComponent] ];
[task launch];
}
And I handle the notification as follows:
- (void)checkATaskStatus:(NSNotification *)aNotification {
BOOL result = ([[aNotification object] terminationStatus] == 0);
if ([mode isEqualToString:@"download"]) {
[[self delegate] trackDidFinishDownload:downloadFilePath success:result];
} else if ([mode isEqualToString:@"upload"]) {
}
}
The problem is that in my delegate I can't access the file! Although I can
see it on the filesystem and open it. even if I check if the file exists
from the delegate, it gives me "false". Why is this happening? How can I fix
it
_______________________________________________
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