27 +(NSString*)moveWebFiles:(NSArray*)movableFileTypes error:(NSError**)error;
28 +(NSString*)moveDirectoriesSearchingForIndexHTML:(BOOL)searchFlag error:(NSError**)error;
29 +(NSString*)searchForIndexHTMLFile:(NSMutableArray*)resources atIndex:(
int)curIndex usingManager:(NSFileManager*)fileManager error:(NSError**)error;
34 +(NSString*)moveDirectoriesAndWebFilesOfType:(NSArray*)webFileTypes error:(NSError**)error{
35 NSString *indexHTMLPath = nil;
36 if (webFileTypes != nil) {
37 NSError *moveError = nil;
39 if (moveError != nil) {
44 NSError *moveError = nil;
46 if (moveError != nil) {
50 if (indexHTMLPath == nil) {
51 indexHTMLPath = foundIndexPath;
57 +(NSString*)moveWebFiles:(NSArray*)movableFileTypes error:(NSError**)error{
59 NSFileManager *fileManager = [NSFileManager defaultManager];
60 NSString *indexPath = nil;
61 NSString *resourcesPath = [NSBundle mainBundle].resourcePath;
62 NSString *tempPath = NSTemporaryDirectory();
63 NSError *anError = nil;
64 NSArray *resourcesList = [fileManager contentsOfDirectoryAtPath:resourcesPath error:&anError];
69 for (NSString *resourceName in resourcesList) {
70 BOOL isMovableType = NO;
71 for (NSString *fileType in movableFileTypes) {
72 if ([resourceName.lowercaseString hasSuffix:fileType]) {
78 NSString *destinationPath = [tempPath stringByAppendingPathComponent:resourceName];
79 if ([fileManager fileExistsAtPath:destinationPath]) {
80 NSError *removeError = nil;
81 [fileManager removeItemAtPath:destinationPath error:&removeError];
82 if (removeError != nil) {
87 NSString *resourcePath = [resourcesPath stringByAppendingPathComponent:resourceName];
88 NSError *copyError = nil;
89 [fileManager copyItemAtPath:resourcePath toPath:destinationPath error:©Error];
90 if (copyError != nil) {
94 if ([resourceName isEqualToString:
@"index.html"]) {
95 indexPath = destinationPath;
102 +(NSString*)moveDirectoriesSearchingForIndexHTML:(BOOL)searchFlag error:(NSError**)error{
104 NSFileManager *fileManager = [NSFileManager defaultManager];
105 NSString *indexPath = nil;
106 NSString *resourcesPath = [NSBundle mainBundle].resourcePath;
107 NSString *tempPath = NSTemporaryDirectory();
108 NSError *anError = nil;
109 NSArray *resourcesList = [fileManager contentsOfDirectoryAtPath:resourcesPath error:&anError];
110 if (anError != nil) {
114 for (NSString *resourceName in resourcesList) {
115 BOOL isDirectoryType = NO;
116 NSString *resourcePath = [resourcesPath stringByAppendingPathComponent:resourceName];
117 NSString *destinationPath = [tempPath stringByAppendingPathComponent:resourceName];
118 [fileManager fileExistsAtPath:resourcePath isDirectory:&isDirectoryType];
119 if (isDirectoryType && ![resourceName hasSuffix:
@".lproj"]
120 && ![resourceName isEqualToString:
@"Frameworks"]
121 && ![resourceName isEqualToString:
@"META-INF"]
122 && ![resourceName isEqualToString:
@"_CodeSignature"]) {
124 if ([fileManager fileExistsAtPath:destinationPath]) {
125 NSError *removeError = nil;
126 [fileManager removeItemAtPath:destinationPath error:&removeError];
127 if (removeError != nil) {
128 *error = removeError;
132 NSError *copyError = nil;
133 [fileManager copyItemAtPath:resourcePath toPath:destinationPath error:©Error];
134 if (copyError != nil) {
139 NSMutableArray *resources = [NSMutableArray array];;
140 NSError *contentsError = nil;
141 NSArray *childResourcesList = [fileManager contentsOfDirectoryAtPath:destinationPath error:&contentsError];
142 if (contentsError != nil) {
145 for (NSString *childResource in childResourcesList) {
146 [resources addObject:@[destinationPath,childResource]];
148 NSError *searchError = nil;
150 if (indexHTMLFilePath != nil) {
151 indexPath = indexHTMLFilePath;
162 +(NSString*)searchForIndexHTMLFile:(NSMutableArray*)resources atIndex:(
int)curIndex usingManager:(NSFileManager*)fileManager error:(NSError**)error{
163 NSString *resource = resources[curIndex][1];
164 NSString *directoryPath = resources[curIndex][0];
165 NSString *resourcePath = [directoryPath stringByAppendingPathComponent:resource];
166 NSError *anError = nil;
167 if ([resource.lowercaseString isEqualToString:
@"index.html"]) {
171 BOOL isDirectoryType = NO;
172 [fileManager fileExistsAtPath:resourcePath isDirectory:&isDirectoryType];
173 if (isDirectoryType) {
174 NSArray *resourceList = [fileManager contentsOfDirectoryAtPath:resourcePath error:&anError];
175 if (anError != nil) {
179 for (NSString *childResource in resourceList) {
180 [resources addObject:@[resourcePath, childResource]];
NSString * moveDirectoriesSearchingForIndexHTML:error:(BOOL searchFlag, [error] NSError **error)
NSString * searchForIndexHTMLFile:atIndex:usingManager:error:(NSMutableArray *resources, [atIndex] int curIndex, [usingManager] NSFileManager *fileManager, [error] NSError **error)
NSString * moveWebFiles:error:(NSArray *movableFileTypes, [error] NSError **error)