當前位置: 首頁>>代碼示例>>PHP>>正文


PHP symlink函數代碼示例

本文整理匯總了PHP中symlink函數的典型用法代碼示例。如果您正苦於以下問題:PHP symlink函數的具體用法?PHP symlink怎麽用?PHP symlink使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了symlink函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setupBeforeClass

    public static function setupBeforeClass()
    {
        static::$root = sys_get_temp_dir() . '/insulin';
        static::$files = array(static::$root . '/modules/', static::$root . '/sugar/', static::$root . '/sugar/custom/', static::$root . '/sugar/include/', static::$root . '/sugar/include/entryPoint.php', static::$root . '/sugar/include/MVC/', static::$root . '/sugar/include/MVC/SugarApplication.php', static::$root . '/sugar/config.php', static::$root . '/sugar/sugar_version.php');
        static::$links = array(static::$root . '/modules' => static::$root . '/sugar/modules', static::$root . '/sugar/custom' => static::$root . '/custom');
        if (is_dir(static::$root)) {
            static::tearDownAfterClass();
        } else {
            mkdir(static::$root);
        }
        foreach (static::$files as $file) {
            if ('/' === substr($file, -1) && !is_dir($file)) {
                mkdir($file);
            } else {
                touch($file);
            }
        }
        foreach (static::$links as $target => $link) {
            symlink($target, $link);
        }
        file_put_contents(static::$root . '/sugar/sugar_version.php', '<?php
$sugar_version      = \'6.5.3\';
$sugar_db_version   = \'6.5.3\';
$sugar_flavor       = \'ENT\';
$sugar_build        = \'123\';
$sugar_timestamp    = \'2008-08-01 12:00am\';
');
    }
開發者ID:insulin,項目名稱:cli,代碼行數:28,代碼來源:FinderTest.php

示例2: cp_r

 /**
  * Recursive copy function
  * @param str src source path
  * @param str dst source path
  * @return bool
  */
 public static function cp_r($src, $dst)
 {
     if (is_link($src)) {
         $l = readlink($src);
         if (!symlink($l, $dst)) {
             return false;
         }
     } elseif (is_dir($src)) {
         if (!mkdir($dst)) {
             return false;
         }
         $objects = scandir($src);
         if ($objects === false) {
             return false;
         }
         foreach ($objects as $file) {
             if ($file == "." || $file == "..") {
                 continue;
             }
             if (!self::cp_r($src . DIRECTORY_SEPARATOR . $file, $dst . DIRECTORY_SEPARATOR . $file)) {
                 return false;
             }
         }
     } else {
         if (!copy($src, $dst)) {
             return false;
         }
     }
     return true;
 }
開發者ID:DWWf,項目名稱:pocketmine-plugins,代碼行數:36,代碼來源:FileUtils.php

示例3: up

 public function up()
 {
     $old = umask(0);
     mkdir(Config::get('upload_dir'), 0777);
     umask($old);
     symlink(Config::get('upload_dir'), Config::get('public_dir') . '/upload');
 }
開發者ID:utumdol,項目名稱:codeseed,代碼行數:7,代碼來源:create_upload_directory.class.php

示例4: processDocument

 /**
  * Process document and write the result in the document cache.
  *
  * When the original document is required, create either a symbolic link with the
  * original document in the cache dir, or copy it in the cache dir if it's not already done.
  *
  * This method updates the cache_file_path and file_url attributes of the event
  *
  * @param DocumentEvent $event Event
  *
  * @throws \Thelia\Exception\DocumentException
  * @throws \InvalidArgumentException           , DocumentException
  */
 public function processDocument(DocumentEvent $event)
 {
     $subdir = $event->getCacheSubdirectory();
     $sourceFile = $event->getSourceFilepath();
     if (null == $subdir || null == $sourceFile) {
         throw new \InvalidArgumentException("Cache sub-directory and source file path cannot be null");
     }
     $originalDocumentPathInCache = $this->getCacheFilePath($subdir, $sourceFile, true);
     if (!file_exists($originalDocumentPathInCache)) {
         if (!file_exists($sourceFile)) {
             throw new DocumentException(sprintf("Source document file %s does not exists.", $sourceFile));
         }
         $mode = ConfigQuery::read('original_document_delivery_mode', 'symlink');
         if ($mode == 'symlink') {
             if (false == symlink($sourceFile, $originalDocumentPathInCache)) {
                 throw new DocumentException(sprintf("Failed to create symbolic link for %s in %s document cache directory", basename($sourceFile), $subdir));
             }
         } else {
             // mode = 'copy'
             if (false == @copy($sourceFile, $originalDocumentPathInCache)) {
                 throw new DocumentException(sprintf("Failed to copy %s in %s document cache directory", basename($sourceFile), $subdir));
             }
         }
     }
     // Compute the document URL
     $documentUrl = $this->getCacheFileURL($subdir, basename($originalDocumentPathInCache));
     // Update the event with file path and file URL
     $event->setDocumentPath($documentUrl);
     $event->setDocumentUrl(URL::getInstance()->absoluteUrl($documentUrl, null, URL::PATH_TO_FILE));
 }
開發者ID:alex63530,項目名稱:thelia,代碼行數:43,代碼來源:Document.php

示例5: makeSymlink

 protected function makeSymlink($target, $link)
 {
     if (!@symlink($target, $link)) {
         $error = error_get_last();
         throw new ErrorException(sprintf("%s: %s -> %s\n", $error['message'], $link, $target));
     }
 }
開發者ID:syokunin,項目名稱:ZipArchiveEx,代碼行數:7,代碼來源:SymlinkerUnix.php

示例6: generatePhpbbLink

 public function generatePhpbbLink($varValue, DataContainer $dc)
 {
     if (is_link($dc->activeRecord->phpbb_alias) && readlink($dc->activeRecord->phpbb_alias) == $varValue) {
         Message::addInfo("Path to forum already set");
         return $varValue;
     }
     if (is_link($dc->activeRecord->phpbb_alias) !== false && readlink($dc->activeRecord->phpbb_alias) != $varValue) {
         Message::addInfo("Removing old link");
         unlink($dc->activeRecord->phpbb_alias);
     }
     Message::addInfo("Trying to set Forum Symlink");
     if (file_exists($varValue . "/viewtopic.php")) {
         Message::addInfo("Forum found. Setting Link");
         $result = symlink($varValue, $dc->activeRecord->phpbb_alias);
         if ($result === true) {
             Message::addInfo("Link Set");
         }
         if (!is_link($dc->activeRecord->phpbb_alias . '/ext/ctsmedia') || readlink($dc->activeRecord->phpbb_alias . '/ext/ctsmedia') != "../../contao/vendor/ctsmedia/contao-phpbb-bridge-bundle/src/Resources/phpBB/ctsmedia") {
             Message::addInfo("Setting Vendor Link");
             symlink(TL_ROOT . "/vendor/ctsmedia/contao-phpbb-bridge-bundle/src/Resources/phpBB/ctsmedia", $dc->activeRecord->phpbb_alias . '/ext/ctsmedia');
         }
         Message::addInfo("Please activate the contao extension in the phpbb backend");
     } else {
         //Message::addError("Forum could not be found: ".$varValue . "/viewtopic.php");
         throw new Exception("Forum could not be found: " . $varValue . "/viewtopic.php");
     }
     return $varValue;
 }
開發者ID:ctsmedia,項目名稱:contao-phpbb-bridge-bundle,代碼行數:28,代碼來源:tl_page.php

示例7: publishAction

 /**
  * 發布素材到開放的目錄
  */
 public function publishAction()
 {
     $cli = $this->cli;
     $plugins = $this->plugin->getAll();
     foreach ($plugins as $plugin) {
         $path = $plugin->getBasePath();
         // TODO V2 隻處理vendor下的插件,直到遷移完畢
         if (strpos($path, 'vendor/') !== 0) {
             continue;
         }
         $source = $path . '/public';
         if (!is_dir($source)) {
             continue;
         }
         $id = $plugin->getId();
         $target = 'plugins/' . $id;
         if (is_dir($target)) {
             $this->writeln(sprintf('Remove %s', $cli->success($target)));
             $this->remove($target);
         }
         $source = '../' . $source;
         $this->writeln(sprintf('Symlink %s to %s', $cli->success($source), $cli->success($target)));
         symlink($source, $target);
     }
 }
開發者ID:miaoxing,項目名稱:plugin,代碼行數:28,代碼來源:Assets.php

示例8: main

 function main($source, $dest, $nested = 1)
 {
     // Check for symlinks
     if (is_link($source)) {
         return symlink(readlink($source), $dest);
     }
     // notify user
     $this->notify($source, $dest, $nested);
     // Simple copy for a file
     if (is_file($source)) {
         return copy($source, $dest);
     }
     // Make destination directory
     if (!is_dir($dest)) {
         mkdir($dest);
     }
     // Loop through the folder
     $dir = dir($source);
     while (false !== ($entry = $dir->read())) {
         // Skip pointers
         if (substr($entry, 0, 1) == '.' || $entry == '.' || $entry == '..') {
             continue;
         }
         // Deep copy directories
         $this->main("{$source}/{$entry}", "{$dest}/{$entry}", $nested + 1);
     }
     // Clean up
     $dir->close();
     return true;
 }
開發者ID:naz-ahmed,項目名稱:ndap-magento-mirror,代碼行數:30,代碼來源:RecursiveCopy.php

示例9: copyRecursive

 /**
  * Copies assets recursively
  *
  * @param $source
  * @param $dest
  * @param int $permissions
  * @return bool
  * @internal
  */
 private function copyRecursive($source, $dest, $permissions = 0755)
 {
     // Check for symlinks
     if (is_link($source)) {
         return symlink(readlink($source), $dest);
     }
     // Simple copy for a file
     if (is_file($source)) {
         if (is_file($dest)) {
             $this->putWarning("Cannot copy {$source}. File already exists.");
             return false;
         } else {
             return copy($source, $dest);
         }
     }
     // Make destination directory
     if (!is_dir($dest)) {
         mkdir($dest, $permissions);
     }
     // Loop through the folder
     $dir = dir($source);
     while (false !== ($entry = $dir->read())) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         // Deep copy directories
         $this->copyRecursive("{$source}/{$entry}", "{$dest}/{$entry}");
     }
     // Clean up
     $dir->close();
     return true;
 }
