예제 #1
0
        /// <summary>
        /// 写出SPJ可执行程序
        /// </summary>
        /// <param name="problemId">问题ID</param>
        /// <param name="programFile">SPJ程序</param>
        public static void WriteSpecialJudgeProgramFile(int problemId, SpecialJudgeProgram programFile)
        {
            lock (GetDataLock(problemId))
            {
                string programPath = SpjManager.GetSpjProgramPathInTestData(problemId, programFile.LangConfiguration);
                if (File.Exists(programPath))
                {
                    File.Delete(programPath);
                }

                File.WriteAllBytes(programPath, programFile.Program);
            }
        }
예제 #2
0
        /// <summary>
        /// 获取SPJ可执行程序
        /// </summary>
        /// <param name="problemId">问题ID</param>
        /// <param name="index">索引</param>
        /// <returns>SPJ程序</returns>
        public static SpecialJudgeProgram GetSpecialJudgeProgramFile(int problemId, int index = 0)
        {
            lock (GetDataLock(problemId))
            {
                string programPath = SpjManager.FindSpjProgramInTestData(problemId, index);
                if (programPath == null)
                {
                    return(null);
                }

                ProgramLangConfig langConfig = SpjManager.GetLangConfigByProgramPath(programPath);
                if (langConfig == null)
                {
                    return(null);
                }

                return(new SpecialJudgeProgram
                {
                    LangConfiguration = langConfig,
                    Program = File.ReadAllBytes(programPath)
                });
            }
        }