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


PHP make_writable_directory函数代码示例

本文整理汇总了PHP中make_writable_directory函数的典型用法代码示例。如果您正苦于以下问题:PHP make_writable_directory函数的具体用法?PHP make_writable_directory怎么用?PHP make_writable_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: get_tool_dir

 /**
  * Create generator_dir where all feature and context will be saved.
  *
  * @return string
  * @throws \coding_exception
  * @throws \invalid_dataroot_permissions
  */
 public static function get_tool_dir()
 {
     $dir = self::get_performance_dir() . DIRECTORY_SEPARATOR . 'sitegenerator';
     // Create dir if required.
     if (!is_dir($dir)) {
         make_writable_directory($dir, true);
     }
     return $dir;
 }
开发者ID:rajeshtaneja,项目名称:moodle-behat-generator,代码行数:16,代码来源:util.php

示例2: get_performance_dir

 /**
  * Return directory in which performance data is saved.
  *
  * @static
  * @param bool $create if ture then it will also create directory if not present.
  * @return string
  */
 public static function get_performance_dir($create = false)
 {
     $datapath = self::get_data_path();
     // Create dir if required.
     if ($create && !is_dir($datapath)) {
         make_writable_directory($datapath, true);
     }
     if (!is_writeable($datapath)) {
         self::performance_exception("Data directory is not writable.");
     }
     return $datapath;
 }
开发者ID:rajeshtaneja,项目名称:moodle-behat-generator,代码行数:19,代码来源:toolkit_util.php

示例3: get_performance_dir

 /**
  * Return directory in which performance data is saved.
  *
  * @static
  * @param bool $create if ture then it will also create directory if not present.
  * @return string
  */
 public static function get_performance_dir($create = false)
 {
     global $CFG;
     if (empty($CFG->performance_dataroot)) {
         self::performance_exception("\$CFG->performance_dataroot is not set.");
     }
     $dir = $CFG->performance_dataroot;
     // Create dir if required.
     if ($create && !is_dir($dir)) {
         make_writable_directory($dir, true);
     }
     return $dir;
 }
开发者ID:rajeshtaneja,项目名称:moodle-performance-tool,代码行数:20,代码来源:toolkit_util.php

示例4: config_save

 /**
  * Saves the current configuration.
  */
 protected function config_save()
 {
     global $CFG;
     $cachefile = self::get_config_file_path();
     $directory = dirname($cachefile);
     if ($directory !== $CFG->dataroot && !file_exists($directory)) {
         $result = make_writable_directory($directory, false);
         if (!$result) {
             throw new cache_exception('ex_configcannotsave', 'cache', '', null, 'Cannot create config directory.');
         }
     }
     if (!file_exists($directory) || !is_writable($directory)) {
         throw new cache_exception('ex_configcannotsave', 'cache', '', null, 'Config directory is not writable.');
     }
     // Prepare a configuration array to store.
     $configuration = array();
     $configuration['stores'] = $this->configstores;
     $configuration['modemappings'] = $this->configmodemappings;
     $configuration['definitions'] = $this->configdefinitions;
     $configuration['definitionmappings'] = $this->configdefinitionmappings;
     $configuration['locks'] = $this->configlocks;
     // Prepare the file content.
     $content = "<?php defined('MOODLE_INTERNAL') || die();\n \$configuration = " . var_export($configuration, true) . ";";
     // We need to create a temporary cache lock instance for use here. Remember we are generating the config file
     // it doesn't exist and thus we can't use the normal API for this (it'll just try to use config).
     $lockconf = reset($this->configlocks);
     if ($lockconf === false) {
         debugging('Your cache configuration file is out of date and needs to be refreshed.', DEBUG_DEVELOPER);
         // Use the default
         $lockconf = array('name' => 'cachelock_file_default', 'type' => 'cachelock_file', 'dir' => 'filelocks', 'default' => true);
     }
     $factory = cache_factory::instance();
     $locking = $factory->create_lock_instance($lockconf);
     if ($locking->lock('configwrite', 'config', true)) {
         // Its safe to use w mode here because we have already acquired the lock.
         $handle = fopen($cachefile, 'w');
         fwrite($handle, $content);
         fflush($handle);
         fclose($handle);
         $locking->unlock('configwrite', 'config');
     } else {
         throw new cache_exception('ex_configcannotsave', 'cache', '', null, 'Unable to open the cache config file.');
     }
 }
