Index: src/OFApplication.h ================================================================== --- src/OFApplication.h +++ src/OFApplication.h @@ -9,10 +9,11 @@ * the packaging of this file. */ #import "OFObject.h" +@class OFString; @class OFArray; @class OFMutableArray; #define OF_APPLICATION_DELEGATE(cls) \ int \ @@ -40,19 +41,25 @@ /** * \brief Represents the application as an object. */ @interface OFApplication: OFObject { + OFString *progname; OFMutableArray *arguments; id delegate; } /** * \return The only OFApplication instance in the application */ + sharedApplication; +/** + * \return The name of the program (argv[0]) + */ ++ (OFString*)programName; + /** * \return The arguments passed to the application */ + (OFArray*)arguments; @@ -70,10 +77,15 @@ * \param argv The argument values */ - setArgumentCount: (int)argc andArgumentValues: (char**)argv; +/** + * \return The name of the program (argv[0]) + */ +- (OFString*)programName; + /** * \return The arguments passed to the application */ - (OFArray*)arguments; Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -56,10 +56,15 @@ if (app == nil) app = [[self alloc] init]; return app; } + ++ (OFString*)programName +{ + return [app programName]; +} + (OFArray*)arguments { return [app arguments]; } @@ -82,22 +87,28 @@ andArgumentValues: (char**)argv { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; int i; - if (arguments != nil) - [arguments release]; + [progname release]; + [arguments release]; + progname = [[OFString alloc] initWithCString: argv[0]]; arguments = [[OFMutableArray alloc] init]; - for (i = 0; i < argc; i++) + for (i = 1; i < argc; i++) [arguments addObject: [OFString stringWithCString: argv[i]]]; [pool release]; return self; } + +- (OFString*)programName +{ + return [[progname retain] autorelease]; +} - (OFArray*)arguments { return [[arguments retain] autorelease]; }