From 0a98952de1eb2fed24ce9edf7a96c920af9fa245 Mon Sep 17 00:00:00 2001 From: "Philippe C.D. Robert" Date: Sat, 29 Dec 2001 14:41:43 +0000 Subject: [PATCH] Fixed some minor issues with file backup handling git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@11913 72102866-910b-0410-8b05-ffd578937521 --- PCLib/PCProject.m | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/PCLib/PCProject.m b/PCLib/PCProject.m index 1059c88..963290e 100644 --- a/PCLib/PCProject.m +++ b/PCLib/PCProject.m @@ -563,10 +563,16 @@ NSString *bu = [projectPath stringByAppendingPathComponent:@"GNUmakefile~"]; NSFileManager *fm = [NSFileManager defaultManager]; - if (![fm movePath:mf toPath:bu handler:nil]) { - NSRunAlertPanel(@"Attention!", - @"Could not keep a backup of the GNUMakefile!", - @"OK",nil,nil); + if( [fm isReadableFileAtPath:mf] ) { + if( [fm isWritableFileAtPath:bu] ) { + [fm removeFileAtPath:bu handler:nil]; + } + + if (![fm copyPath:mf toPath:bu handler:nil]) { + NSRunAlertPanel(@"Attention!", + @"Could not keep a backup of the GNUMakefile!", + @"OK",nil,nil); + } } return [self save]; @@ -807,19 +813,23 @@ NSString *keepBackup = [defs objectForKey:KeepBackup]; BOOL shouldKeep = [keepBackup isEqualToString:@"YES"]; - if ( shouldKeep == NO && [fm isWritableFileAtPath:backup] ) { - [fm removeFileAtPath:backup handler:nil]; + if ( shouldKeep == YES && [fm isWritableFileAtPath:backup] ) { + ret = [fm removeFileAtPath:backup handler:nil]; + + if( ret == NO ) { + NSRunAlertPanel(@"Attention!", + @"Could not remove the old project backup '%@'!", + @"OK",nil,nil,backup); + } } if (shouldKeep && [fm isReadableFileAtPath:file]) { ret = [fm copyPath:file toPath:backup handler:nil]; if( ret == NO ) { - NSString *name = [projectDict objectForKey:PCProjectName]; - NSRunAlertPanel(@"Attention!", - @"Could not save the backup file for '%@'!", - @"OK",nil,nil,name); + @"Could not save the project backup file '%@'!", + @"OK",nil,nil,file); } }