Oolite 1.91.0.7646-241128-10e222e
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

Extends class OOJSScript.

Definition at line 55 of file OOJSScript.m.

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

Extends class OOJSScript.

Definition at line 55 of file OOJSScript.m.

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

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