开发者ID:numbas,项目名称:moodle,代码行数:47,代码来源:locallib.php

示例5: init

 /**
  * Init session handler.
  */
 public function init()
 {
     if (preg_match('/^[0-9]+;/', $this->sessiondir)) {
         throw new exception('sessionhandlerproblem', 'error', '', null, 'Multilevel session directories are not supported');
     }
     // Make sure session directory exists and is writable.
     make_writable_directory($this->sessiondir, false);
     if (!is_writable($this->sessiondir)) {
         throw new exception('sessionhandlerproblem', 'error', '', null, 'Session directory is not writable');
     }
     // Need to disable debugging since disk_free_space()
     // will fail on very large partitions (see MDL-19222).
     $freespace = @disk_free_space($this->sessiondir);
     if (!($freespace > 2048) and $freespace !== false) {
         throw new exception('sessiondiskfull', 'error');
     }
     // NOTE: we cannot set any lock acquiring timeout here - bad luck.
     ini_set('session.save_handler', 'files');
     ini_set('session.save_path', $this->sessiondir);
 }
开发者ID:eamador,项目名称:moodle-course-custom-fields,代码行数:23,代码来源:file.php

示例6: ensure_path_exists

 /**
  * Checks to make sure that the path for the file cache exists.
  *
  * @return bool
  * @throws coding_exception
  */
 protected function ensure_path_exists()
 {
     if (!is_writable($this->path)) {
         if ($this->custompath && !$this->autocreate) {
             throw new coding_exception('File store path does not exist. It must exist and be writable by the web server.');
         }
         if (!make_writable_directory($this->path, false)) {
             throw new coding_exception('File store path does not exist and can not be created.');
         }
     }
     return true;
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:18,代码来源:lib.php

示例7: ensure_path_exists

 /**
  * Checks to make sure that the path for the file cache exists.
  *
  * @return bool
  * @throws coding_exception
  */
 protected function ensure_path_exists()
 {
     global $CFG;
     if (!is_writable($this->path)) {
         if ($this->custompath && !$this->autocreate) {
             throw new coding_exception('File store path does not exist. It must exist and be writable by the web server.');
         }
         $createdcfg = false;
         if (!isset($CFG)) {
             // This can only happen during destruction of objects.
             // A cache is being used within a destructor, php is ending a request and $CFG has
             // already being cleaned up.
             // Rebuild $CFG with directory permissions just to complete this write.
             $CFG = $this->cfg;
             $createdcfg = true;
         }
         if (!make_writable_directory($this->path, false)) {
             throw new coding_exception('File store path does not exist and can not be created.');
         }
         if ($createdcfg) {
             // We re-created it so we'll clean it up.
             unset($CFG);
         }
     }
     return true;
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:32,代码来源:lib.php

示例8: test_distributed_application_event_invalidation

 /**
  * Tests application cache event invalidation over a distributed setup.
  */
 public function test_distributed_application_event_invalidation()
 {
     global $CFG;
     // This is going to be an intense wee test.
     // We need to add data the to cache, invalidate it by event, manually force it back without MUC knowing to simulate a
     // disconnected/distributed setup (think load balanced server using local cache), instantiate the cache again and finally
     // check that it is not picked up.
     $instance = cache_config_phpunittest::instance();
     $instance->phpunit_add_definition('phpunit/eventinvalidationtest', array('mode' => cache_store::MODE_APPLICATION, 'component' => 'phpunit', 'area' => 'eventinvalidationtest', 'simplekeys' => true, 'simpledata' => true, 'invalidationevents' => array('crazyevent')));
     $cache = cache::make('phpunit', 'eventinvalidationtest');
     $this->assertTrue($cache->set('testkey1', 'test data 1'));
     $this->assertEquals('test data 1', $cache->get('testkey1'));
     cache_helper::invalidate_by_event('crazyevent', array('testkey1'));
     $this->assertFalse($cache->get('testkey1'));
     // OK data added, data invalidated, and invalidation time has been set.
     // Now we need to manually add back the data and adjust the invalidation time.
     $hash = md5(cache_store::MODE_APPLICATION . '/phpunit/eventinvalidationtest/' . $CFG->wwwroot . 'phpunit');
     $timefile = $CFG->dataroot . "/cache/cachestore_file/default_application/phpunit_eventinvalidationtest/las/lastinvalidation-{$hash}.cache";
     // Make sure the file is correct.
     $this->assertTrue(file_exists($timefile));
     $timecont = serialize(cache::now() - 60);
     // Back 60sec in the past to force it to re-invalidate.
     make_writable_directory(dirname($timefile));
     file_put_contents($timefile, $timecont);
     $this->assertTrue(file_exists($timefile));
     $datafile = $CFG->dataroot . "/cache/cachestore_file/default_application/phpunit_eventinvalidationtest/tes/testkey1-{$hash}.cache";
     $datacont = serialize("test data 1");
     make_writable_directory(dirname($datafile));
     file_put_contents($datafile, $datacont);
     $this->assertTrue(file_exists($datafile));
     // Test 1: Rebuild without the event and test its there.
     cache_factory::reset();
     $instance = cache_config_phpunittest::instance();
     $instance->phpunit_add_definition('phpunit/eventinvalidationtest', array('mode' => cache_store::MODE_APPLICATION, 'component' => 'phpunit', 'area' => 'eventinvalidationtest', 'simplekeys' => true, 'simpledata' => true));
     $cache = cache::make('phpunit', 'eventinvalidationtest');
     $this->assertEquals('test data 1', $cache->get('testkey1'));
     // Test 2: Rebuild and test the invalidation of the event via the invalidation cache.
     cache_factory::reset();
     $instance = cache_config_phpunittest::instance();
     $instance->phpunit_add_definition('phpunit/eventinvalidationtest', array('mode' => cache_store::MODE_APPLICATION, 'component' => 'phpunit', 'area' => 'eventinvalidationtest', 'simplekeys' => true, 'simpledata' => true, 'invalidationevents' => array('crazyevent')));
     $cache = cache::make('phpunit', 'eventinvalidationtest');
     $this->assertFalse($cache->get('testkey1'));
 }
开发者ID:Burick,项目名称:moodle,代码行数:46,代码来源:cache_test.php

示例9: test_validate_target_location

 public function test_validate_target_location()
 {
     $fixtures = __DIR__ . '/fixtures/update_validator';
     $validator = testable_core_update_validator::instance($fixtures . '/installed', array('greenbar/' => true, 'greenbar/version.php' => true, 'greenbar/index.php' => true, 'greenbar/lang/' => true, 'greenbar/lang/en/' => true, 'greenbar/lang/en/local_greenbar.php' => true));
     $validator->assert_plugin_type('local');
     $validator->assert_moodle_version('2013031400.00');
     $this->assertTrue($validator->execute());
     $this->assertFalse($this->has_message($validator->get_messages(), $validator::WARNING, 'targetexists', $validator->get_plugintype_location('local') . '/greenbar'));
     $typeroot = $validator->get_plugintype_location('local');
     make_writable_directory($typeroot . '/greenbar');
     $this->assertTrue($validator->execute());
     $this->assertTrue($this->has_message($validator->get_messages(), $validator::WARNING, 'targetexists', $validator->get_plugintype_location('local') . '/greenbar'));
     remove_dir($typeroot . '/greenbar');
     file_put_contents($typeroot . '/greenbar', 'This file occupies a place where a plugin should land.');
     $this->assertFalse($validator->execute());
     $this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'targetnotdir', $validator->get_plugintype_location('local') . '/greenbar'));
     unlink($typeroot . '/greenbar');
     $this->assertTrue($validator->execute());
     $validator = testable_core_update_validator::instance($fixtures . '/plugindir', array('foobar/' => true, 'foobar/version.php' => true, 'foobar/index.php' => true, 'foobar/lang/' => true, 'foobar/lang/en/' => true, 'foobar/lang/en/local_foobar.php' => true));
     $validator->assert_plugin_type('local');
     $validator->assert_moodle_version('2013031400.00');
     $this->assertTrue($validator->execute());
     $this->assertTrue($this->has_message($validator->get_messages(), $validator::INFO, 'pathwritable', $validator->get_plugintype_location('local')));
 }
