Revision: 7775
http://skim-app.svn.sourceforge.net/skim-app/?rev=7775&view=rev
Author: hofman
Date: 2012-11-02 23:01:09 +0000 (Fri, 02 Nov 2012)
Log Message:
-----------
use mkdtemp for temporary directory
Modified Paths:
--------------
trunk/NSFileManager_SKExtensions.h
trunk/NSFileManager_SKExtensions.m
trunk/SKDragImageView.m
Modified: trunk/NSFileManager_SKExtensions.h
===================================================================
--- trunk/NSFileManager_SKExtensions.h 2012-11-02 18:04:25 UTC (rev 7774)
+++ trunk/NSFileManager_SKExtensions.h 2012-11-02 23:01:09 UTC (rev 7775)
@@ -49,5 +49,6 @@
- (NSURL *)uniqueFileURL:(NSURL *)fileURL;
- (NSURL *)uniqueChewableItemsDirectoryURL;
+- (NSURL *)temporaryDirectoryURL;
@end
Modified: trunk/NSFileManager_SKExtensions.m
===================================================================
--- trunk/NSFileManager_SKExtensions.m 2012-11-02 18:04:25 UTC (rev 7774)
+++ trunk/NSFileManager_SKExtensions.m 2012-11-02 23:01:09 UTC (rev 7775)
@@ -108,4 +108,17 @@
return uniqueURL;
}
+- (NSURL *)temporaryDirectoryURL {
+ static NSURL *temporaryDirectoryURL = nil;
+ if (temporaryDirectoryURL == nil) {
+ char *template = strdup([[NSTemporaryDirectory()
stringByAppendingPathComponent:@"Skim.XXXXXX"] fileSystemRepresentation]);
+ const char *tempPath = mkdtemp(template);
+ temporaryDirectoryURL = [[NSURL alloc] initFileURLWithPath:[self
stringWithFileSystemRepresentation:tempPath length:strlen(tempPath)] ];
+ free(template);
+ }
+ if ([self fileExistsAtURL:temporaryDirectoryURL] == NO)
+ [self createDirectoryAtPath:[temporaryDirectoryURL path]
withIntermediateDirectories:YES attributes:nil error:NULL];
+ return temporaryDirectoryURL;
+}
+
@end
Modified: trunk/SKDragImageView.m
===================================================================
--- trunk/SKDragImageView.m 2012-11-02 18:04:25 UTC (rev 7774)
+++ trunk/SKDragImageView.m 2012-11-02 23:01:09 UTC (rev 7775)
@@ -56,12 +56,8 @@
}
NSFileManager *fm = [NSFileManager defaultManager];
- NSString *appName = [[NSBundle mainBundle]
objectForInfoDictionaryKey:(NSString *)kCFBundleNameKey];
- NSURL *tmpDirURL = [[NSURL fileURLWithPath:NSTemporaryDirectory()]
URLByAppendingPathComponent:appName];
- if ([fm fileExistsAtURL:tmpDirURL] == NO)
- [fm createDirectoryAtPath:[tmpDirURL path]
withIntermediateDirectories:YES attributes:nil error:NULL];
-
- NSURL *fileURL = [fm uniqueFileURL:[tmpDirURL
URLByAppendingPathComponent:@"SkimNote.tiff"]];
+ NSURL *fileURL = [[fm temporaryDirectoryURL]
URLByAppendingPathComponent:@"SkimNote.tiff"];
+ fileURL = [fm uniqueFileURL:fileURL];
[[image TIFFRepresentation] writeToURL:fileURL atomically:YES];
[[NSWorkspace sharedWorkspace] openURL:fileURL];
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
LogMeIn Central: Instant, anywhere, Remote PC access and management.
Stay in control, update software, and manage PCs from one command center
Diagnose problems and improve visibility into emerging IT issues
Automate, monitor and manage. Do more in less time with Central
http://p.sf.net/sfu/logmein12331_d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit