Oolite
Loading...
Searching...
No Matches
OOJSScript(OOPrivate) Category Reference

Instance Methods

(NSString *) - scriptNameFromPath:
 
(NSDictionary *) - defaultPropertiesFromPath:
 

Detailed Description

Definition at line 102 of file OOJSScript.m.

Method Documentation

◆ defaultPropertiesFromPath:

- (NSDictionary *) defaultPropertiesFromPath: (NSString *)  path

Definition at line 55 of file OOJSScript.m.

615 :(NSString *)path
616{
617 // remove file name, remove OXP subfolder, add manifest.plist
618 NSString *manifestPath = [[[path stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"manifest.plist"];
619 NSDictionary *manifest = OODictionaryFromFile(manifestPath);
620 NSMutableDictionary *properties = [NSMutableDictionary dictionaryWithCapacity:3];
621 /* __oolite.tmp.* is allocated for OXPs without manifests. Its
622 * values are meaningless and shouldn't be used here */
623 if (manifest != nil && ![[manifest oo_stringForKey:kOOManifestIdentifier] hasPrefix:@"__oolite.tmp."])
624 {
625 if ([manifest objectForKey:kOOManifestVersion] != nil)
626 {
627 [properties setObject:[manifest oo_stringForKey:kOOManifestVersion] forKey:@"version"];
628 }
629 if ([manifest objectForKey:kOOManifestIdentifier] != nil)
630 {
631 // used for system info
632 [properties setObject:[manifest oo_stringForKey:kOOManifestIdentifier] forKey:kLocalManifestProperty];
633 }
634 if ([manifest objectForKey:kOOManifestAuthor] != nil)
635 {
636 [properties setObject:[manifest oo_stringForKey:kOOManifestAuthor] forKey:@"author"];
637 }
638 if ([manifest objectForKey:kOOManifestLicense] != nil)
639 {
640 [properties setObject:[manifest oo_stringForKey:kOOManifestLicense] forKey:@"license"];
641 }
642 }
643 return properties;
644}
static NSString *const kOOManifestLicense
static NSString *const kOOManifestIdentifier
static NSString *const kOOManifestVersion
static NSString *const kOOManifestAuthor
NSDictionary * OODictionaryFromFile(NSString *path)
return nil

◆ scriptNameFromPath:

- (NSString *) scriptNameFromPath: (NSString *)  path

Definition at line 55 of file OOJSScript.m.

581 :(NSString *)path
582{
583 NSString *lastComponent = nil;
584 NSString *truncatedPath = nil;
585 NSString *theName = nil;
586
587 if (path == nil) theName = [NSString stringWithFormat:@"%p", self];
588 else
589 {
590 lastComponent = [path lastPathComponent];
591 if (![lastComponent hasPrefix:@"script."]) theName = lastComponent;
592 else
593 {
594 truncatedPath = [path stringByDeletingLastPathComponent];
595 if (NSOrderedSame == [[truncatedPath lastPathComponent] caseInsensitiveCompare:@"Config"])
596 {
597 truncatedPath = [truncatedPath stringByDeletingLastPathComponent];
598 }
599 if (NSOrderedSame == [[truncatedPath pathExtension] caseInsensitiveCompare:@"oxp"])
600 {
601 truncatedPath = [truncatedPath stringByDeletingPathExtension];
602 }
603
604 lastComponent = [truncatedPath lastPathComponent];
605 theName = lastComponent;
606 }
607 }
608
609 if (0 == [theName length]) theName = path;
610
611 return StrippedName([theName stringByAppendingString:@".anon-script"]);
612}
static NSString * StrippedName(NSString *string)
Definition OOJSScript.m:816

The documentation for this category was generated from the following file: