#import "SVNPalette.h" #import #import @interface IBDocument : NSObject - (NSString*) documentPath; @end @implementation SVNPalette + (void) load { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentWillSave:) name:IBWillSaveDocumentNotification object:0]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentDidSave:) name:IBDidSaveDocumentNotification object:0]; } + (void) documentWillSave:(NSNotification*)note { IBDocument *doc = [note object]; NSFileManager *fm = [NSFileManager defaultManager]; NSString *path = [[doc documentPath] stringByAppendingPathComponent:@".svn"]; NSString *tmppath = [[doc documentPath] stringByAppendingString:@".svn-guts"]; if ([fm fileExistsAtPath:path]) { [fm movePath:path toPath:tmppath handler:0]; } } + (void) documentDidSave:(NSNotification*)note { IBDocument *doc = [note object]; NSFileManager *fm = [NSFileManager defaultManager]; NSString *path = [[doc documentPath] stringByAppendingPathComponent:@".svn"]; NSString *backuppath = [[doc documentPath] stringByAppendingString:@"~/.svn"]; NSString *tmppath = [[doc documentPath] stringByAppendingString:@".svn-guts"]; if ([fm fileExistsAtPath:tmppath]) { [fm movePath:tmppath toPath:path handler:0]; } if ([fm fileExistsAtPath:backuppath]) { [fm removeFileAtPath:backuppath handler:0]; } } @end