Permalink
Browse files

change method names of temporary file convenience methods to include …

…the word "unique" in them so that it's clear that calling these will always produce a unique path, not suitable for re-using.
  • Loading branch information...
danwood committed Sep 17, 2010
1 parent 9702354 commit 2b418620c56b16480f191cc00df2248dee33b192
Showing with 11 additions and 9 deletions.
  1. +1 −1 IMBPyramidObjectPromise.m
  2. +3 −3 NSFileManager+iMedia.h
  3. +7 −5 NSFileManager+iMedia.m
@@ -118,7 +118,7 @@ + (NSURL*)urlForObject:(IMBLightroomObject*)lightroomObject
BOOL success = NO;
NSData* jpegData = [data subdataWithRange:NSMakeRange(index, [data length] - index)];
NSString* fileName = [[(NSString*)lightroomObject.location lastPathComponent] stringByDeletingPathExtension];
NSString* jpegPath = [[[NSFileManager threadSafeManager] temporaryFile:fileName] stringByAppendingPathExtension:@"jpg"];
NSString* jpegPath = [[[NSFileManager threadSafeManager] uniqueTemporaryFile:fileName] stringByAppendingPathExtension:@"jpg"];
if ((orientation == nil) || [orientation isEqual:@"AB"]) {
success = [jpegData writeToFile:jpegPath atomically:YES];
View
@@ -56,9 +56,9 @@
- (BOOL)createDirectoryPath:(NSString *)path attributes:(NSDictionary *)attributes;
- (NSString *)pathResolved:(NSString *)path;
- (NSString*)temporaryFile:(NSString*)name;
- (NSString*)temporaryFile:(NSString*)name withinDirectory:(NSString*)directoryPath;
- (NSString*)temporaryPathWithinDirectory:(NSString*)directoryPath;
- (NSString*)uniqueTemporaryFile:(NSString*)name;
- (NSString*)uniqueTemporaryFile:(NSString*)name withinDirectory:(NSString*)directoryPath;
- (NSString*)uniqueTemporaryPathWithinDirectory:(NSString*)directoryPath;
- (NSString*) volumeNameAtPath:(NSString*)inPath;
- (NSString*) relativePathToVolumeAtPath:(NSString*)inPath;
View
@@ -154,20 +154,20 @@ - (NSString *)pathResolved:(NSString *)path
return resolvedPath;
}
- (NSString*)temporaryFile:(NSString*)name
- (NSString*)uniqueTemporaryFile:(NSString*)name
{
NSString *processName = [[NSProcessInfo processInfo] processName];
NSString *directoryName = [NSString stringWithFormat:@"%@_iMediaTemporary", processName];
NSString *directoryPath = [NSTemporaryDirectory() stringByAppendingPathComponent:directoryName];
[self createDirectoryAtPath:directoryPath withIntermediateDirectories:YES attributes:nil error:NULL];
return [self temporaryFile:name withinDirectory:directoryPath];
return [self uniqueTemporaryFile:name withinDirectory:directoryPath];
}
- (NSString*)temporaryFile:(NSString*)name withinDirectory:(NSString*)directoryPath
- (NSString*)uniqueTemporaryFile:(NSString*)name withinDirectory:(NSString*)directoryPath
{
NSString *temporaryPath = [self temporaryPathWithinDirectory:directoryPath];
NSString *temporaryPath = [self uniqueTemporaryPathWithinDirectory:directoryPath];
if ([name length] > 0) {
[self createDirectoryAtPath:temporaryPath withIntermediateDirectories:YES attributes:nil error:NULL];
@@ -178,8 +178,10 @@ - (NSString*)temporaryFile:(NSString*)name withinDirectory:(NSString*)directoryP
return temporaryPath;
}
// Creates a new, unique path (for a directory or a file), so don't use this if you want to match up
// with an existing downloaded file!
- (NSString*)temporaryPathWithinDirectory:(NSString*)directoryPath
- (NSString*)uniqueTemporaryPathWithinDirectory:(NSString*)directoryPath
{
NSString *tempFileTemplate = [directoryPath stringByAppendingPathComponent:@"XXXXXXXXXXXX"];
const char *tempFileTemplateCString = [tempFileTemplate fileSystemRepresentation];

0 comments on commit 2b41862

Please sign in to comment.