Example #1
0
        private bool IncludeDirectory(List <IncludeItem> items, string initialDirectory, string folder, ref bool repeat, ref IncludeType action)
        {
            var relative = Utils.GetRelativePath(initialDirectory, ProjectLocation);

            if (!IncludeFiles(items, initialDirectory, Directory.GetFiles(folder), ref repeat, ref action))
            {
                return(false);
            }

            foreach (var dir in Directory.GetDirectories(folder))
            {
                var dirname = Path.GetFileName(dir);
                var initdir = Path.Combine(initialDirectory, dirname);
                var diritem = new IncludeItem
                {
                    SourcePath       = initdir,
                    IsDirectory      = true,
                    IncludeType      = IncludeType.Create,
                    RelativeDestPath = Path.Combine(relative, dirname)
                };
                items.Add(diritem);

                if (!IncludeDirectory(items, initdir, dir, ref repeat, ref action))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        private bool IncludeFiles(List <IncludeItem> items, string initialDirectory, string[] files, ref bool repeat, ref IncludeType action)
        {
            var relative = Utils.GetRelativePath(initialDirectory, ProjectLocation);

            foreach (var file in files)
            {
                var item = new IncludeItem
                {
                    SourcePath = file
                };

                if (file.StartsWith(ProjectLocation))
                {
                    // If the file is in the same directory as the .mgcb file, just add it and skip showing file dialogs

                    item.RelativeDestPath = PathHelper.GetRelativePath(ProjectLocation, file);
                    item.IncludeType      = IncludeType.Link;
                }
                else
                {
                    item.RelativeDestPath = Path.Combine(relative, Path.GetFileName(file));

                    if (!repeat)
                    {
                        if (!View.CopyOrLinkFile(file, File.Exists(Path.Combine(ProjectLocation, item.RelativeDestPath)), out action, out repeat))
                        {
                            return(false);
                        }
                    }

                    if (action == IncludeType.Skip)
                    {
                        continue;
                    }

                    if (action == IncludeType.Copy && File.Exists(Path.Combine(ProjectLocation, item.RelativeDestPath)))
                    {
                        item.IncludeType = IncludeType.Link;
                    }
                    else
                    {
                        item.IncludeType = action;
                    }
                }

                items.Add(item);
            }

            return(true);
        }
 public IncludeAction(IncludeItem item) : this(new List <IncludeItem> {
     item
 })
 {
 }