Пример #1
0
 private void createSrcFile() throws ServerException {
   try {
     exec("touch " + srcFileName, "", 1, 10);
     exec("chmod 666 " + srcFileName, "", 1, 10);
   } catch (Exception e) {
     UtilSrv.se("Can't save submission.", e);
   }
 }
Пример #2
0
 public boolean compile(String sol) throws ServerException {
   try {
     createSrcFile();
     File f = new File(workDir, srcFileName);
     FileWriter fw = new FileWriter(f);
     fw.write(sol);
     fw.close();
     exec(compileCmd, "", 2, 2048);
     File ef = new File(workDir, executableName);
     return ef.exists();
   } catch (Exception e) {
     throw UtilSrv.se("Can't compile.", e);
   }
 }
Пример #3
0
 public void prepare(String pb, String validatorCmd, Language lang) throws ServerException {
   try {
     validator =
         validatorCmd.equals("builtin")
             ? new BuiltinValidator()
             : new CommandValidator(validatorCmd);
     srcFileName = lang.saveName.replaceAll("PB", pb);
     compileCmd = lang.compileCmd.replaceAll("PB", pb);
     executableName = lang.executable.replaceAll("PB", pb);
     runCmd = lang.runCmd.replaceAll("PB", pb);
     exec("rm -rf *", "", 1, 10);
   } catch (Exception e) {
     UtilSrv.se("Can't cleanup for testing.", e);
   }
 }