diff --git a/PCLib/PCProject.h b/PCLib/PCProject.h index 6fb4373..dd162ba 100644 --- a/PCLib/PCProject.h +++ b/PCLib/PCProject.h @@ -188,6 +188,8 @@ static NSString * const PCLibraryVar = @"LIBRARY_VAR"; // Returns YES if type is a valid key and file is not contained in the project already - (void)addFile:(NSString *)file forKey:(NSString *)key; +- (void)addFile:(NSString *)file forKey:(NSString *)key copy:(BOOL)yn; + - (void)removeFile:(NSString *)file forKey:(NSString *)key; - (BOOL)removeSelectedFilePermanently:(BOOL)yn; - (void)renameFile:(NSString *)aFile; diff --git a/PCLib/PCProject.m b/PCLib/PCProject.m index 5aebec9..74cd3ce 100644 --- a/PCLib/PCProject.m +++ b/PCLib/PCProject.m @@ -600,29 +600,43 @@ - (void)addFile:(NSString *)file forKey:(NSString *)type { - NSMutableArray *files = [NSMutableArray arrayWithArray:[projectDict objectForKey:type]]; - NSMutableString *newFile = [NSMutableString stringWithString:[file lastPathComponent]]; - - if ([type isEqualToString:PCLibraries]) { - [newFile deleteCharactersInRange:NSMakeRange(0,3)]; - newFile = [newFile stringByDeletingPathExtension]; - } - - if ([files containsObject:newFile]) { - NSRunAlertPanel(@"Attention!",@"The file %@ is already part of this project!",@"OK",nil,nil,newFile); - return; - } + [self addFile:file forKey:type copy:NO]; +} +- (void)addFile:(NSString *)file forKey:(NSString *)type copy:(BOOL)yn +{ + NSMutableArray *files = [NSMutableArray arrayWithArray:[projectDict objectForKey:type]]; + NSMutableString *newFile = [NSMutableString stringWithString:[file lastPathComponent]]; + + if ([type isEqualToString:PCLibraries]) { + [newFile deleteCharactersInRange:NSMakeRange(0,3)]; + newFile = [newFile stringByDeletingPathExtension]; + } + + if ([files containsObject:newFile]) { + NSRunAlertPanel(@"Attention!",@"The file %@ is already part of this project!",@"OK",nil,nil,newFile); + return; + } + #ifdef DEBUG - NSLog(@"<%@ %x>: adding file %@ for key %@",[self class],self,newFile,type); + NSLog(@"<%@ %x>: adding file %@ for key %@",[self class],self,newFile,type); #endif DEBUG + + // Add the new file + [files addObject:newFile]; + [projectDict setObject:files forKey:type]; + + // Synchronise the makefile! + [self writeMakefile]; + + if (yn) { + NSFileManager *manager = [NSFileManager defaultManager]; + NSString *destination = [[self projectPath] stringByAppendingPathComponent:newFile]; - // Add the new file - [files addObject:newFile]; - [projectDict setObject:files forKey:type]; - - // Synchronise the makefile! - [self writeMakefile]; + if (![manager copyPath:file toPath:destination handler:nil]) { + NSRunAlertPanel(@"Attention!",@"The file %@ could not be copied to %@!",@"OK",nil,nil,newFile,destination); + } + } } - (void)removeFile:(NSString *)file forKey:(NSString *)key diff --git a/PCLib/PCServer.m b/PCLib/PCServer.m index 9ba5260..1119e00 100644 --- a/PCLib/PCServer.m +++ b/PCLib/PCServer.m @@ -133,7 +133,7 @@ scrollView = [[NSScrollView alloc] initWithFrame:NSMakeRect (-1,-1,514,322)]; [scrollView setDocumentView:textView]; - [textView setMinSize:NSMakeSize(0.0,[scrollView contentSize].height)]; + //[textView setMinSize:NSMakeSize(0.0,[scrollView contentSize].height)]; [[textView textContainer] setContainerSize:NSMakeSize([scrollView contentSize].width,1e7)]; [scrollView setHasHorizontalScroller: YES]; [scrollView setHasVerticalScroller: YES];