Revision: 5673
http://skim-app.svn.sourceforge.net/skim-app/?rev=5673&view=rev
Author: hofman
Date: 2009-09-04 16:57:09 +0000 (Fri, 04 Sep 2009)
Log Message:
-----------
move functions for some temporary folders and methods for app support files to
an NSFileManager category file
Modified Paths:
--------------
trunk/NSDocument_SKExtensions.m
trunk/SKApplicationController.h
trunk/SKApplicationController.m
trunk/SKBookmarkController.m
trunk/SKConversionProgressController.m
trunk/SKDocumentController.m
trunk/SKDownload.m
trunk/SKMainDocument.m
trunk/SKNotesDocument.m
trunk/SKPDFSynchronizerServer.m
trunk/Skim.xcodeproj/project.pbxproj
Added Paths:
-----------
trunk/NSFileManager_SKExtensions.h
trunk/NSFileManager_SKExtensions.m
Removed Paths:
-------------
trunk/Files_SKExtensions.h
trunk/Files_SKExtensions.m
Deleted: trunk/Files_SKExtensions.h
===================================================================
--- trunk/Files_SKExtensions.h 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/Files_SKExtensions.h 2009-09-04 16:57:09 UTC (rev 5673)
@@ -1,49 +0,0 @@
-//
-// Files_SKExtensions.h
-// Skim
-//
-// Created by Christiaan Hofman on 8/18/07.
-/*
- This software is Copyright (c) 2007-2009
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-
-// These functions are thread safe
-
-extern BOOL SKFileIsInTrash(NSURL *fileURL);
-
-extern NSString *SKChewableItemsDirectory();
-extern NSString *SKUniqueTemporaryDirectory();
-extern NSString *SKUniqueChewableItemsDirectory();
-
\ No newline at end of file
Deleted: trunk/Files_SKExtensions.m
===================================================================
--- trunk/Files_SKExtensions.m 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/Files_SKExtensions.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -1,117 +0,0 @@
-//
-// Files_SKExtensions.m
-// Skim
-//
-// Created by Christiaan Hofman on 8/18/07.
-/*
- This software is Copyright (c) 2007-2009
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "Files_SKExtensions.h"
-#import <CoreFoundation/CoreFoundation.h>
-
-BOOL SKFileIsInTrash(NSURL *fileURL) {
- NSCParameterAssert([fileURL isFileURL]);
- FSRef fileRef;
- Boolean result = false;
- if (CFURLGetFSRef((CFURLRef)fileURL, &fileRef)) {
- FSDetermineIfRefIsEnclosedByFolder(0, kTrashFolderType, &fileRef,
&result);
- if (result == false)
- FSDetermineIfRefIsEnclosedByFolder(0, kSystemTrashFolderType,
&fileRef, &result);
- }
- return result;
-}
-
-static NSString *SKUniqueDirectory(NSString *basePath) {
- CFUUIDRef uuid = CFUUIDCreate(NULL);
- NSString *tmpDirName = [(NSString *)CFUUIDCreateString(NULL, uuid)
autorelease];
- CFRelease(uuid);
-
- BOOL success = YES;
- FSRef tmpRef;
- UniCharCount length = [tmpDirName length];
- UniChar *tmpName = (UniChar *)NSZoneMalloc(NULL, length * sizeof(UniChar));
- [tmpDirName getCharacters:tmpName];
- success = noErr == FSPathMakeRef((UInt8 *)[basePath
fileSystemRepresentation], &tmpRef, NULL) &&
- noErr == FSCreateDirectoryUnicode(&tmpRef, length, tmpName,
kFSCatInfoNone, NULL, NULL, NULL, NULL);
- NSZoneFree(NULL, tmpName);
-
- return success ? [basePath stringByAppendingPathComponent:tmpDirName] :
nil;
-}
-
-NSString *SKChewableItemsDirectory() {
- // chewable items are automatically cleaned up at restart, and it's hidden
from the user
- static NSString *chewableItemsDirectory = nil;
- if (chewableItemsDirectory == nil) {
- FSRef chewableRef;
- OSErr err = FSFindFolder(kUserDomain, kChewableItemsFolderType, TRUE,
&chewableRef);
-
- CFAllocatorRef alloc = CFAllocatorGetDefault();
- CFURLRef chewableURL = NULL;
- if (noErr == err) {
- chewableURL = CFURLCreateFromFSRef(alloc, &chewableRef);
-
- CFStringRef baseName =
CFStringCreateWithFileSystemRepresentation(alloc, "Skim");
- CFURLRef newURL = CFURLCreateCopyAppendingPathComponent(alloc,
chewableURL, baseName, TRUE);
- FSRef newRef;
-
- if (chewableURL) CFRelease(chewableURL);
-
- assert(NULL != newURL);
-
- if (CFURLGetFSRef(newURL, &newRef) == false) {
- CFIndex nameLength = CFStringGetLength(baseName);
- UniChar *nameBuf = CFAllocatorAllocate(alloc, nameLength *
sizeof(UniChar), 0);
- CFStringGetCharacters(baseName, CFRangeMake(0, nameLength),
nameBuf);
- err = FSCreateDirectoryUnicode(&chewableRef, nameLength,
nameBuf, kFSCatInfoNone, NULL, NULL, NULL, NULL);
- CFAllocatorDeallocate(alloc, nameBuf);
- }
-
- if (noErr == err)
- chewableItemsDirectory = (NSString
*)CFURLCopyFileSystemPath(newURL, kCFURLPOSIXPathStyle);
-
- if (newURL) CFRelease(newURL);
- if (baseName) CFRelease(baseName);
-
- assert(nil != chewableItemsDirectory);
- }
- }
- return chewableItemsDirectory;
-}
-
-NSString *SKUniqueTemporaryDirectory() {
- return SKUniqueDirectory(NSTemporaryDirectory());
-}
-
-NSString *SKUniqueChewableItemsDirectory() {
- return SKUniqueDirectory(SKChewableItemsDirectory());
-}
Modified: trunk/NSDocument_SKExtensions.m
===================================================================
--- trunk/NSDocument_SKExtensions.m 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/NSDocument_SKExtensions.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -39,6 +39,7 @@
#import "NSDocument_SKExtensions.h"
#import "SKApplicationController.h"
#import "SKTemplateParser.h"
+#import "NSFileManager_SKExtensions.h"
NSString *SKDocumentErrorDomain = @"SKDocumentErrorDomain";
@@ -53,7 +54,7 @@
NSString *fileType = [[templateFile pathExtension] lowercaseString];
NSString *string = nil;
if ([richTextTypes containsObject:fileType] == NO) {
- NSString *templatePath = [[SKApplicationController
sharedApplicationController] pathForApplicationSupportFile:[templateFile
stringByDeletingPathExtension] ofType:[templateFile pathExtension]
inDirectory:@"Templates"];
+ NSString *templatePath = [[NSFileManager defaultManager]
pathForApplicationSupportFile:[templateFile stringByDeletingPathExtension]
ofType:[templateFile pathExtension] inDirectory:@"Templates"];
NSError *error = nil;
NSString *templateString = [[NSString alloc]
initWithContentsOfFile:templatePath encoding:NSUTF8StringEncoding error:&error];
string = [SKTemplateParser
stringByParsingTemplateString:templateString usingObject:self];
@@ -70,7 +71,7 @@
NSString *fileType = [[templateFile pathExtension] lowercaseString];
NSData *data = nil;
if ([supportedRichTextTypes containsObject:fileType]) {
- NSString *templatePath = [[SKApplicationController
sharedApplicationController] pathForApplicationSupportFile:[templateFile
stringByDeletingPathExtension] ofType:[templateFile pathExtension]
inDirectory:@"Templates"];
+ NSString *templatePath = [[NSFileManager defaultManager]
pathForApplicationSupportFile:[templateFile stringByDeletingPathExtension]
ofType:[templateFile pathExtension] inDirectory:@"Templates"];
NSDictionary *docAttributes = nil;
NSError *error = nil;
NSAttributedString *templateAttrString = [[NSAttributedString alloc]
initWithPath:templatePath documentAttributes:&docAttributes];
@@ -86,7 +87,7 @@
- (NSFileWrapper *)notesFileWrapperUsingTemplateFile:(NSString *)templateFile {
NSFileWrapper *fileWrapper = nil;
if ([[templateFile pathExtension] caseInsensitiveCompare:@"rtfd"] ==
NSOrderedSame) {
- NSString *templatePath = [[SKApplicationController
sharedApplicationController] pathForApplicationSupportFile:[templateFile
stringByDeletingPathExtension] ofType:[templateFile pathExtension]
inDirectory:@"Templates"];
+ NSString *templatePath = [[NSFileManager defaultManager]
pathForApplicationSupportFile:[templateFile stringByDeletingPathExtension]
ofType:[templateFile pathExtension] inDirectory:@"Templates"];
NSDictionary *docAttributes = nil;
NSAttributedString *templateAttrString = [[NSAttributedString alloc]
initWithPath:templatePath documentAttributes:&docAttributes];
NSAttributedString *attrString = [SKTemplateParser
attributedStringByParsingTemplateAttributedString:templateAttrString
usingObject:self];
Added: trunk/NSFileManager_SKExtensions.h
===================================================================
--- trunk/NSFileManager_SKExtensions.h (rev 0)
+++ trunk/NSFileManager_SKExtensions.h 2009-09-04 16:57:09 UTC (rev 5673)
@@ -0,0 +1,56 @@
+//
+// NSFileManager_SKExtensions.h
+// Skim
+//
+// Created by Christiaan on 9/4/09.
+/*
+ This software is Copyright (c) 2009
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import <Cocoa/Cocoa.h>
+
+
+...@interface NSFileManager (SKExtensions)
+
+- (BOOL)isTrashedFileAtURL:(NSURL *)aURL;
+
+- (NSArray *)applicationSupportDirectories;
+- (NSString *)pathForApplicationSupportFile:(NSString *)file ofType:(NSString
*)extension;
+- (NSString *)pathForApplicationSupportFile:(NSString *)file ofType:(NSString
*)extension inDirectory:(NSString *)subpath;
+
+...@end
+
+// These functions are thread safe
+
+extern NSString *SKChewableItemsDirectory();
+extern NSString *SKUniqueTemporaryDirectory();
+extern NSString *SKUniqueChewableItemsDirectory();
Added: trunk/NSFileManager_SKExtensions.m
===================================================================
--- trunk/NSFileManager_SKExtensions.m (rev 0)
+++ trunk/NSFileManager_SKExtensions.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -0,0 +1,157 @@
+//
+// NSFileManager_SKExtensions.m
+// Skim
+//
+// Created by Christiaan on 9/4/09.
+/*
+ This software is Copyright (c) 2009
+ Christiaan Hofman. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ - Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ - Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+
+ - Neither the name of Christiaan Hofman nor the names of any
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "NSFileManager_SKExtensions.h"
+
+
+...@implementation NSFileManager (SKExtensions)
+
+- (BOOL)isTrashedFileAtURL:(NSURL *)aURL {
+ NSCParameterAssert([aURL isFileURL]);
+ FSRef fileRef;
+ Boolean result = false;
+ if (CFURLGetFSRef((CFURLRef)aURL, &fileRef)) {
+ FSDetermineIfRefIsEnclosedByFolder(0, kTrashFolderType, &fileRef,
&result);
+ if (result == false)
+ FSDetermineIfRefIsEnclosedByFolder(0, kSystemTrashFolderType,
&fileRef, &result);
+ }
+ return result;
+}
+
+- (NSArray *)applicationSupportDirectories {
+ static NSArray *applicationSupportDirectories = nil;
+ if (applicationSupportDirectories == nil) {
+ NSMutableArray *pathArray = [NSMutableArray array];
+ NSString *appName = [[NSBundle mainBundle]
objectForInfoDictionaryKey:(NSString *)kCFBundleNameKey];
+ NSEnumerator *pathEnum =
[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
NSAllDomainsMask, YES) objectEnumerator];
+ NSString *path;
+ while (path = [pathEnum nextObject])
+ [pathArray addObject:[path
stringByAppendingPathComponent:appName]];
+ applicationSupportDirectories = [pathArray copy];
+ }
+ return applicationSupportDirectories;
+}
+
+- (NSString *)pathForApplicationSupportFile:(NSString *)file ofType:(NSString
*)extension {
+ return [self pathForApplicationSupportFile:file ofType:extension
inDirectory:nil];
+}
+
+- (NSString *)pathForApplicationSupportFile:(NSString *)file ofType:(NSString
*)extension inDirectory:(NSString *)subpath {
+ NSFileManager *fm = [NSFileManager defaultManager];
+ NSString *filename = [file stringByAppendingPathExtension:extension];
+ NSString *fullPath = nil;
+ NSEnumerator *pathEnum = [[[self applicationSupportDirectories]
arrayByAddingObject:[[NSBundle mainBundle] sharedSupportPath]]
objectEnumerator];
+ NSString *appSupportPath = nil;
+
+ while (appSupportPath = [pathEnum nextObject]) {
+ fullPath = subpath ? [appSupportPath
stringByAppendingPathComponent:subpath] : appSupportPath;
+ fullPath = [fullPath stringByAppendingPathComponent:filename];
+ if ([fm fileExistsAtPath:fullPath] == NO)
+ fullPath = nil;
+ else break;
+ }
+
+ return fullPath;
+}
+
+...@end
+
+static NSString *SKUniqueDirectory(NSString *basePath) {
+ CFUUIDRef uuid = CFUUIDCreate(NULL);
+ NSString *tmpDirName = [(NSString *)CFUUIDCreateString(NULL, uuid)
autorelease];
+ CFRelease(uuid);
+
+ BOOL success = YES;
+ FSRef tmpRef;
+ UniCharCount length = [tmpDirName length];
+ UniChar *tmpName = (UniChar *)NSZoneMalloc(NULL, length * sizeof(UniChar));
+ [tmpDirName getCharacters:tmpName];
+ success = noErr == FSPathMakeRef((UInt8 *)[basePath
fileSystemRepresentation], &tmpRef, NULL) &&
+ noErr == FSCreateDirectoryUnicode(&tmpRef, length, tmpName,
kFSCatInfoNone, NULL, NULL, NULL, NULL);
+ NSZoneFree(NULL, tmpName);
+
+ return success ? [basePath stringByAppendingPathComponent:tmpDirName] :
nil;
+}
+
+NSString *SKChewableItemsDirectory() {
+ // chewable items are automatically cleaned up at restart, and it's hidden
from the user
+ static NSString *chewableItemsDirectory = nil;
+ if (chewableItemsDirectory == nil) {
+ FSRef chewableRef;
+ OSErr err = FSFindFolder(kUserDomain, kChewableItemsFolderType, TRUE,
&chewableRef);
+
+ CFAllocatorRef alloc = CFAllocatorGetDefault();
+ CFURLRef chewableURL = NULL;
+ if (noErr == err) {
+ chewableURL = CFURLCreateFromFSRef(alloc, &chewableRef);
+
+ CFStringRef baseName =
CFStringCreateWithFileSystemRepresentation(alloc, "Skim");
+ CFURLRef newURL = CFURLCreateCopyAppendingPathComponent(alloc,
chewableURL, baseName, TRUE);
+ FSRef newRef;
+
+ if (chewableURL) CFRelease(chewableURL);
+
+ assert(NULL != newURL);
+
+ if (CFURLGetFSRef(newURL, &newRef) == false) {
+ CFIndex nameLength = CFStringGetLength(baseName);
+ UniChar *nameBuf = CFAllocatorAllocate(alloc, nameLength *
sizeof(UniChar), 0);
+ CFStringGetCharacters(baseName, CFRangeMake(0, nameLength),
nameBuf);
+ err = FSCreateDirectoryUnicode(&chewableRef, nameLength,
nameBuf, kFSCatInfoNone, NULL, NULL, NULL, NULL);
+ CFAllocatorDeallocate(alloc, nameBuf);
+ }
+
+ if (noErr == err)
+ chewableItemsDirectory = (NSString
*)CFURLCopyFileSystemPath(newURL, kCFURLPOSIXPathStyle);
+
+ if (newURL) CFRelease(newURL);
+ if (baseName) CFRelease(baseName);
+
+ assert(nil != chewableItemsDirectory);
+ }
+ }
+ return chewableItemsDirectory;
+}
+
+NSString *SKUniqueTemporaryDirectory() {
+ return SKUniqueDirectory(NSTemporaryDirectory());
+}
+
+NSString *SKUniqueChewableItemsDirectory() {
+ return SKUniqueDirectory(SKChewableItemsDirectory());
+}
Modified: trunk/SKApplicationController.h
===================================================================
--- trunk/SKApplicationController.h 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/SKApplicationController.h 2009-09-04 16:57:09 UTC (rev 5673)
@@ -47,8 +47,6 @@
BOOL remoteScrolling;
}
-+ (id)sharedApplicationController;
-
- (IBAction)orderFrontLineInspector:(id)sender;
- (IBAction)orderFrontNotesPanel:(id)sender;
@@ -61,12 +59,6 @@
- (IBAction)editBookmarks:(id)sender;
- (IBAction)openBookmark:(id)sender;
-- (void)doSpotlightImportIfNeeded;
-
-- (NSArray *)applicationSupportDirectories;
-- (NSString *)pathForApplicationSupportFile:(NSString *)file ofType:(NSString
*)extension;
-- (NSString *)pathForApplicationSupportFile:(NSString *)file ofType:(NSString
*)extension inDirectory:(NSString *)subpath;
-
- (NSDictionary *)defaultPdfViewSettings;
- (void)setDefaultPdfViewSettings:(NSDictionary *)settings;
- (NSDictionary *)defaultFullScreenPdfViewSettings;
Modified: trunk/SKApplicationController.m
===================================================================
--- trunk/SKApplicationController.m 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/SKApplicationController.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -63,7 +63,7 @@
#import "NSURL_SKExtensions.h"
#import "SKDocumentController.h"
#import "NSDocument_SKExtensions.h"
-#import "Files_SKExtensions.h"
+#import "NSFileManager_SKExtensions.h"
#import "NSTask_SKExtensions.h"
#import "SKRuntime.h"
#import <SkimNotes/SkimNotes.h>
@@ -90,6 +90,11 @@
#define SKSpotlightLastSysVersionKey @"lastSysVersion"
+...@interface SKApplicationController (SKPrivate)
+- (void)doSpotlightImportIfNeeded;
+...@end
+
+
@implementation SKApplicationController
+ (void)initialize{
@@ -115,24 +120,6 @@
[[NSUserDefaultsController sharedUserDefaultsController]
setInitialValues:initialValuesDict];
}
-static id sharedApplicationController = nil;
-
-+ (id)sharedApplicationController {
- if (sharedApplicationController == nil)
- [[[self alloc] init] release];
- return sharedApplicationController;
-}
-
-+ (id)allocWithZone:(NSZone *)zone {
- return [sharedApplicationController retain] ?: [super allocWithZone:zone];
-}
-
-- (id)init {
- if (sharedApplicationController == nil)
- sharedApplicationController = [[super init] retain];
- return sharedApplicationController;
-}
-
- (void)awakeFromNib {
NSMenu *viewMenu = [[[NSApp mainMenu] itemAtIndex:VIEW_MENU_INDEX]
submenu];
NSInteger i, count = [viewMenu numberOfItems];
@@ -435,42 +422,6 @@
}
}
-- (NSArray *)applicationSupportDirectories {
- static NSArray *applicationSupportDirectories = nil;
- if (applicationSupportDirectories == nil) {
- NSMutableArray *pathArray = [NSMutableArray array];
- NSString *appName = [[NSBundle mainBundle]
objectForInfoDictionaryKey:(NSString *)kCFBundleNameKey];
- NSEnumerator *pathEnum =
[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory,
NSAllDomainsMask, YES) objectEnumerator];
- NSString *path;
- while (path = [pathEnum nextObject])
- [pathArray addObject:[path
stringByAppendingPathComponent:appName]];
- applicationSupportDirectories = [pathArray copy];
- }
- return applicationSupportDirectories;
-}
-
-- (NSString *)pathForApplicationSupportFile:(NSString *)file ofType:(NSString
*)extension {
- return [self pathForApplicationSupportFile:file ofType:extension
inDirectory:nil];
-}
-
-- (NSString *)pathForApplicationSupportFile:(NSString *)file ofType:(NSString
*)extension inDirectory:(NSString *)subpath {
- NSFileManager *fm = [NSFileManager defaultManager];
- NSString *filename = [file stringByAppendingPathExtension:extension];
- NSString *fullPath = nil;
- NSEnumerator *pathEnum = [[[self applicationSupportDirectories]
arrayByAddingObject:[[NSBundle mainBundle] sharedSupportPath]]
objectEnumerator];
- NSString *appSupportPath = nil;
-
- while (appSupportPath = [pathEnum nextObject]) {
- fullPath = subpath ? [appSupportPath
stringByAppendingPathComponent:subpath] : appSupportPath;
- fullPath = [fullPath stringByAppendingPathComponent:filename];
- if ([fm fileExistsAtPath:fullPath] == NO)
- fullPath = nil;
- else break;
- }
-
- return fullPath;
-}
-
#pragma mark Scripting support
- (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key
{
Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/SKBookmarkController.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -41,7 +41,7 @@
#import "BDAlias.h"
#import "SKMainDocument.h"
#import "SKMainWindowController.h"
-#import "Files_SKExtensions.h"
+#import "NSFileManager_SKExtensions.h"
#import "SKBookmarkOutlineView.h"
#import "SKOutlineView.h"
#import "SKTypeSelectHelper.h"
@@ -379,7 +379,7 @@
} else {
NSString *path = [bookmark path];
NSURL *fileURL = path ? [NSURL fileURLWithPath:path] : nil;
- if (fileURL && NO == SKFileIsInTrash(fileURL) &&
+ if (fileURL && NO == [[NSFileManager defaultManager]
isTrashedFileAtURL:fileURL] &&
(document = [[NSDocumentController sharedDocumentController]
openDocumentWithContentsOfURL:fileURL display:YES error:&error]))
[[document mainWindowController] setPageNumber:[bookmark
pageIndex] + 1];
}
Modified: trunk/SKConversionProgressController.m
===================================================================
--- trunk/SKConversionProgressController.m 2009-09-04 16:21:55 UTC (rev
5672)
+++ trunk/SKConversionProgressController.m 2009-09-04 16:57:09 UTC (rev
5673)
@@ -39,7 +39,7 @@
#import "SKConversionProgressController.h"
#import "NSString_SKExtensions.h"
#import "NSTask_SKExtensions.h"
-#import "Files_SKExtensions.h"
+#import "NSFileManager_SKExtensions.h"
#import "NSInvocation_SKExtensions.h"
#import <libkern/OSAtomic.h>
Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/SKDocumentController.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -45,7 +45,7 @@
#import "SKStringConstants.h"
#import "SKRuntime.h"
#import "SKApplicationController.h"
-#import "Files_SKExtensions.h"
+#import "NSFileManager_SKExtensions.h"
#import "BDAlias.h"
#import "SKMainWindowController.h"
@@ -356,7 +356,7 @@
NSURL *fileURL = [[BDAlias aliasWithData:[setup
objectForKey:SKDocumentSetupAliasKey]] fileURL];
if(fileURL == nil && [setup objectForKey:SKDocumentSetupFileNameKey])
fileURL = [NSURL fileURLWithPath:[setup
objectForKey:SKDocumentSetupFileNameKey]];
- if(fileURL && NO == SKFileIsInTrash(fileURL)) {
+ if(fileURL && NO == [[NSFileManager defaultManager]
isTrashedFileAtURL:fileURL]) {
if (document = [self documentForURL:fileURL]) {
// the document was already open, don't call makeWindowControllers
because that adds new empty windows
[document applySetup:setup];
@@ -417,7 +417,7 @@
if (customExportTemplateFiles == nil) {
NSFileManager *fm = [NSFileManager defaultManager];
NSMutableArray *templateFiles = [NSMutableArray array];
- NSEnumerator *pathEnum = [[[SKApplicationController
sharedApplicationController] applicationSupportDirectories] objectEnumerator];
+ NSEnumerator *pathEnum = [[[NSFileManager defaultManager]
applicationSupportDirectories] objectEnumerator];
NSString *appSupportPath;
while (appSupportPath = [pathEnum nextObject]) {
Modified: trunk/SKDownload.m
===================================================================
--- trunk/SKDownload.m 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/SKDownload.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -38,7 +38,7 @@
#import "SKDownload.h"
#import <ApplicationServices/ApplicationServices.h>
-#import "Files_SKExtensions.h"
+#import "NSFileManager_SKExtensions.h"
#import "SKRuntime.h"
NSString *SKDownloadFileNameKey = @"fileName";
Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/SKMainDocument.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -61,7 +61,7 @@
#import "SKInfoWindowController.h"
#import "SKLine.h"
#import "SKApplicationController.h"
-#import "Files_SKExtensions.h"
+#import "NSFileManager_SKExtensions.h"
#import "NSTask_SKExtensions.h"
#import "SKFDFParser.h"
#import "NSData_SKExtensions.h"
@@ -1537,7 +1537,7 @@
[searchPaths addObject:[[appBundle executablePath]
stringByDeletingLastPathComponent]];
}
} else {
- pathEnum = [[[SKApplicationController
sharedApplicationController] applicationSupportDirectories] objectEnumerator];
+ pathEnum = [[[NSFileManager defaultManager]
applicationSupportDirectories] objectEnumerator];
while (path = [pathEnum nextObject]) {
[searchPaths addObject:path];
[searchPaths addObject:[path
stringByAppendingPathComponent:@"Scripts"]];
Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/SKNotesDocument.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -55,7 +55,7 @@
#import "NSDocument_SKExtensions.h"
#import "NSMenu_SKExtensions.h"
#import "NSView_SKExtensions.h"
-#import "Files_SKExtensions.h"
+#import "NSFileManager_SKExtensions.h"
#import "SKToolbarItem.h"
#import "SKCFCallbacks.h"
#import "SKAnnotationTypeImageCell.h"
Modified: trunk/SKPDFSynchronizerServer.m
===================================================================
--- trunk/SKPDFSynchronizerServer.m 2009-09-04 16:21:55 UTC (rev 5672)
+++ trunk/SKPDFSynchronizerServer.m 2009-09-04 16:57:09 UTC (rev 5673)
@@ -43,7 +43,7 @@
#import "NSCharacterSet_SKExtensions.h"
#import "NSScanner_SKExtensions.h"
#import <CoreFoundation/CoreFoundation.h>
-#import "Files_SKExtensions.h"
+#import "NSFileManager_SKExtensions.h"
#import "NSString_SKExtensions.h"
#import "SKCFCallBacks.h"
#import "SKRuntime.h"
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2009-09-04 16:21:55 UTC (rev
5672)
+++ trunk/Skim.xcodeproj/project.pbxproj 2009-09-04 16:57:09 UTC (rev
5673)
@@ -129,6 +129,7 @@
CE5BAF4410511A0F00161B87 /* PDFOutline_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE5BAF4310511A0F00161B87 /*
PDFOutline_SKExtensions.m */; };
CE5BB0CF10515CCC00161B87 /* SKPDFDocument.m in Sources */ =
{isa = PBXBuildFile; fileRef = CE5BB0CE10515CCC00161B87 /* SKPDFDocument.m */;
};
CE5BB0D310515D3100161B87 /* SKPDFPage.m in Sources */ = {isa =
PBXBuildFile; fileRef = CE5BB0D210515D3100161B87 /* SKPDFPage.m */; };
+ CE5BB21610517AEF00161B87 /* NSFileManager_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE5BB21510517AEF00161B87 /*
NSFileManager_SKExtensions.m */; };
CE5BD6740C7ADF1500EBDCF7 /* SKTypeSelectHelper.m in Sources */
= {isa = PBXBuildFile; fileRef = CE5BD6720C7ADF1500EBDCF7 /*
SKTypeSelectHelper.m */; };
CE5BEA190C7C635400EBDCF7 /* NSGeometry_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = CE5BEA170C7C635400EBDCF7 /*
NSGeometry_SKExtensions.m */; };
CE5BF8010C7CBF6300EBDCF7 /* SKTableView.m in Sources */ = {isa
= PBXBuildFile; fileRef = CE5BF7FF0C7CBF6300EBDCF7 /* SKTableView.m */; };
@@ -247,7 +248,6 @@
CEF7175F0B90DF10003A2771 /* SKReleaseNotesController.m in
Sources */ = {isa = PBXBuildFile; fileRef = CEF7175E0B90DF10003A2771 /*
SKReleaseNotesController.m */; };
CEF82CC50EC4ADDA009652CF /* libssl.dylib in Frameworks */ =
{isa = PBXBuildFile; fileRef = CEF82CC40EC4ADDA009652CF /* libssl.dylib */; };
CEF82CE60EC4B2FE009652CF /* libcrypto.dylib in Frameworks */ =
{isa = PBXBuildFile; fileRef = CEF82CE50EC4B2FE009652CF /* libcrypto.dylib */;
};
- CEF839B30C77742A00A3AD51 /* Files_SKExtensions.m in Sources */
= {isa = PBXBuildFile; fileRef = CEF839B10C77742A00A3AD51 /*
Files_SKExtensions.m */; };
CEF84C630C78A89A00A3AD51 /* SmallPreferences.tiff in Resources
*/ = {isa = PBXBuildFile; fileRef = CEF84C620C78A89900A3AD51 /*
SmallPreferences.tiff */; };
CEFBC96A103C5CBF00535C74 /* SKFormatCommand.m in Sources */ =
{isa = PBXBuildFile; fileRef = CEFBC969103C5CBF00535C74 /* SKFormatCommand.m
*/; };
CEFD68740C01D4080027B933 /* SkimImporter.mdimporter in Copy
Files: Spotlight */ = {isa = PBXBuildFile; fileRef = CEFD68690C01D3BB0027B933
/* SkimImporter.mdimporter */; };
@@ -675,6 +675,8 @@
CE5BB0CE10515CCC00161B87 /* SKPDFDocument.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKPDFDocument.m; sourceTree = "<group>"; };
CE5BB0D110515D3100161B87 /* SKPDFPage.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKPDFPage.h; sourceTree = "<group>"; };
CE5BB0D210515D3100161B87 /* SKPDFPage.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKPDFPage.m; sourceTree = "<group>"; };
+ CE5BB21410517AEF00161B87 /* NSFileManager_SKExtensions.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = NSFileManager_SKExtensions.h; sourceTree = "<group>"; };
+ CE5BB21510517AEF00161B87 /* NSFileManager_SKExtensions.m */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = NSFileManager_SKExtensions.m; sourceTree = "<group>";
};
CE5BD6710C7ADF1500EBDCF7 /* SKTypeSelectHelper.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKTypeSelectHelper.h; sourceTree = "<group>"; };
CE5BD6720C7ADF1500EBDCF7 /* SKTypeSelectHelper.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKTypeSelectHelper.m; sourceTree = "<group>"; };
CE5BEA160C7C635400EBDCF7 /* NSGeometry_SKExtensions.h */ = {isa
= PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path
= NSGeometry_SKExtensions.h; sourceTree = "<group>"; };
@@ -957,8 +959,6 @@
CEF7175E0B90DF10003A2771 /* SKReleaseNotesController.m */ =
{isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path =
SKReleaseNotesController.m; sourceTree = "<group>"; };
CEF82CC40EC4ADDA009652CF /* libssl.dylib */ = {isa =
PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name =
libssl.dylib; path = /usr/lib/libssl.dylib; sourceTree = "<absolute>"; };
CEF82CE50EC4B2FE009652CF /* libcrypto.dylib */ = {isa =
PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name =
libcrypto.dylib; path = /usr/lib/libcrypto.dylib; sourceTree = "<absolute>"; };
- CEF839B00C77742A00A3AD51 /* Files_SKExtensions.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
Files_SKExtensions.h; sourceTree = "<group>"; };
- CEF839B10C77742A00A3AD51 /* Files_SKExtensions.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= Files_SKExtensions.m; sourceTree = "<group>"; };
CEF84C620C78A89900A3AD51 /* SmallPreferences.tiff */ = {isa =
PBXFileReference; lastKnownFileType = image.tiff; path = SmallPreferences.tiff;
sourceTree = "<group>"; };
CEFBC968103C5CBF00535C74 /* SKFormatCommand.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKFormatCommand.h; sourceTree = "<group>"; };
CEFBC969103C5CBF00535C74 /* SKFormatCommand.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKFormatCommand.m; sourceTree = "<group>"; };
@@ -1151,8 +1151,8 @@
CE1E30270BDB9D8E0011D9DD /*
NSCharacterSet_SKExtensions.m */,
CEA182250C92E3300061A6D4 /*
NSData_SKExtensions.h */,
CEA182260C92E3300061A6D4 /*
NSData_SKExtensions.m */,
- CEF839B00C77742A00A3AD51 /*
Files_SKExtensions.h */,
- CEF839B10C77742A00A3AD51 /*
Files_SKExtensions.m */,
+ CE5BB21410517AEF00161B87 /*
NSFileManager_SKExtensions.h */,
+ CE5BB21510517AEF00161B87 /*
NSFileManager_SKExtensions.m */,
CE5BEA160C7C635400EBDCF7 /*
NSGeometry_SKExtensions.h */,
CE5BEA170C7C635400EBDCF7 /*
NSGeometry_SKExtensions.m */,
CE0EB4D40DD054DC0034DF92 /*
NSInvocation_SKExtensions.h */,
@@ -2086,7 +2086,6 @@
CEAA559E0C6DE235006BD633 /* SKDownload.m in
Sources */,
CEAA55B70C6DE452006BD633 /* SKProgressCell.m in
Sources */,
CEAA67260C70A882006BD633 /*
NSURL_SKExtensions.m in Sources */,
- CEF839B30C77742A00A3AD51 /*
Files_SKExtensions.m in Sources */,
CE5BD6740C7ADF1500EBDCF7 /*
SKTypeSelectHelper.m in Sources */,
CE5BEA190C7C635400EBDCF7 /*
NSGeometry_SKExtensions.m in Sources */,
CE5BF8010C7CBF6300EBDCF7 /* SKTableView.m in
Sources */,
@@ -2171,6 +2170,7 @@
CE5BAF4410511A0F00161B87 /*
PDFOutline_SKExtensions.m in Sources */,
CE5BB0CF10515CCC00161B87 /* SKPDFDocument.m in
Sources */,
CE5BB0D310515D3100161B87 /* SKPDFPage.m in
Sources */,
+ CE5BB21610517AEF00161B87 /*
NSFileManager_SKExtensions.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit