Line data Source code
1 0 : /* 2 : 3 : OOFileScannerVerifierStage.h 4 : 5 : OOOXPVerifierStage which keeps track of which files are used and ensures file 6 : name capitalization is consistent. It also provides the file lookup service 7 : for other stages. 8 : 9 : 10 : Copyright (C) 2007-2013 Jens Ayton 11 : 12 : Permission is hereby granted, free of charge, to any person obtaining a copy 13 : of this software and associated documentation files (the "Software"), to deal 14 : in the Software without restriction, including without limitation the rights 15 : to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 : copies of the Software, and to permit persons to whom the Software is 17 : furnished to do so, subject to the following conditions: 18 : 19 : The above copyright notice and this permission notice shall be included in all 20 : copies or substantial portions of the Software. 21 : 22 : THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 : IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 : FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 : AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 : LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 : OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 28 : SOFTWARE. 29 : 30 : */ 31 : 32 : #import "OOOXPVerifierStage.h" 33 : 34 : #if OO_OXP_VERIFIER_ENABLED 35 : 36 0 : @interface OOFileScannerVerifierStage: OOOXPVerifierStage 37 : { 38 : @private 39 0 : NSString *_basePath; 40 0 : NSMutableSet *_usedFiles; 41 0 : NSMutableSet *_caseWarnings; 42 0 : NSDictionary *_directoryListings; 43 0 : NSDictionary *_directoryCases; 44 0 : NSMutableSet *_badPLists; 45 0 : NSSet *_junkFileNames; 46 0 : NSSet *_skipDirectoryNames; 47 : } 48 : 49 : // Returns name to be used in -dependencies by other stages; also registers stage. 50 0 : + (NSString *)nameForDependencyForVerifier:(OOOXPVerifier *)verifier; 51 : 52 : /* This method does the following: 53 : A. Checks whether a file exists. 54 : B. Checks whether case matches, and logs a warning otherwise. 55 : C. Maintains list of files which are referred to. 56 : D. Optionally falls back on Oolite's built-in files. 57 : 58 : For example, to test whether a texture referenced in a shipdata.plist entry 59 : exists, one would use: 60 : [fileScanner fileExists:textureName inFolder:@"Textures" referencedFrom:@"shipdata.plist" checkBuiltIn:YES]; 61 : */ 62 0 : - (BOOL)fileExists:(NSString *)file 63 : inFolder:(NSString *)folder 64 : referencedFrom:(NSString *)context 65 : checkBuiltIn:(BOOL)checkBuiltIn; 66 : 67 : // This method performs all the checks the previous one does, but also returns a file path. 68 0 : - (NSString *)pathForFile:(NSString *)file 69 : inFolder:(NSString *)folder 70 : referencedFrom:(NSString *)context 71 : checkBuiltIn:(BOOL)checkBuiltIn; 72 : 73 : // Data getters based on above method. 74 0 : - (NSData *)dataForFile:(NSString *)file 75 : inFolder:(NSString *)folder 76 : referencedFrom:(NSString *)context 77 : checkBuiltIn:(BOOL)checkBuiltIn; 78 : 79 0 : - (id)plistNamed:(NSString *)file // Only uses "real" plist parser, not homebrew. 80 : inFolder:(NSString *)folder 81 : referencedFrom:(NSString *)context 82 : checkBuiltIn:(BOOL)checkBuiltIn; 83 : 84 : 85 : /* Utility to handle display names of files. 86 : If a file and folder are provided, returns folder/file, otherwise just file. 87 : */ 88 0 : - (id)displayNameForFile:(NSString *)file andFolder:(NSString *)folder; 89 : 90 : /* Get a list of files in a subfolder of the OXP. Order is undefined. 91 : */ 92 0 : - (NSArray *)filesInFolder:(NSString *)folder; 93 : 94 : @end 95 : 96 : 97 0 : @interface OOListUnusedFilesStage: OOOXPVerifierStage 98 : 99 : // Returns name to be used in -dependents by other stages; also registers stage. 100 0 : + (NSString *)nameForReverseDependencyForVerifier:(OOOXPVerifier *)verifier; 101 : 102 : @end 103 : 104 : 105 : @interface OOOXPVerifier(OOFileScannerVerifierStage) 106 : 107 0 : - (OOFileScannerVerifierStage *)fileScannerStage; 108 : 109 : @end 110 : 111 : 112 : // Convenience base class for stages that require OOFileScannerVerifierStage and OOListUnusedFilesStage. 113 0 : @interface OOFileHandlingVerifierStage: OOOXPVerifierStage 114 : 115 : @end 116 : 117 : #endif