Changeset 3101
- Timestamp:
- 07/09/05 23:01:41 (3 years ago)
- Files:
-
- Footagehead/trunk/FHController.m (modified) (6 diffs)
- Footagehead/trunk/FHFileHandler.h (modified) (2 diffs)
- Footagehead/trunk/FHFileHandler.m (modified) (5 diffs)
- Footagehead/trunk/FHHandler.h (modified) (1 diff)
- Footagehead/trunk/FHHandler.m (modified) (3 diffs)
- Footagehead/trunk/FHZipHandler.h (added)
- Footagehead/trunk/FHZipHandler.m (added)
- Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj (modified) (7 diffs)
- Footagehead/trunk/Info.plist (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Footagehead/trunk/FHController.m
r3037 r3101 193 193 url = [ZAURL URLWithString:[FHSettings objectForKey:FHOpenURL]]; 194 194 195 if([url isFileURL] && ![[NSFileManager defaultManager] directoryExistsAtPath:[url path]])195 if([url isFileURL] && ![[NSFileManager defaultManager] fileExistsAtPath:[url path]]) 196 196 url = [ZAURL fileURLWithPath:NSHomeDirectory()]; 197 197 … … 212 212 if(url) 213 213 [FHSettings setObject:[url string] forKey:FHOpenURL]; 214 215 [_handler release]; 214 216 } 215 217 … … 224 226 - (BOOL)application:(NSApplication *)application openFile:(NSString *)path { 225 227 NSString *file; 226 227 if([[NSFileManager defaultManager] directoryExistsAtPath:path]) { 228 [self loadURL:[ZAURL fileURLWithPath:path]]; 228 ZAURL *url; 229 230 url = [ZAURL fileURLWithPath:path]; 231 232 if([FHHandler handlesURLAsDirectory:url]) { 233 [self loadURL:url]; 229 234 } else { 230 235 file = [path lastPathComponent]; 231 236 path = [path stringByDeletingLastPathComponent]; 232 237 233 [self loadURL:[ZAURL fileURLWithPath:path] selectFile:file]; 234 } 238 [self loadURL:url selectFile:file]; 239 } 240 241 _openLastURL = NO; 235 242 236 243 return YES; … … 808 815 809 816 - (void)loadURL:(ZAURL *)url selectRow:(int)row file:(NSString *)file { 817 NSArray *files; 810 818 FHHandler *handler; 811 819 unsigned int i, count; … … 831 839 _handler = handler; 832 840 [_handler setDelegate:self]; 833 [_handler files];841 files = [_handler files]; 834 842 835 843 [self updateLeftStatus]; … … 838 846 839 847 if(file) { 840 for(i = 0, count = [ [_handler files]count]; i < count; i++) {841 if([[[ [_handler files]objectAtIndex:i] name] isEqualToString:file]) {848 for(i = 0, count = [files count]; i < count; i++) { 849 if([[[files objectAtIndex:i] name] isEqualToString:file]) { 842 850 row = i; 843 851 Footagehead/trunk/FHFileHandler.h
r920 r3101 1 /* $Id : FHFileHandler.h,v 1.5 2005/01/08 22:55:46 morris Exp$ */1 /* $Id$ */ 2 2 3 3 /* … … 29 29 #import "FHHandler.h" 30 30 31 @interface FHFileHandler : FHHandler 31 @interface FHFileHandler : FHHandler { 32 NSString *_rootPath; 33 } 34 35 36 + (NSArray *)handledFileTypes; 37 38 - (id)initHandlerWithURL:(ZAURL *)url rootPath:(NSString *)rootPath; 32 39 33 40 @end Footagehead/trunk/FHFileHandler.m
r2957 r3101 30 30 #import "FHFile.h" 31 31 #import "FHFileHandler.h" 32 #import "FHZipHandler.h" 32 33 33 static NSComparisonResult compareFile(id, id, void *); 34 static NSMutableArray *FHFileHandlerFileTypes; 35 36 @implementation FHFileHandler 37 38 + (void)initialize { 39 if([self isEqual:[FHFileHandler class]]) { 40 FHFileHandlerFileTypes = [[NSMutableArray alloc] init]; 41 [FHFileHandlerFileTypes addObjectsFromArray:[FHZipHandler handledFileTypes]]; 42 } 43 } 34 44 35 45 36 @implementation FHFileHandler 46 47 #pragma mark - 37 48 38 49 + (BOOL)handlesURL:(ZAURL *)url isPrimary:(BOOL)primary { … … 43 54 44 55 return NO; 56 } 57 58 59 60 + (BOOL)handlesURLAsDirectory:(ZAURL *)url { 61 if(![url isFileURL]) 62 return NO; 63 64 if([[NSFileManager defaultManager] directoryExistsAtPath:[url path]]) 65 return YES; 66 67 return [FHFileHandlerFileTypes containsObject:[url pathExtension]]; 68 } 69 70 71 72 + (NSArray *)handledFileTypes { 73 return [NSImage FHImageFileTypes]; 74 } 75 76 77 78 #pragma mark - 79 80 - (id)initHandlerWithURL:(ZAURL *)url { 81 return [self initHandlerWithURL:url rootPath:[url path]]; 82 } 83 84 85 86 - (id)initHandlerWithURL:(ZAURL *)url rootPath:(NSString *)rootPath { 87 self = [super initHandlerWithURL:url]; 88 89 _rootPath = [rootPath retain]; 90 91 return self; 92 } 93 94 95 96 - (void)dealloc { 97 [_rootPath release]; 98 99 [super dealloc]; 45 100 } 46 101 … … 59 114 - (NSArray *)files { 60 115 NSArray *types, *files; 61 NSString *name, * root, *path;116 NSString *name, *path, *extension; 62 117 FHFile *file; 63 118 ZAURL *url; … … 68 123 69 124 if(!_files) { 70 root = [[self URL] path]; 71 files = [[NSFileManager defaultManager] directoryContentsWithFileAtPath:root]; 125 files = [[NSFileManager defaultManager] directoryContentsWithFileAtPath:_rootPath]; 72 126 files = [files sortedArrayUsingFunction:compareFile context:NULL]; 73 127 count = [files count]; 74 types = [NSImage FHImageFileTypes]; 75 128 types = [FHFileHandler handledFileTypes]; 76 129 _files = [[NSMutableArray alloc] initWithCapacity:count]; 77 130 78 131 for(i = index = 0; i < count; i++) { 79 132 name = [files objectAtIndex:i]; 80 path = [ rootstringByAppendingPathComponent:name];133 path = [_rootPath stringByAppendingPathComponent:name]; 81 134 82 135 if([name hasPrefix:@"."] ) … … 95 148 96 149 if(!isDirectory) { 97 if(![types containsObject:[path pathExtension]]) 98 continue; 150 extension = [path pathExtension]; 151 152 if(![types containsObject:extension]) { 153 if([FHFileHandlerFileTypes containsObject:extension]) 154 isDirectory = YES; 155 else 156 continue; 157 } 99 158 } 100 159 Footagehead/trunk/FHHandler.h
r3024 r3101 43 43 44 44 + (BOOL)handlesURL:(ZAURL *)url isPrimary:(BOOL)primary; 45 + (BOOL)handlesURLAsDirectory:(ZAURL *)url; 45 46 46 47 - (id)initHandlerWithURL:(ZAURL *)url; Footagehead/trunk/FHHandler.m
r2935 r3101 35 35 #import "FHSpotlightHandler.h" 36 36 #import "FHURLHandler.h" 37 #import "FHZipHandler.h" 37 38 38 39 static NSArray *FHHandlerClasses; … … 47 48 [FHSpotlightHandler class], 48 49 [FHURLHandler class], 50 [FHZipHandler class], 49 51 NULL]; 50 52 } … … 55 57 + (BOOL)handlesURL:(ZAURL *)url isPrimary:(BOOL)primary { 56 58 [self doesNotRecognizeSelector:_cmd]; 59 return NO; 60 } 61 62 63 64 + (BOOL)handlesURLAsDirectory:(ZAURL *)url { 57 65 return NO; 58 66 } Footagehead/trunk/Footagehead.xcodeproj/project.pbxproj
r2967 r3101 149 149 A5B1FB9F067CB90400111D0A /* FHCache.m in Sources */ = {isa = PBXBuildFile; fileRef = A5B1FB9D067CB90400111D0A /* FHCache.m */; }; 150 150 A5B1FBC6067D01C200111D0A /* FHImageHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A5B1FBC4067D01C200111D0A /* FHImageHandler.m */; }; 151 A5B44F98087F9A2D003B1DA1 /* FHZipHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = A5B44F96087F9A2D003B1DA1 /* FHZipHandler.m */; }; 151 152 A5DE34860567F307003E7FE9 /* URL.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A5DE34850567F307003E7FE9 /* URL.tiff */; }; 152 153 A5DEB67005CBEFD30074DA63 /* Fullscreen.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A5DEB66F05CBEFD30074DA63 /* Fullscreen.tiff */; }; … … 385 386 A5B1FBC4067D01C200111D0A /* FHImageHandler.m */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.objc; path = FHImageHandler.m; sourceTree = "<group>"; }; 386 387 A5B1FBC5067D01C200111D0A /* FHImageHandler.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = FHImageHandler.h; sourceTree = "<group>"; }; 388 A5B44F95087F9A2D003B1DA1 /* FHZipHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FHZipHandler.h; sourceTree = "<group>"; }; 389 A5B44F96087F9A2D003B1DA1 /* FHZipHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FHZipHandler.m; sourceTree = "<group>"; }; 387 390 A5DE34850567F307003E7FE9 /* URL.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = URL.tiff; sourceTree = "<group>"; }; 388 391 A5DEB66F05CBEFD30074DA63 /* Fullscreen.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Fullscreen.tiff; sourceTree = "<group>"; }; … … 631 634 A5B1F616067B3B7900111D0A /* FHFileHandler.m */, 632 635 A5B1F614067B3B6F00111D0A /* FHFileHandler.h */, 636 A5B44FA4087F9CAB003B1DA1 /* File Handlers */, 633 637 A5B1F9BF067BDF2300111D0A /* FHRangeHandler.m */, 634 638 A5B1F9C0067BDF2300111D0A /* FHRangeHandler.h */, … … 655 659 ); 656 660 name = Data; 661 sourceTree = "<group>"; 662 }; 663 A5B44FA4087F9CAB003B1DA1 /* File Handlers */ = { 664 isa = PBXGroup; 665 children = ( 666 A5B44F96087F9A2D003B1DA1 /* FHZipHandler.m */, 667 A5B44F95087F9A2D003B1DA1 /* FHZipHandler.h */, 668 ); 669 name = "File Handlers"; 657 670 sourceTree = "<group>"; 658 671 }; … … 957 970 8D11072D0486CEB800E47090 /* main.m in Sources */, 958 971 770EBFC5083C94CE0094BD6C /* NSBitmapImageRep-FHAdditions.m in Sources */, 972 A570FD9F0863661300317D0F /* NSData-FHAdditions.m in Sources */, 959 973 775BA4F2075F70ED00F0941E /* NSImage-FHAdditions.m in Sources */, 960 974 A5B1FB9F067CB90400111D0A /* FHCache.m in Sources */, … … 964 978 A599A110075F94F400A03BA5 /* FHFileCell.m in Sources */, 965 979 A5B1F617067B3B7900111D0A /* FHFileHandler.m in Sources */, 980 77EAC0D5084C6D1F006C9F69 /* FHFlickrHandler.m in Sources */, 966 981 A5B1F611067B3AA100111D0A /* FHHandler.m in Sources */, 967 982 A5B1F9AC067BCF0200111D0A /* FHHTMLHandler.m in Sources */, 968 983 77EABF11084C61FF006C9F69 /* FHHTMLParser.m in Sources */, 984 77494704085A57F600BA0915 /* FHImage.m in Sources */, 969 985 A5B1FBC6067D01C200111D0A /* FHImageHandler.m in Sources */, 970 986 77CDB023083B6B85003BE654 /* FHImageView.m in Sources */, … … 975 991 77BD99520760B7380007D034 /* FHTableView.m in Sources */, 976 992 77EAADDA084B546D006C9F69 /* FHURLHandler.m in Sources */, 977 77EAC0D5084C6D1F006C9F69 /* FHFlickrHandler.m in Sources */, 978 77494704085A57F600BA0915 /* FHImage.m in Sources */, 979 A570FD9F0863661300317D0F /* NSData-FHAdditions.m in Sources */, 993 A5B44F98087F9A2D003B1DA1 /* FHZipHandler.m in Sources */, 980 994 ); 981 995 runOnlyForDeploymentPostprocessing = 0; Footagehead/trunk/Info.plist
r2844 r3101 145 145 <string>Viewer</string> 146 146 </dict> 147 <dict> 148 <key>CFBundleTypeExtensions</key> 149 <array> 150 <string>cbz</string> 151 </array> 152 <key>CFBundleTypeName</key> 153 <string>Comic Book Zip File</string> 154 <key>CFBundleTypeRole</key> 155 <string>Viewer</string> 156 </dict> 147 157 </array> 148 158 <key>CFBundleExecutable</key>
