Port ejemplo para comprimir un archivo :
TaskExec("/usr/bin/gzip","archivo1")
para descomprimir :
TaskExec( "/usr/bin/gzip","-d", "archivo1")
y muchas cosas mas ...
Code: Select all
HB_FUNC( TASKEXEC )
{
NSString * comando = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
NSString * arg1 = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 2 ) : "" ] autorelease ];
NSString * arg2 = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 3 ) : "" ] autorelease ];
NSString * arg3 = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 4 ) : "" ] autorelease ];
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: comando ];
NSArray *arguments;
arguments = [NSArray arrayWithObjects: arg1, arg2, arg3, nil];
[task setArguments: arguments];
NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file;
file = [pipe fileHandleForReading];
[task launch];
NSData *data;
data = [file readDataToEndOfFile];
NSString *string;
string = [[NSString alloc] initWithData: data
encoding: NSUTF8StringEncoding];
// NSLog (@"woop! got\n%@", string);
}