From d664740a88d7b4249cebee0936e5a3424e12e8a5 Mon Sep 17 00:00:00 2001 From: BusinessmanProgrammerSteve Date: Wed, 5 May 2010 23:41:27 +0000 Subject: [PATCH] Fix bug 160: silent blockfiles not copied between projects --- src/DirManager.cpp | 48 ++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/DirManager.cpp b/src/DirManager.cpp index 100608e3e..696715a39 100644 --- a/src/DirManager.cpp +++ b/src/DirManager.cpp @@ -839,28 +839,38 @@ BlockFile *DirManager::CopyBlockFile(BlockFile *b) return b; } - wxFileName newFile = MakeBlockFileName(); - - // We assume that the new file should have the same extension - // as the existing file - newFile.SetExt(b->GetFileName().GetExt()); - - //some block files such as ODPCMAliasBlockFIle don't always have - //a summary file, so we should check before we copy. - if(b->IsSummaryAvailable()) - { - if( !wxCopyFile(b->GetFileName().GetFullPath(), - newFile.GetFullPath()) ) - return NULL; + // Copy the blockfile + BlockFile *b2; + if (b->GetFileName().GetName().IsEmpty()) { + // Block files with no filename (i.e. SilentBlockFile) just need an + // in-memory copy + b2 = b->Copy(wxFileName()); } - - BlockFile *b2 = b->Copy(newFile); + else + { + wxFileName newFile = MakeBlockFileName(); - if (b2 == NULL) - return NULL; + // We assume that the new file should have the same extension + // as the existing file + newFile.SetExt(b->GetFileName().GetExt()); - blockFileHash[newFile.GetName()]=b2; - aliasList.Add(newFile.GetFullPath()); + //some block files such as ODPCMAliasBlockFIle don't always have + //a summary file, so we should check before we copy. + if(b->IsSummaryAvailable()) + { + if( !wxCopyFile(b->GetFileName().GetFullPath(), + newFile.GetFullPath()) ) + return NULL; + } + + b2 = b->Copy(newFile); + + if (b2 == NULL) + return NULL; + + blockFileHash[newFile.GetName()]=b2; + aliasList.Add(newFile.GetFullPath()); + } return b2; }