当前位置: 首页>>代码示例>>PHP>>正文


PHP Problem::setMemoryLimit方法代码示例

本文整理汇总了PHP中Problem::setMemoryLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP Problem::setMemoryLimit方法的具体用法?PHP Problem::setMemoryLimit怎么用?PHP Problem::setMemoryLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Problem的用法示例。


在下文中一共展示了Problem::setMemoryLimit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showProblem

 private function showProblem($id, $ignore_git = FALSE)
 {
     try {
         $problem = new Problem($id);
         if ($problem->exists()) {
             throw new fValidationException("Problem {$id} already exists.");
         }
     } catch (fNotFoundException $e) {
         // fall through
     }
     $data_base_dir = Variable::getString('data-base-path');
     if (!is_dir($data_base_dir)) {
         throw new fValidationException("Data base directory {$data_base_dir} does not exist.");
     }
     if (!$ignore_git) {
         $this->gitPullOriginMaster();
     }
     $problem_dir = "{$data_base_dir}/problems/{$id}";
     if (!is_dir($problem_dir)) {
         throw new fValidationException("Problem directory {$problem_dir} does not exist.");
     }
     $problem_conf = "{$problem_dir}/problem.conf";
     if (!is_file($problem_conf)) {
         throw new fValidationException("Problem configuration file {$problem_conf} does not exist.");
     }
     $problem_text = "{$problem_dir}/problem.text";
     if (!is_file($problem_text)) {
         throw new fValidationException("Problem description file {$problem_text} does not exist.");
     }
     $data_dir = "{$problem_dir}/data";
     if (!is_dir($data_dir)) {
         throw new fValidationException("Problem {$id} does not have a data directory at {$data_dir}");
     }
     $properties_content = file_get_contents($problem_conf);
     $ini_content = str_replace(': ', ' = ', $properties_content);
     $ini = parse_ini_string($ini_content);
     if (!array_key_exists('title', $ini) or empty($ini['title'])) {
         throw new fValidationException('Problem title is not specified in problem.conf');
     }
     if (!array_key_exists('author', $ini)) {
         throw new fValidationException('Problem author is not specified in problem.conf');
     }
     if (!array_key_exists('case_count', $ini) or empty($ini['case_count'])) {
         throw new fValidationException('Problem case count is not specified in problem.conf');
     }
     if (!array_key_exists('case_score', $ini) or empty($ini['case_score'])) {
         throw new fValidationException('Problem case score is not specified in problem.conf');
     }
     if (!array_key_exists('time_limit', $ini) or empty($ini['time_limit'])) {
         throw new fValidationException('Problem time limit is not specified in problem.conf');
     }
     if (!array_key_exists('memory_limit', $ini) or empty($ini['memory_limit'])) {
         throw new fValidationException('Problem memory limit is not specified in problem.conf');
     }
     if (!array_key_exists('secret_before', $ini) or empty($ini['secret_before'])) {
         throw new fValidationException('Problem secret-before time is not specified in problem.conf');
     }
     if (empty($ini['author'])) {
         $ini['author'] = '-';
     }
     $problem = new Problem();
     $problem->setId($id);
     $problem->setTitle($ini['title']);
     $problem->setDescription(file_get_contents($problem_text));
     $problem->setAuthor($ini['author']);
     $problem->setCaseCount($ini['case_count']);
     $problem->setCaseScore($ini['case_score']);
     $problem->setTimeLimit($ini['time_limit']);
     $problem->setMemoryLimit($ini['memory_limit']);
     $problem->setSecretBefore($ini['secret_before']);
     $problem->validate();
     for ($t = 1; $t <= $problem->getCaseCount(); $t++) {
         $input = "{$data_dir}/{$t}.in";
         if (!is_file($input)) {
             throw new fValidationException("Case input file {$input} is not found in {$data_dir}");
         }
         $output = "{$data_dir}/{$t}.out";
         if (!is_file($output)) {
             throw new fValidationException("Case output file {$output} is not found in {$data_dir}");
         }
     }
     $problem->store();
 }
开发者ID:daerduoCarey,项目名称:oj,代码行数:83,代码来源:DashboardController.php


注:本文中的Problem::setMemoryLimit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。