Skip to content

Commit

Permalink
better temp file names
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegrosjean committed Oct 12, 2009
1 parent 02feb2b commit e94354c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
13 changes: 6 additions & 7 deletions ODBEditor.m
Expand Up @@ -31,7 +31,7 @@
@interface ODBEditor(Private)

- (BOOL)_launchExternalEditor;
- (NSString *)_tempFileForEditingString:(NSString *)string;
- (NSString *)_tempFileForEditingString:(NSString *)string ODBEditorCustomPathKey:(NSString *)customPathKey;
- (BOOL)_editFile:(NSString *)path isEditingString:(BOOL)editingStringFlag options:(NSDictionary *)options forClient:(id)client context:(NSDictionary *)context;
- (void)handleModifiedFileEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
- (void)handleClosedFileEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent;
Expand Down Expand Up @@ -136,8 +136,8 @@ - (BOOL)editFile:(NSString *)path options:(NSDictionary *)options forClient:(id)
}

- (BOOL)editString:(NSString *)string options:(NSDictionary *)options forClient:(id)client context:(NSDictionary *)context {
BOOL success = NO;
NSString *path = [self _tempFileForEditingString: string];
BOOL success = NO;
NSString *path = [self _tempFileForEditingString:string ODBEditorCustomPathKey:[options objectForKey:ODBEditorCustomPathKey]];

if (path != nil) {
success = [self _editFile: path isEditingString: YES options: options forClient: client context: context];
Expand All @@ -148,7 +148,6 @@ - (BOOL)editString:(NSString *)string options:(NSDictionary *)options forClient:

@end


@implementation ODBEditor(Private)

- (BOOL)_launchExternalEditor {
Expand Down Expand Up @@ -177,14 +176,14 @@ - (BOOL)_launchExternalEditor {
return success;
}

- (NSString *)_tempFileForEditingString:(NSString *)string {
- (NSString *)_tempFileForEditingString:(NSString *)string ODBEditorCustomPathKey:(NSString *)customPathKey {
static unsigned sTempFileSequence;

NSString *fileName = nil;

sTempFileSequence++;

fileName = [NSString stringWithFormat: @"ODBEditor-%@-%06d.txt", [[NSBundle mainBundle] bundleIdentifier], sTempFileSequence];
fileName = [NSString stringWithFormat: @"%@ (via %@) %03d.txt", customPathKey, [[NSProcessInfo processInfo] processName], sTempFileSequence];
fileName = [NSTemporaryDirectory() stringByAppendingPathComponent: fileName];

if (NO == [string writeToFile:fileName atomically:NO encoding:NSUTF8StringEncoding error:nil])
Expand Down
2 changes: 1 addition & 1 deletion QCAppDelegate.m
Expand Up @@ -297,7 +297,7 @@ - (IBAction)beginQuickCursorEdit:(id)sender {
NSDictionary *context = [NSDictionary dictionaryWithObject:focusedElement forKey:@"uiElement"];
NSString *processName = [focusedElement processName];
NSString *windowTitle = focusedElement.window.title;
NSString *editorCustomPath = [NSString stringWithFormat:@"%@ %@", processName, windowTitle];
NSString *editorCustomPath = [NSString stringWithFormat:@"%@ %@", processName, windowTitle];
[[ODBEditor sharedODBEditor] setEditorBundleIdentifier:bundleID];
[[ODBEditor sharedODBEditor] editString:value options:[NSDictionary dictionaryWithObject:editorCustomPath forKey:ODBEditorCustomPathKey] forClient:self context:context];
} else {
Expand Down
4 changes: 2 additions & 2 deletions QuickCursor-Info.plist
Expand Up @@ -23,9 +23,9 @@
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>CFBundleShortVersionString</key>
<string>1.1.4-Development</string>
<string>1.1.5-Development</string>
<key>CFBundleVersion</key>
<string>14</string>
<string>15</string>
<key>SUFeedURL</key>
<string>https://hogbaysoftware.appspot.com/products/quickcursor/releases.rss</string>
<key>SUPublicDSAKeyFile</key>
Expand Down
3 changes: 1 addition & 2 deletions release_notes
@@ -1,2 +1 @@
- **Added** Option to switch back to souch app when finished editing.
- **Changed** Icon to represent text cursor. Application icon still needs work.
- **Changed** QuickCursor tempfile names to include source application and source window title.

0 comments on commit e94354c

Please sign in to comment.