開發者ID:arius86,項目名稱:core,代碼行數:42,代碼來源:AssetsTask.php

示例10: main

 /**
  * The method that runs the task
  *
  * @return void
  */
 public function main()
 {
     parent::main();
     // Do we need to create directories?
     if (isset($this->map['mkdir'])) {
         foreach ($this->map['mkdir'] as $dir) {
             $path = realpath($this->destinationBasePath . '/' . $dir);
             if (file_exists($path)) {
                 $this->remove($path);
             }
             $path = $this->destinationBasePath . '/' . $dir;
             $this->log('Creating directory: ' . $path);
             mkdir($path);
         }
     }
     foreach ($this->map['symlinks'] as $item) {
         $item = explode(' ', $item);
         $source = $item[0];
         $destination = $item[1];
         // Normalise paths
         $source = realpath($this->sourceBasePath . '/' . $source);
         $destination = rtrim($this->destinationBasePath, '/') . '/' . $destination;
         if (!file_exists($source)) {
             throw new Exception("Symlink target not found: " . $this->sourceBasePath . '/' . $source, 1);
         }
         // Check if the destination exists and remove it
         if (file_exists($destination)) {
             $destination = rtrim($destination, '/');
             $this->remove($destination);
         }
         // Create the new symlink
         $this->log('Creating Symlink: ' . $destination);
         symlink($source, $destination);
     }
 }
