Revision: 12092
          http://sourceforge.net/p/skim-app/code/12092
Author:   hofman
Date:     2020-12-28 15:59:29 +0000 (Mon, 28 Dec 2020)
Log Message:
-----------
Don't inspect file system to determine trailing slash when using 
URLByAppendingPathComponent

Modified Paths:
--------------
    trunk/NSFileManager_SKExtensions.m
    trunk/NSURL_SKExtensions.m
    trunk/PDFPage_SKExtensions.m
    trunk/SKConversionProgressController.m
    trunk/SKDownload.m
    trunk/SKMainDocument.m
    trunk/SKNoteWindowController.m
    trunk/SKScriptMenu.m
    trunk/SKSnapshotWindowController.m
    trunk/SKTemplateManager.m
    trunk/SKTransitionController.m

Modified: trunk/NSFileManager_SKExtensions.m
===================================================================
--- trunk/NSFileManager_SKExtensions.m  2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/NSFileManager_SKExtensions.m  2020-12-28 15:59:29 UTC (rev 12092)
@@ -47,7 +47,7 @@
         NSMutableArray *urlArray = [NSMutableArray array];
         NSString *appName = [[NSBundle mainBundle] 
objectForInfoDictionaryKey:(NSString *)kCFBundleNameKey];
         for (NSURL *url in [self 
URLsForDirectory:NSApplicationSupportDirectory inDomains:NSAllDomainsMask])
-            [urlArray addObject:[url URLByAppendingPathComponent:appName]];
+            [urlArray addObject:[url URLByAppendingPathComponent:appName 
isDirectory:YES]];
         applicationSupportDirectoryURLs = [urlArray copy];
     }
     return applicationSupportDirectoryURLs;
@@ -64,7 +64,7 @@
             NSURL *chewableURL = (NSURL 
*)CFURLCreateFromFSRef(kCFAllocatorDefault, &chewableRef);
 #pragma clang diagnostic pop
             NSString *appName = [[NSBundle mainBundle] 
objectForInfoDictionaryKey:(NSString *)kCFBundleNameKey];
-            chewableItemsDirectoryURL = [[chewableURL 
URLByAppendingPathComponent:appName] copy];
+            chewableItemsDirectoryURL = [[chewableURL 
URLByAppendingPathComponent:appName isDirectory:YES] copy];
             if ([chewableItemsDirectoryURL 
checkResourceIsReachableAndReturnError:NULL] == NO)
                 [self createDirectoryAtPath:[chewableItemsDirectoryURL path] 
withIntermediateDirectories:NO attributes:nil error:NULL];
             [chewableURL release];
@@ -75,7 +75,7 @@
     
     do {
         CFUUIDRef uuid = CFUUIDCreate(NULL);
-        uniqueURL = [chewableItemsDirectoryURL 
URLByAppendingPathComponent:[(NSString *)CFUUIDCreateString(NULL, uuid) 
autorelease]];
+        uniqueURL = [chewableItemsDirectoryURL 
URLByAppendingPathComponent:[(NSString *)CFUUIDCreateString(NULL, uuid) 
autorelease] isDirectory:YES];
         CFRelease(uuid);
     } while ([uniqueURL checkResourceIsReachableAndReturnError:NULL]);
     

Modified: trunk/NSURL_SKExtensions.m
===================================================================
--- trunk/NSURL_SKExtensions.m  2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/NSURL_SKExtensions.m  2020-12-28 15:59:29 UTC (rev 12092)
@@ -124,9 +124,11 @@
     NSURL *baseURL = [self URLByDeletingLastPathComponent];
     NSString *baseName = [[self lastPathComponent] 
stringByDeletingPathExtension];
     NSString *extension = [self pathExtension];
+    BOOL isDirectory = [[self absoluteString] hasSuffix:@"/"];
     NSInteger i = 0;
-    while ([uniqueFileURL checkResourceIsReachableAndReturnError:NULL])
-        uniqueFileURL = [baseURL URLByAppendingPathComponent:[[baseName 
stringByAppendingFormat:@"-%ld", (long)++i] 
stringByAppendingPathExtension:extension]];
+    while ([uniqueFileURL checkResourceIsReachableAndReturnError:NULL]) {
+        uniqueFileURL = [baseURL URLByAppendingPathComponent:[[baseName 
stringByAppendingFormat:@"-%ld", (long)++i] 
stringByAppendingPathExtension:extension] isDirectory:isDirectory];
+    }
     return uniqueFileURL;
 }
 

