Пример #1
0
        /// <exception cref="CopeException"><c>CopeException</c>.</exception>
        public ArchivePackerInfo PackArchive(string outputPath)
        {
            if (!ArchiveToolHelper.IsArchiveToolPresent())
            {
                string msg = "Archive tool has not been found! Searched at: " +
                             ArchiveToolHelper.GetArchiveToolPath();
                LoggingManager.SendError("ArchiveCreator - " + msg);
                throw new CopeException(msg);
            }
            if (!outputPath.EndsWith('\\'))
            {
                outputPath += '\\';
            }

            string uniqueName     = ArchiveName + '_' + DateTime.Now.ToProperString('_');
            string designFilePath = ArchiveToolHelper.GetArchiveToolDirectory() + uniqueName + ".sga_design";

            WriteDesignFile(designFilePath, outputPath + ArchiveName);

            string  arguments = string.Format(ARCHIVE_ARGUMENTS, InputDirectory.RemoveLast(1), outputPath + ArchiveName, uniqueName);
            Process packer    = StartPacker(arguments);

            if (packer == null || packer.Id == 0 || packer.Id == 1)
            {
                LoggingManager.SendError("ArchiveCreator - failed to start packer. Arguments: " + arguments);
                throw new CopeException("Failed to start archive.exe");
            }

            return(new ArchivePackerInfo(packer, designFilePath, outputPath + ArchiveName));
        }