開發者ID:OSTraining,項目名稱:AllediaBuilder,代碼行數:40,代碼來源:CreateSymlinksFromFileTask.php

示例11: recursiveCopy

 /**
  * Copy a directory recursively and optionally use a extension whitelist
  *
  * @param string $source
  * @param string $dest
  * @param array $allowedExtensions
  * @return bool|null
  */
 protected function recursiveCopy($source, $dest, $allowedExtensions = [])
 {
     // Check for symlinks
     if (is_link($source)) {
         return symlink(readlink($source), $dest);
     }
     // Simple copy for a file
     if (is_file($source)) {
         // Filter files not matching the extension whitelist
         if (!empty($allowedExtensions) and !in_array(pathinfo($source, PATHINFO_EXTENSION), $allowedExtensions)) {
             return null;
         }
         return copy($source, $dest);
     }
     // Make destination directory
     if (!is_dir($dest)) {
         mkdir($dest);
     }
     // Loop through the folder
     $dir = dir($source);
     while (false !== ($entry = $dir->read())) {
         // Skip pointers
         if ($entry == '.' || $entry == '..') {
             continue;
         }
         // Deep copy directories
         $this->recursiveCopy("{$source}/{$entry}", "{$dest}/{$entry}", $allowedExtensions);
     }
     // Clean up
     $dir->close();
     return true;
 }
開發者ID:hettiger,項目名稱:larawire,代碼行數:40,代碼來源:InstallCommand.php

示例12: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     if ('\\' === DIRECTORY_SEPARATOR) {
         self::$linkOnWindows = true;
         $originFile = tempnam(sys_get_temp_dir(), 'li');
         $targetFile = tempnam(sys_get_temp_dir(), 'li');
         if (true !== @link($originFile, $targetFile)) {
             $report = error_get_last();
             if (is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
                 self::$linkOnWindows = false;
             }
         } else {
             @unlink($targetFile);
         }
         self::$symlinkOnWindows = true;
         $originDir = tempnam(sys_get_temp_dir(), 'sl');
         $targetDir = tempnam(sys_get_temp_dir(), 'sl');
         if (true !== @symlink($originDir, $targetDir)) {
             $report = error_get_last();
             if (is_array($report) && false !== strpos($report['message'], 'error code(1314)')) {
                 self::$symlinkOnWindows = false;
             }
         } else {
             @unlink($targetDir);
         }
     }
 }
