Exemplo n.º 1
0
        /// <summary>
        /// This will assign all files to the proper destination.
        /// </summary>
        /// <param name="fileList">The list of files inside the mod archive.</param>
        /// <param name="stopPatterns">patterns matching files or directories that should be at the top of the directory structure.</param>
        /// <param name="progressDelegate">A delegate to provide progress feedback.</param>
        /// <param name="coreDelegate">A delegate for all the interactions with the js core.</param>
        protected async Task <List <Instruction> > BasicModInstall(List <string> fileList,
                                                                   List <string> stopPatterns,
                                                                   ProgressDelegate progressDelegate,
                                                                   CoreDelegates coreDelegate)
        {
            List <Instruction> FilesToInstall = new List <Instruction>();
            string             prefix         = ArchiveStructure.FindPathPrefix(fileList, stopPatterns);

            await Task.Run(() =>
            {
                foreach (string ArchiveFile in fileList)
                {
                    if (ArchiveFile.EndsWith("" + Path.DirectorySeparatorChar))
                    {
                        // don't include directories, only files
                        continue;
                    }
                    string destination;
                    if (ArchiveFile.StartsWith(prefix))
                    {
                        destination = ArchiveFile.Substring(prefix.Length);
                    }
                    else
                    {
                        destination = ArchiveFile;
                    }
                    FilesToInstall.Add(Instruction.CreateCopy(ArchiveFile, destination));
                    // Progress should increase.
                }
            });

            return(FilesToInstall);
        }
        /// <summary>
        /// This will assign all files to the proper destination.
        /// </summary>
        /// <param name="FileList">The list of files inside the mod archive.</param>
        /// <param name="pluginQueryDelegate">A delegate to query whether a plugin already exists.</param>
        /// <param name="progressDelegate">A delegate to provide progress feedback.</param>
        /// <param name="error_OverwritesDelegate">A delegate to present errors and file overwrite requests.</param>
        protected bool BasicModInstall(List <string> fileList)
        {
            foreach (string ArchiveFile in fileList)
            {
                if (ArchiveFile.EndsWith("" + Path.DirectorySeparatorChar) ||
                    ArchiveFile.EndsWith("" + Path.AltDirectorySeparatorChar))
                {
                    modInstallInstructions.Add(Instruction.CreateMKDir(ArchiveFile));
                }
                else
                {
                    modInstallInstructions.Add(Instruction.CreateCopy(ArchiveFile, ArchiveFile));
                }
                // Progress should increase.
            }

            return(true);
        }