in Nodejs/Product/Nodejs/SharedProject/ProjectNode.cs [4753:4852]
private int AddDirectory(VSADDRESULT[] result, HierarchyNode n, string file, bool? promptOverwrite)
{
// need to recursively add all of the directory contents
var targetFolder = n.FindImmediateChildByName(Path.GetFileName(file));
if (targetFolder == null)
{
var fullPath = Path.Combine(GetBaseDirectoryForAddingFiles(n), Path.GetFileName(file));
Directory.CreateDirectory(fullPath);
var newChild = CreateFolderNode(fullPath);
n.AddChild(newChild);
targetFolder = newChild;
}
else if (targetFolder.IsNonMemberItem)
{
var hr = targetFolder.IncludeInProject(true);
if (ErrorHandler.Succeeded(hr))
{
OnInvalidateItems(targetFolder.Parent);
}
return hr;
}
else if (promptOverwrite == null)
{
var res = MessageBox.Show(
string.Format(
@"This folder already contains a folder called '{0}'.
If the files in the existing folder have the same names as files in the folder you are copying, do you want to replace the existing files?", Path.GetFileName(file)),
"Merge Folders",
MessageBoxButtons.YesNoCancel
);
// yes means prompt for each file
// no means don't prompt for any of the files
// cancel means forget what I'm doing
switch (res)
{
case DialogResult.Cancel:
result[0] = VSADDRESULT.ADDRESULT_Cancel;
return (int)OleConstants.OLECMDERR_E_CANCELED;
case DialogResult.No:
promptOverwrite = false;
break;
case DialogResult.Yes:
promptOverwrite = true;
break;
}
}
var empty = Guid.Empty;
// add the files...
var dirFiles = Directory.GetFiles(file);
if (dirFiles.Length > 0)
{
var subRes = AddItemWithSpecificInternal(
targetFolder.ID,
VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE,
null,
(uint)dirFiles.Length,
dirFiles,
IntPtr.Zero,
0,
ref empty,
null,
ref empty,
result,
promptOverwrite: promptOverwrite
);
if (ErrorHandler.Failed(subRes))
{
return subRes;
}
}
// add any subdirectories...
var subDirs = Directory.GetDirectories(file);
if (subDirs.Length > 0)
{
return AddItemWithSpecificInternal(
targetFolder.ID,
VSADDITEMOPERATION.VSADDITEMOP_CLONEFILE,
null,
(uint)subDirs.Length,
subDirs,
IntPtr.Zero,
0,
ref empty,
null,
ref empty,
result,
promptOverwrite: promptOverwrite
);
}
return VSConstants.S_OK;
}