开发者ID:evltuma,项目名称:moodle,代码行数:24,代码来源:update_validator_test.php

示例10: make_localcache_directory

/**
 * Create a directory under localcachedir and make sure it is writable.
 * The files in this directory MUST NOT change, use revisions or content hashes to
 * work around this limitation - this means you can only add new files here.
 *
 * The content of this directory gets purged automatically on all cluster nodes
 * after calling purge_all_caches() before new data is written to this directory.
 *
 * Note: this local cache directory does not need to be shared by cluster nodes.
 *
 * @param string $directory the relative path of the directory to be created under $CFG->localcachedir
 * @param bool $exceptiononerror throw exception if error encountered
 * @return string|false Returns full path to directory if successful, false if not; may throw exception
 */
function make_localcache_directory($directory, $exceptiononerror = true)
{
    global $CFG;
    make_writable_directory($CFG->localcachedir, $exceptiononerror);
    if ($CFG->localcachedir !== "{$CFG->dataroot}/localcache") {
        protect_directory($CFG->localcachedir);
    } else {
        protect_directory($CFG->dataroot);
    }
    if (!isset($CFG->localcachedirpurged)) {
        $CFG->localcachedirpurged = 0;
    }
    $timestampfile = "{$CFG->localcachedir}/.lastpurged";
    if (!file_exists($timestampfile)) {
        touch($timestampfile);
        @chmod($timestampfile, $CFG->filepermissions);
    } else {
        if (filemtime($timestampfile) < $CFG->localcachedirpurged) {
            // This means our local cached dir was not purged yet.
            remove_dir($CFG->localcachedir, true);
            if ($CFG->localcachedir !== "{$CFG->dataroot}/localcache") {
                protect_directory($CFG->localcachedir);
            }
            touch($timestampfile);
            @chmod($timestampfile, $CFG->filepermissions);
            clearstatcache();
        }
    }
    if ($directory === '') {
        return $CFG->localcachedir;
    }
    return make_writable_directory("{$CFG->localcachedir}/{$directory}", $exceptiononerror);
}
开发者ID:abhilash1994,项目名称:moodle,代码行数:47,代码来源:setuplib.php

