Ejemplo n.º 1
0
        /// <summary>
        /// Start the packing for the current options
        /// </summary>
        /// <exception cref="FilePackCreationException">Error when creating the list of file to pack</exception>
        /// <exception cref="BspBackupCreationException">Error when creating the bsp backup</exception>
        /// <exception cref="BspZipExecutionException">Error during bspzip execution</exception>
        public override void Start()
        {
            UpdateSettings();
            // Remove any extra '/'
            mapContent.CleanPath();

            // The base path doesn't have a final '\'
            FilePack filePack = new FilePack(mapContent.Path, hasRestrictions, toolSettings.DirectoriesRestrictions);

            try
            {
                filePack.FindAllFiles();
                filePack.OutputToFile();
            }
            catch (Exception ex)
            {
                throw new FilePackCreationException(MessageConstants.MessageListFilesFail, ex);
            }
            logsOutput.AppendLine("Created " + Constants.FilesListText);
            if (!System.IO.File.Exists(Constants.FilesListText))
            {
                // Just for safety, but the file is supposed to exist
                throw new FilePackCreationException(MessageConstants.MessageListFilesNotFound);
            }
            if (bspPath.Equals(outputBspPath))
            {
                // If we override the original BSP, we make a backup
                try
                {
                    CreateBackupBsp();
                }
                catch (Exception ex)
                {
                    throw new BspBackupCreationException(MessageConstants.MessageCopyBspFail, ex);
                }
            }
            try
            {
                StartProcess();
            }
            catch (Exception ex)
            {
                throw new BspZipExecutionException(MessageConstants.MessageBspzipFail, ex);
            }
        }