Modified: trunk/PDFPage_SKExtensions.m
===================================================================
--- trunk/PDFPage_SKExtensions.m        2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/PDFPage_SKExtensions.m        2020-12-28 15:59:29 UTC (rev 12092)
@@ -312,7 +312,7 @@
     if ([type isEqualToString:(NSString *)kPasteboardTypeFileURLPromise]) {
         NSURL *dropDestination = [pboard pasteLocationURL];
         NSString *filename = [NSString stringWithFormat:@"%@ %c %@", ([[[self 
containingDocument] displayName] stringByDeletingPathExtension] ?: @"PDF"), 
'-', [NSString stringWithFormat:NSLocalizedString(@"Page %@", @""), [self 
displayLabel]]];
-        NSURL *fileURL = [dropDestination 
URLByAppendingPathComponent:filename];
+        NSURL *fileURL = [dropDestination URLByAppendingPathComponent:filename 
isDirectory:NO];
         NSString *pathExt = nil;
         NSData *data = nil;
         

Modified: trunk/SKConversionProgressController.m
===================================================================
--- trunk/SKConversionProgressController.m      2020-12-27 15:55:36 UTC (rev 
12091)
+++ trunk/SKConversionProgressController.m      2020-12-28 15:59:29 UTC (rev 
12092)
@@ -270,7 +270,7 @@
             NSString *commandName = [toolPath lastPathComponent];
             NSURL *tmpDirURL = [[NSFileManager defaultManager] 
URLForDirectory:NSItemReplacementDirectory inDomain:NSUserDomainMask 
appropriateForURL:aURL create:YES error:NULL];
             BOOL outputPS = [commandName isEqualToString:@"dvips"];
-            NSURL *outFileURL = [tmpDirURL URLByAppendingPathComponent:[aURL 
lastPathComponentReplacingPathExtension:outputPS ? @"ps" : @"pdf"]];
+            NSURL *outFileURL = [tmpDirURL URLByAppendingPathComponent:[aURL 
lastPathComponentReplacingPathExtension:outputPS ? @"ps" : @"pdf"] 
isDirectory:NO];
             NSArray *arguments = [commandName isEqualToString:@"dvipdf"] ? 
[NSArray arrayWithObjects:[aURL path], [outFileURL path], nil] : [NSArray 
arrayWithObjects:@"-o", [outFileURL path], [aURL path], nil];
             
             task = [[NSTask alloc] init];

Modified: trunk/SKDownload.m
===================================================================
--- trunk/SKDownload.m  2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/SKDownload.m  2020-12-28 15:59:29 UTC (rev 12092)
@@ -421,7 +421,7 @@
         downloadURL = [NSURL fileURLWithPath:downloadDir isDirectory:NO];
     else
         downloadURL = [[NSFileManager defaultManager] 
URLForDirectory:NSDownloadsDirectory inDomain:NSUserDomainMask 
appropriateForURL:nil create:YES error:NULL];
-    NSURL *destinationURL = [[downloadURL 
URLByAppendingPathComponent:filename] uniqueFileURL];
+    NSURL *destinationURL = [[downloadURL URLByAppendingPathComponent:filename 
isDirectory:NO] uniqueFileURL];
     NSError *error = nil;
     NSFileManager *fm = [NSFileManager defaultManager];
     if ([[destinationURL URLByDeletingLastPathComponent] 
checkResourceIsReachableAndReturnError:NULL] == NO)

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/SKMainDocument.m      2020-12-28 15:59:29 UTC (rev 12092)
@@ -563,7 +563,7 @@
             if ([ourExtensions containsObject:[[url pathExtension] 
lowercaseString]] == NO) {
                 if (tmpURL == nil)
                     tmpURL = [fm URLForDirectory:NSItemReplacementDirectory 
inDomain:NSUserDomainMask appropriateForURL:fileURL create:YES error:NULL];
-                [fm copyItemAtURL:url toURL:[tmpURL 
URLByAppendingPathComponent:[url lastPathComponent]] error:NULL];
+                [fm copyItemAtURL:url toURL:[tmpURL 
URLByAppendingPathComponent:[url lastPathComponent] isDirectory:NO] error:NULL];
             }
         }
     }