示例11: make_cache_directory

/**
 * Create a directory under cachedir and make sure it is writable.
 *
 * @param string $directory  the full path of the directory to be created under $CFG->cachedir
 * @param bool $exceptiononerror throw exception if error encountered
 * @return string|false Returns full path to directory if successful, false if not; may throw exception
 */
function make_cache_directory($directory, $exceptiononerror = true)
{
    global $CFG;
    protect_directory($CFG->cachedir);
    return make_writable_directory("{$CFG->cachedir}/{$directory}", $exceptiononerror);
}
开发者ID:nigeldaley,项目名称:moodle,代码行数:13,代码来源:setuplib.php

示例12: init_temp_directories

 /**
  * Makes sure all temp directories exist and are writable.
  */
 protected function init_temp_directories()
 {
     make_writable_directory($this->temproot . '/distfiles');
     make_writable_directory($this->temproot . '/archive');
 }
开发者ID:evltuma,项目名称:moodle,代码行数:8,代码来源:code_manager.php

示例13: log_to_file

/** ERROR HANDLING **/
function log_to_file($info, $notused = null)
{
    try {
        $logdir = get_config('rcommon', 'data_store_log');
        $tracer = get_config('rcommon', 'tracer');
        if ($tracer == 'checked' && !empty($logdir)) {
            $logdir = make_writable_directory($logdir . '/log_rcommon', false);
            if ($handle = @fopen($logdir . "/LogRcommon.log", "a")) {
                $content = "\r\n" . date("Y-m-d H:i:s") . " - Data: " . $info;
                @fwrite($handle, $content);
                @fclose($handle);
            }
        }
    } catch (Exception $e) {
        return;
    }
}
开发者ID:kevin-bruton,项目名称:marsupial,代码行数:18,代码来源:wslib.php

示例14: get_final_testplan_path

 /**
  * Return path for the final testplan path, where all file related to test plan will be stored.
  *
  * @return string
  */
 public static function get_final_testplan_path()
 {
     $dir = self::get_tool_dir() . DIRECTORY_SEPARATOR . "moodle_testplan";
     // Create directory if not exist.
     if (!is_dir($dir)) {
         make_writable_directory($dir, true);
     }
     return $dir;
 }
开发者ID:rajeshtaneja,项目名称:moodle-performance-toolkit,代码行数:14,代码来源:util.php

示例15: get_dirpath

 /**
  * @return string|bool
  */
 public function get_dirpath()
 {
     global $CFG;
     if ($this->_dirpath === null) {
         $sep = DIRECTORY_SEPARATOR;
         $this->_dirpath = make_writable_directory("{$CFG->dataroot}{$sep}mhaairs", false);
     }
     return $this->_dirpath;
 }
开发者ID:itamart,项目名称:moodle-block_mhaairs,代码行数:12,代码来源:block_mhaairs_util.php


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