public bool Clone(CloneObjectParameters parameters, HashSet <string> alreadyCloned, bool execute)
{
string newAlias = parameters.TransformAlias(mAlias);
string sourceModName = Module.Name;
string targetModName = parameters.TargetModule == null ? sourceModName : parameters.TargetModule;
Module targetModule = ModuleDataManager.GetInstance().GetMod(targetModName);
if (targetModule.GetAliasFile(newAlias) != null)
{
// MessageBox.Show("The alias " + newAlias + " already exists in manifest.json");
return(false);
}
string modPath = targetModule.ParentDirectory;
string relativePath = ResolvedPath.Replace(mModule.Path + "/", "");
string newPath = parameters.TransformParameter(relativePath);
string fullPath = modPath + "/" + targetModName + "/" + newPath;
if (!FileData.Clone(fullPath, parameters, alreadyCloned, execute))
{
return(false);
}
alreadyCloned.Add(targetModName + ':' + newAlias);
if (execute)
{
string fileLocation = "file(" + newPath + ")";
ModuleFile file = new ModuleFile(targetModule, newAlias, fileLocation);
file.TryLoad();
if (file.FileData != null)
{
targetModule.AddToManifest(newAlias, fileLocation, parameters.manifestEntryType);
targetModule.WriteManifestToFile();
return(true);
}
}
else
{
return(true);
}
return(false);
}