Ejemplo n.º 1
0
        /// <summary>
        /// 编译SPJ程序
        /// </summary>
        /// <returns>是否编译并写出成功</returns>
        private bool CompileSpecialJudgeProgram()
        {
            Compiler compiler      = new Compiler(SpjContext);
            string   compileResult = compiler.Compile();

            if (compileResult != "")
            {
                throw new CompileException("Can not compile special judge program!" + Environment.NewLine +
                                           compileResult);
            }

            string spjProgramPath =
                Path.Combine(SpjContext.TempDirectory, LangConfig.ProgramFileName);

            if (!File.Exists(spjProgramPath))
            {
                throw new CompileException("Special judge program not found!");
            }

            SpecialJudgeProgram spjProgram = new SpecialJudgeProgram
            {
                LangConfiguration = LangConfig,
                Program           = File.ReadAllBytes(spjProgramPath)
            };

            TestDataManager.WriteSpecialJudgeProgramFile(JudgeTask.ProblemId, spjProgram);

            return(TestDataManager.GetSpecialJudgeProgramFile(JudgeTask.ProblemId) != null);
        }