Oolite 1.91.0.7644-241112-7f5034b
Loading...
Searching...
No Matches
OOCheckPListSyntaxVerifierStage.m
Go to the documentation of this file.
1/*
2
3OOCheckPListSyntaxVerifierStage.m
4
5
6Oolite
7Copyright (C) 2004-2013 Giles C Williams and contributors
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22MA 02110-1301, USA.
23
24*/
25
28
29#if OO_OXP_VERIFIER_ENABLED
30
32
33static NSString * const kStageName = @"Checking plist well-formedness";
34
35
37
38- (NSString *)name
39{
40 return kStageName;
41}
42
43
44- (BOOL)shouldRun
45{
46 return YES;
47}
48
49
50- (void)run
51{
52 OOFileScannerVerifierStage *fileScanner = nil;
53
54
55 fileScanner = [[self verifier] fileScannerStage];
56
57 NSArray *plists = [[[self verifier] configurationDictionaryForKey:@"knownFiles"] oo_arrayForKey:@"Config"];
58 NSArray *arrayPlists = [[[self verifier] configurationDictionaryForKey:@"knownFiles"] oo_arrayForKey:@"ConfigArrays"];
59 NSArray *dictionaryPlists = [[[self verifier] configurationDictionaryForKey:@"knownFiles"] oo_arrayForKey:@"ConfigDictionaries"];
60
61 NSString *plistName = nil;
62 foreach (plistName, plists)
63 {
64 if ([fileScanner fileExists:plistName
65 inFolder:@"Config"
66 referencedFrom:nil
67 checkBuiltIn:NO])
68 {
69 OOLog(@"verifyOXP.syntaxCheck",@"Checking %@",plistName);
70 id retrieve = [fileScanner plistNamed:plistName
71 inFolder:@"Config"
73 checkBuiltIn:NO];
74 if (retrieve != nil)
75 {
76 if ([retrieve isKindOfClass:[NSArray class]])
77 {
78 if (![arrayPlists containsObject:plistName])
79 {
80 OOLog(@"verifyOXP.syntaxCheck.error",@"%@ should be an array but isn't.",plistName);
81 }
82 }
83 else if ([retrieve isKindOfClass:[NSDictionary class]])
84 {
85 if (![dictionaryPlists containsObject:plistName])
86 {
87 OOLog(@"verifyOXP.syntaxCheck.error",@"%@ should be an array but isn't.",plistName);
88 }
89 }
90 else
91 {
92 OOLog(@"verifyOXP.syntaxCheck.error",@"%@ is neither an array nor a dictionary.",plistName);
93 }
94 }
95 }
96 }
97
98}
99
100@end
101
102
103
104#endif
static NSString *const kStageName
static NSString *const kStageName
#define OOLog(class, format,...)
Definition OOLogging.h:88
return nil
id plistNamed:inFolder:referencedFrom:checkBuiltIn:(NSString *file,[inFolder] NSString *folder,[referencedFrom] NSString *context,[checkBuiltIn] BOOL checkBuiltIn)