@@ -602,7 +602,7 @@
             // move extra package content like version info to the new location
             NSFileManager *fm = [NSFileManager defaultManager];
             for (NSURL *url in [fm contentsOfDirectoryAtURL:tmpURL 
includingPropertiesForKeys:[NSArray array] options:0 error:NULL])
-                [fm moveItemAtURL:url toURL:[absoluteURL 
URLByAppendingPathComponent:[url lastPathComponent]] error:NULL];
+                [fm moveItemAtURL:url toURL:[absoluteURL 
URLByAppendingPathComponent:[url lastPathComponent] isDirectory:NO] error:NULL];
         }
     } else if ([attributes count]) {
         [attributes enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL 
*stop){
@@ -659,7 +659,7 @@
     NSString *typeName = [self fileType];
     NSURL *tmpURL = [[NSFileManager defaultManager] 
URLForDirectory:NSItemReplacementDirectory inDomain:NSUserDomainMask 
appropriateForURL:absoluteURL create:YES error:NULL];
     NSString *ext = [self fileNameExtensionForType:typeName 
saveOperation:NSSaveToOperation];
-    NSURL *tmpFileURL = [tmpURL URLByAppendingPathComponent:[[absoluteURL 
URLReplacingPathExtension:ext] lastPathComponent]];
+    NSURL *tmpFileURL = [tmpURL URLByAppendingPathComponent:[[absoluteURL 
URLReplacingPathExtension:ext] lastPathComponent] isDirectory:NO];
     BOOL didWrite = [self writeToURL:tmpFileURL ofType:typeName 
error:outError];
     if (didWrite) {
         if ([self canAttachNotesForType:typeName])
@@ -930,7 +930,7 @@
             NSArray *array = nil;
             NSNumber *number = nil;
             if ([docType isEqualToString:SKPDFBundleDocumentType]) {
-                NSDictionary *info = [NSDictionary 
dictionaryWithContentsOfURL:[[absoluteURL 
URLByAppendingPathComponent:BUNDLE_DATA_FILENAME] 
URLByAppendingPathExtension:@"plist"]];
+                NSDictionary *info = [NSDictionary 
dictionaryWithContentsOfURL:[[absoluteURL 
URLByAppendingPathComponent:BUNDLE_DATA_FILENAME isDirectory:NO] 
URLByAppendingPathExtension:@"plist"]];
                 if ([info isKindOfClass:[NSDictionary class]]) {
                     dictionary = [info objectForKey:SKPresentationOptionsKey];
                     array = [info objectForKey:SKTagsKey];
@@ -1288,13 +1288,13 @@
         targetFileName = [[self displayName] 
stringByAppendingPathExtension:targetExt];
     
     NSURL *targetDirURL = [[NSFileManager defaultManager] 
uniqueChewableItemsDirectoryURL];
-    NSURL *targetFileURL = [targetDirURL 
URLByAppendingPathComponent:targetFileName];
+    NSURL *targetFileURL = [targetDirURL 
URLByAppendingPathComponent:targetFileName isDirectory:NO];
     NSURL *tmpURL = nil;
     NSURL *fileURL = targetFileURL;
     
     if (shouldArchive) {
         tmpURL = [[NSFileManager defaultManager] 
URLForDirectory:NSItemReplacementDirectory inDomain:NSUserDomainMask 
appropriateForURL:targetFileURL create:YES error:NULL];
-        fileURL = [[tmpURL URLByAppendingPathComponent:targetFileName] 
URLReplacingPathExtension:typeExt];
+        fileURL = [[tmpURL URLByAppendingPathComponent:targetFileName 
isDirectory:NO] URLReplacingPathExtension:typeExt];
     }
     
     if ([self writeSafelyToURL:fileURL ofType:typeName 
forSaveOperation:NSAutosaveElsewhereOperation error:NULL] == NO) {

Modified: trunk/SKNoteWindowController.m
===================================================================
--- trunk/SKNoteWindowController.m      2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/SKNoteWindowController.m      2020-12-28 15:59:29 UTC (rev 12092)
@@ -336,7 +336,7 @@
         NSString *name = [note string];
         if ([name length] == 0)
             name = @"NoteImage";
-        NSURL *fileURL = [[destination URLByAppendingPathComponent:name] 
URLByAppendingPathExtension:@"tiff"];
+        NSURL *fileURL = [[destination URLByAppendingPathComponent:name 
isDirectory:NO] URLByAppendingPathExtension:@"tiff"];
         fileURL = [fileURL uniqueFileURL];
         if ([[image TIFFRepresentation] writeToURL:fileURL atomically:YES])
             return fileURL;

Modified: trunk/SKScriptMenu.m
===================================================================
--- trunk/SKScriptMenu.m        2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/SKScriptMenu.m        2020-12-28 15:59:29 UTC (rev 12092)
@@ -91,7 +91,7 @@
         
         for (NSURL *folderURL in [fm applicationSupportDirectoryURLs]) {
             NSNumber *isDir = nil;
-            folderURL = [folderURL 
URLByAppendingPathComponent:SCRIPTS_FOLDER_NAME];
+            folderURL = [folderURL 
URLByAppendingPathComponent:SCRIPTS_FOLDER_NAME isDirectory:YES];
             [folderURL getResourceValue:&isDir forKey:NSURLIsDirectoryKey 
error:NULL];
             if ([isDir boolValue])
                 [folders addObject:folderURL];

Modified: trunk/SKSnapshotWindowController.m
===================================================================
--- trunk/SKSnapshotWindowController.m  2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/SKSnapshotWindowController.m  2020-12-28 15:59:29 UTC (rev 12092)
@@ -701,7 +701,7 @@
         NSURL *dropDestination = [pboard pasteLocationURL];
         PDFPage *page = [[[self pdfView] document] pageAtIndex:[self 
pageIndex]];
         NSString *filename = [NSString stringWithFormat:@"%@ %c %@", ([[[self 
document] displayName] stringByDeletingPathExtension] ?: @"PDF"), '-', 
[NSString stringWithFormat:NSLocalizedString(@"Page %@", @""), [page 
displayLabel]]];
-        NSURL *fileURL = [[dropDestination 
URLByAppendingPathComponent:filename] URLByAppendingPathExtension:@"tiff"];
+        NSURL *fileURL = [[dropDestination 
URLByAppendingPathComponent:filename isDirectory:NO] 
URLByAppendingPathExtension:@"tiff"];
         fileURL = [fileURL uniqueFileURL];
         if ([[[self thumbnailWithSize:0.0] TIFFRepresentation] 
writeToURL:fileURL atomically:YES])
             [item setString:[fileURL absoluteString] forType:type];

Modified: trunk/SKTemplateManager.m
===================================================================
--- trunk/SKTemplateManager.m   2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/SKTemplateManager.m   2020-12-28 15:59:29 UTC (rev 12092)
@@ -65,7 +65,7 @@
         NSMutableArray *templates = [NSMutableArray array];
         
         for (NSURL *appSupportURL in [fm applicationSupportDirectoryURLs]) {
-            NSURL *templatesURL = [appSupportURL 
URLByAppendingPathComponent:TEMPLATES_DIRECTORY];
+            NSURL *templatesURL = [appSupportURL 
URLByAppendingPathComponent:TEMPLATES_DIRECTORY isDirectory:YES];
             NSNumber *isDir = nil;
             [appSupportURL getResourceValue:&isDir forKey:NSURLIsDirectoryKey 
error:NULL];
             if ([isDir boolValue]) {
@@ -92,7 +92,7 @@
     NSURL *url = nil;
     
     for (NSURL *appSupportURL in [[fm applicationSupportDirectoryURLs] 
arrayByAddingObject:[[NSBundle mainBundle] sharedSupportURL]]) {
-        url = [[appSupportURL URLByAppendingPathComponent:TEMPLATES_DIRECTORY] 
URLByAppendingPathComponent:typeName];
+        url = [[appSupportURL URLByAppendingPathComponent:TEMPLATES_DIRECTORY 
isDirectory:YES] URLByAppendingPathComponent:typeName isDirectory:NO];
         if ([url checkResourceIsReachableAndReturnError:NULL] == NO)
             url = nil;
         else break;

Modified: trunk/SKTransitionController.m
===================================================================
--- trunk/SKTransitionController.m      2020-12-27 15:55:36 UTC (rev 12091)
+++ trunk/SKTransitionController.m      2020-12-28 15:59:29 UTC (rev 12092)
@@ -239,7 +239,7 @@
                @"CoreGraphics SKTransitionWarpFlip", nil]];
         }
         // get our transitions
-        NSURL *transitionsURL = [[[NSBundle mainBundle] builtInPlugInsURL] 
URLByAppendingPathComponent:TRANSITIONS_PLUGIN];
+        NSURL *transitionsURL = [[[NSBundle mainBundle] builtInPlugInsURL] 
URLByAppendingPathComponent:TRANSITIONS_PLUGIN isDirectory:YES];
         [CIPlugIn loadPlugIn:transitionsURL allowExecutableCode:YES];
         // get all the transition filters
                [CIPlugIn loadAllPlugIns];

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to