mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
orrected faulty commit of basic.m
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10220 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
45a8b10e5b
commit
9af91298d4
1 changed files with 21 additions and 86 deletions
107
Testing/basic.m
107
Testing/basic.m
|
@ -1,92 +1,27 @@
|
|||
#include <Foundation/Foundation.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface TaskMan : NSObject
|
||||
#if 1
|
||||
int main ()
|
||||
{
|
||||
NSMutableArray *taskList;
|
||||
id pool = [NSAutoreleasePool new];
|
||||
id o = [NSObject new];
|
||||
printf ("Hello from object at 0x%x\n", (unsigned)[o self]);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
-nextTask:(NSNotification *) aNotification;
|
||||
@end
|
||||
|
||||
@implementation TaskMan
|
||||
-init
|
||||
#else
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
NSTask *aTask;
|
||||
|
||||
self = [super init];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(nextTask:)
|
||||
name:NSTaskDidTerminateNotification
|
||||
object:nil];
|
||||
|
||||
taskList = [[NSMutableArray alloc] init];
|
||||
|
||||
aTask = [[NSTask alloc] init];
|
||||
[aTask setLaunchPath:@"/bin/ls"];
|
||||
[aTask setArguments:nil];
|
||||
[taskList addObject:aTask];
|
||||
|
||||
aTask = [[NSTask alloc] init];
|
||||
[aTask setLaunchPath:@"/bin/ps"];
|
||||
[aTask setArguments:nil];
|
||||
[taskList addObject:aTask];
|
||||
|
||||
aTask = [[NSTask alloc] init];
|
||||
[aTask setLaunchPath:@"/bin/pwd"];
|
||||
[aTask setArguments:nil];
|
||||
[taskList addObject:aTask];
|
||||
|
||||
aTask = [[NSTask alloc] init];
|
||||
[aTask setLaunchPath:@"/bin/date"];
|
||||
[aTask setArguments:nil];
|
||||
[taskList addObject:aTask];
|
||||
|
||||
[[taskList objectAtIndex:0] launch];
|
||||
|
||||
return self;
|
||||
NSString *string;
|
||||
id pool = [NSAutoreleasePool new];
|
||||
NSProcessInfo *info = [NSProcessInfo processInfo];
|
||||
NSUserDefaults *defaults;
|
||||
|
||||
NSLog(@"Temporary directory - %@", NSTemporaryDirectory());
|
||||
[info setProcessName: @"TestProcess"];
|
||||
defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSLog(@"%@", [defaults dictionaryRepresentation]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
-nextTask:(NSNotification *) aNotification
|
||||
{
|
||||
if ([[aNotification object] terminationStatus] == 0) {
|
||||
[NSNotification notificationWithName:@"CommandCompletedSuccessfully"
|
||||
object:self];
|
||||
} else {
|
||||
[NSNotification notificationWithName:@"CommandFailed"
|
||||
object:self];
|
||||
}
|
||||
[taskList removeObjectAtIndex:0];
|
||||
|
||||
if ([taskList count] > 0)
|
||||
[[taskList objectAtIndex:0] launch];
|
||||
else
|
||||
exit(0);
|
||||
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
int main(int argc, char **argv, char** env)
|
||||
{
|
||||
NSAutoreleasePool *pool;
|
||||
TaskMan *aTaskMan;
|
||||
int i = 0;
|
||||
|
||||
pool = [NSAutoreleasePool new];
|
||||
aTaskMan = [[TaskMan alloc] init];
|
||||
|
||||
while(1) {
|
||||
[[NSRunLoop currentRunLoop] runOnceBeforeDate:
|
||||
[NSDate dateWithTimeIntervalSinceNow: 5]];
|
||||
|
||||
/* Uncomment the following line, and the app will complete all tasks */
|
||||
/* otherwise it will hang */
|
||||
//printf("%d\n", i++);
|
||||
// NSLog(@"");
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue