Test for existance before changing/copying

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/projectcenter/trunk@14925 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2002-11-05 03:47:01 +00:00
parent 5755a72fe4
commit 088455e8c6
4 changed files with 25 additions and 7 deletions

View file

@ -1,3 +1,8 @@
2002-11-04 Adam Fedor <fedor@gnu.org>
* PCBaseFileType.m (-createFileOfType:path:project:): Only add
file extension if it doesn't already have one
2002-06-01 15:56 probert
* GNUmakefile, PCBaseFileTypes.pcproj: Installation into

View file

@ -137,7 +137,8 @@ static NSDictionary *dict = nil;
if ([type isEqualToString:ObjCClass])
{
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"class" ofType:@"template"];
newFile = [path stringByAppendingPathExtension:@"m"];
if ([[path pathExtension] isEqual: @"m"] == NO)
newFile = [path stringByAppendingPathExtension:@"m"];
[fm copyPath:_file toPath:newFile handler:nil];
[files setObject:ObjCClass forKey:newFile];
@ -164,7 +165,8 @@ static NSDictionary *dict = nil;
else if ([type isEqualToString:ObjCNSViewClass])
{
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"nsviewclass" ofType:@"template"];
newFile = [path stringByAppendingPathExtension:@"m"];
if ([[path pathExtension] isEqual: @"m"] == NO)
newFile = [path stringByAppendingPathExtension:@"m"];
[fm copyPath:_file toPath:newFile handler:nil];
[files setObject:ObjCNSViewClass forKey:newFile];
@ -191,7 +193,8 @@ static NSDictionary *dict = nil;
else if ([type isEqualToString:CFile])
{
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cfile" ofType:@"template"];
newFile = [path stringByAppendingPathExtension:@"c"];
if ([[path pathExtension] isEqual: @"c"] == NO)
newFile = [path stringByAppendingPathExtension:@"c"];
[fm copyPath:_file toPath:newFile handler:nil];
[files setObject:CFile forKey:newFile];
@ -215,7 +218,8 @@ static NSDictionary *dict = nil;
else if ([type isEqualToString:ObjCHeader])
{
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"header" ofType:@"template"];
newFile = [path stringByAppendingPathExtension:@"h"];
if ([[path pathExtension] isEqual: @"h"] == NO)
newFile = [path stringByAppendingPathExtension:@"h"];
[fm copyPath:_file toPath:newFile handler:nil];
[self replaceTagsInFileAtPath:newFile withProject:aProject type:type];
[files setObject:ObjCHeader forKey:newFile];
@ -228,7 +232,8 @@ static NSDictionary *dict = nil;
else if ([type isEqualToString:CHeader])
{
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"cheader" ofType:@"template"];
newFile = [path stringByAppendingPathExtension:@"h"];
if ([[path pathExtension] isEqual: @"h"] == NO)
newFile = [path stringByAppendingPathExtension:@"h"];
[fm copyPath:_file toPath:newFile handler:nil];
[self replaceTagsInFileAtPath:newFile withProject:aProject type:type];
[files setObject:CHeader forKey:newFile];
@ -241,7 +246,8 @@ static NSDictionary *dict = nil;
else if ([type isEqualToString:ProtocolFile])
{
_file = [[NSBundle bundleForClass:[self class]] pathForResource:@"protocol" ofType:@"template"];
newFile = [path stringByAppendingPathExtension:@"h"];
if ([[path pathExtension] isEqual: @"h"] == NO)
newFile = [path stringByAppendingPathExtension:@"h"];
[fm copyPath:_file toPath:newFile handler:nil];
[self replaceTagsInFileAtPath:newFile withProject:aProject type:type];
[files setObject:ProtocolFile forKey:newFile];

View file

@ -1,3 +1,8 @@
2002-11-04 Adam Fedor <fedor@gnu.org>
* PCFileManager.m (-showAddFileWindow): Only copy file if it isn't
already there.
2002-10-06 15:45 probert
* PCEditor.h, PCEditor.m, PCEditorView.m, PCProjectEditor.h,

View file

@ -354,7 +354,9 @@ static PCFileManager *_mgr = nil;
fileName = [fn lastPathComponent];
pth = [pp stringByAppendingPathComponent:fileName];
[[NSFileManager defaultManager] copyPath:fn toPath:pth handler:nil];
/* Only copy the file if it isn't already there */
if ([pth isEqual: fn] == NO)
[[NSFileManager defaultManager] copyPath:fn toPath:pth handler:nil];
[project addFile:pth forKey:otherKey];
}