開發者ID:Gladhon,項目名稱:symfony,代碼行數:27,代碼來源:FilesystemTestCase.php

示例13: symlink

 public static function symlink()
 {
     /* WP FileSystem API does not support symlink creation
        global $wp_filesystem;
        */
     $muplugin = dirname(WPF2B_PATH) . self::$muplugin_rel;
     $symlink = WPMU_PLUGIN_DIR . self::$symlink_rel;
     if (!file_exists(WPMU_PLUGIN_DIR)) {
         if (!mkdir(WPMU_PLUGIN_DIR, 0755, true)) {
             return false;
         }
     }
     if (is_link($symlink) || file_exists($symlink)) {
         // Correct symbolic link
         if (is_link($symlink) && readlink($symlink) === $muplugin) {
             return true;
         } else {
             /* is_writable() does not detect broken symlinks, unlink() must be @muted
                // Incorrect and unwritable
                if ( ! is_writable( $symlink ) ) {
                    return false;
                }
                */
             // Remove symbolic link
             if (!@unlink($symlink)) {
                 return false;
             }
         }
     }
     $linking = symlink($muplugin, $symlink);
     return $linking;
 }
開發者ID:vrkansagara,項目名稱:wordpress-plugin-construction,代碼行數:32,代碼來源:ban.php

示例14: create

 /**
  * Create symlinks from each plugin to app/webroot
  *
  * @return void
  */
 public function create()
 {
     chdir(realpath(WWW_ROOT));
     $paths = $this->_getPaths();
     foreach ($paths as $plugin => $config) {
         $this->out('Processing plugin: <info>' . $plugin . '</info>');
         if (file_exists($config['public'])) {
             $this->out(sprintf('--> <warning>Path "%s" already exists</warning>', \Nodes\Common::stripRealPaths($config['public'])));
             if (is_link($config['public'])) {
                 $symlinkTarget = readlink($config['public']);
                 $this->out('----> Path is already symlink. (' . $symlinkTarget . ')');
                 if (realpath($config['relative_private']) === realpath($symlinkTarget)) {
                     $this->out('----> <info>Skipping</info>, Already configured correctly');
                     continue;
                 }
                 $this->out('--> <error>Target is already symlink, but does not have same source</error>');
                 continue;
             } elseif (is_file($config['public'])) {
                 $this->out('----> Skipping, target is a file');
                 continue;
             } else {
                 $this->out('----> <error>Skipping, don\'t know how to process file</error>');
                 continue;
             }
         }
         if (symlink($config['relative_private'], $config['relative_public'])) {
             $this->out(sprintf('--> <info>OK</info>, symlink created (%s => %s)', \Nodes\Common::stripRealPaths($config['private']), \Nodes\Common::stripRealPaths($config['public'])));
         } else {
             $this->out('--> <error>Error</error> Could not create symlink');
         }
     }
 }
開發者ID:nodesagency,項目名稱:Platform-Common-Plugin,代碼行數:37,代碼來源:SymlinkAssetsShell.php

示例15: init

 public function init()
 {
     parent::init();
     $extJsSrcDir = Yii::getAlias($this->extJsDir);
     $extJsSrcExtendDir = Yii::getAlias($this->extJsExtendDir);
     $dstDir = Yii::getAlias($this->dstPath);
     $extJsDstDir = $dstDir . DIRECTORY_SEPARATOR . 'extjs';
     $extJsExtendDstDir = $dstDir . DIRECTORY_SEPARATOR . 'extjs-extend';
     if (!is_dir($dstDir)) {
         if (!is_dir($dstDir)) {
             FileHelper::createDirectory($dstDir);
         }
     }
     if (!is_dir($extJsDstDir)) {
         symlink($extJsSrcDir, $extJsDstDir);
     }
     if (!is_dir($extJsExtendDstDir)) {
         symlink($extJsSrcExtendDir, $extJsExtendDstDir);
     }
     $data = DpConfig::find()->all();
     $config = [];
     foreach ($data as $item) {
         $config[$item['name']] = $item['value'];
     }
     $this->config = $config;
     $this->identity = Yii::$app->user->identity;
 }
開發者ID:phpsong,項目名稱:yii2-extjs-rbac,代碼行數:27,代碼來源:Controller.php


注:本文中的symlink函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。