Revision: 11538
http://bibdesk.svn.sourceforge.net/bibdesk/?rev=11538&view=rev
Author: hofman
Date: 2007-11-11 09:16:32 -0800 (Sun, 11 Nov 2007)
Log Message:
-----------
Merge in some changes from trunk.
Modified Paths:
--------------
branches/TRY_ARM_FILE_INTERFACE/bibdesk/BDSKFiler.m
Modified: branches/TRY_ARM_FILE_INTERFACE/bibdesk/BDSKFiler.m
===================================================================
--- branches/TRY_ARM_FILE_INTERFACE/bibdesk/BDSKFiler.m 2007-11-11 15:28:31 UTC
(rev 11537)
+++ branches/TRY_ARM_FILE_INTERFACE/bibdesk/BDSKFiler.m 2007-11-11 17:16:32 UTC
(rev 11538)
@@ -112,6 +112,7 @@
BibItem *paper = nil;
NSString *path = nil;
NSString *newPath = nil;
+ NSString *newRelativePath = nil;
NSMutableArray *fileInfoDicts = [NSMutableArray
arrayWithCapacity:numberOfPapers];
NSMutableDictionary *info = nil;
BOOL useRelativePath = [[OFPreferenceWrapper sharedPreferenceWrapper]
boolForKey:BDSKAutoFileUsesRelativePathKey];
@@ -176,6 +177,9 @@
paper = (BibItem *)paperInfo;
path = [paper localUrlPathInheriting:NO];
newPath = [[NSURL URLWithString:[paper
suggestedLocalUrl]] path];
+ newRelativePath = newPath;
+ if ([newPath hasPrefix:papersFolderPath])
+ newRelativePath = [newPath
substringFromIndex:[papersFolderPath length]];
}else{
// an explicit move, possibly from undo: a list of info
dictionaries
paper = [paperInfo objectForKey:@"paper"];
@@ -188,16 +192,22 @@
[progressIndicator displayIfNeeded];
}
- if([NSString isEmptyString:path] || [NSString
isEmptyString:newPath] ||
- [path isEqualToString:newPath])
+ if([NSString isEmptyString:path] || [NSString
isEmptyString:newPath]){
continue;
-
+ }else if([path isEqualToString:newPath]){
+ // we still want to change the field when we change from full URL
to relative path or v.v.
+ oldValue = [paper valueOfField:field inherit:NO];
+ BOOL wasRelative = [oldValue hasPrefix:@"file://"] == NO &&
[oldValue isAbsolutePath] == NO;
+ if (initial == NO || useRelativePath != wasRelative ||
[newRelativePath isAbsolutePath] == NO)
+ continue;
+ }
+
info = [NSMutableDictionary dictionaryWithCapacity:6];
[info setObject:paper forKey:@"paper"];
error = nil;
oldValue = [[NSURL fileURLWithPath:path] absoluteString]; // we don't
use the field value, as we might have already changed it in undo or find/replace
- if(check && ![paper canSetLocalUrl]){
+ if(check && NO == [paper canSetLocalUrl]){
[info setObject:NSLocalizedString(@"Incomplete information to
generate file name.",@"") forKey:@"status"];
[info setObject:[NSNumber
numberWithInt:BDSKIncompleteFieldsErrorMask] forKey:@"flag"];
@@ -206,7 +216,7 @@
[info setObject:newPath forKey:@"newPath"];
[self insertObject:info inErrorInfoDictsAtIndex:[self
countOfErrorInfoDicts]];
- }else if(![fm movePath:path toPath:newPath force:force error:&error]){
+ }else if(NO == [path isEqualToString:newPath] && NO == [fm
movePath:path toPath:newPath force:force error:&error]){
NSDictionary *errorInfo = [error userInfo];
NSString *fix = [errorInfo
objectForKey:NSLocalizedRecoverySuggestionErrorKey];
@@ -222,14 +232,7 @@
newValue = [[NSURL fileURLWithPath:newPath]
absoluteString];
if(initial) {// otherwise will be done by undo of
setField:
- if(useRelativePath){
- NSString *relativePath = newPath;
- if ([newPath hasPrefix:papersFolderPath])
- relativePath = [newPath
substringFromIndex:[papersFolderPath length]];
- [paper setField:field toValue:relativePath];
- }else{
- [paper setField:field toValue:newValue];
- }
+ [paper setField:field toValue:useRelativePath ?
newRelativePath : newValue];
}else{
// make sure the UI is notified that the linked file has
changed, as this is often called after setField:toValue:
NSString *value = [paper valueOfField:field];
@@ -238,15 +241,17 @@
object:paper
userInfo:notifInfo];
}
- if(scriptHook){
- [papers addObject:paper];
- [oldValues addObject:oldValue];
- [newValues addObject:newValue];
- }
- // switch them as this is used in undo
- [info setObject:path forKey:@"newPath"];
- [info setObject:newPath forKey:@"oldPath"];
- [fileInfoDicts addObject:info];
+ if(NO == [path isEqualToString:newPath]){
+ if(scriptHook){
+ [papers addObject:paper];
+ [oldValues addObject:oldValue];
+ [newValues addObject:newValue];
+ }
+ // switch them as this is used in undo
+ [info setObject:path forKey:@"newPath"];
+ [info setObject:newPath forKey:@"oldPath"];
+ [fileInfoDicts addObject:info];
+ }
}
}
@@ -563,13 +568,12 @@
// get the Finder comment (spotlight comment)
comment = [self commentForURL:[NSURL
fileURLWithPath:resolvedPath]];
NSString *fileType = [[self fileAttributesAtPath:resolvedPath
traverseLink:NO] objectForKey:NSFileType];
- NS_DURING
- [self createPathToFile:resolvedNewPath attributes:nil]; //
create parent directories if necessary (OmniFoundation)
- NS_HANDLER
- NSLog(@"Ignoring exception %@ raised while creating path %@",
[localException name], resolvedNewPath);
+
+ // create parent directories if necessary (OmniFoundation)
+ if (NO == [self createPathToFile:resolvedNewPath attributes:nil
error:NULL]) {
status = NSLocalizedString(@"Unable to create parent
directory.", @"AutoFile error message");
statusFlag = BDSKCannotCreateParentErrorMask;
- NS_ENDHANDLER
+ }
if(statusFlag == BDSKNoError){
if([fileType isEqualToString:NSFileTypeDirectory] && force ==
NO &&
[[OFPreferenceWrapper sharedPreferenceWrapper]
boolForKey:BDSKWarnOnMoveFolderKey]){
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit