本文整理汇总了PHP中symlink函数的典型用法代码示例。如果您正苦于以下问题:PHP symlink函数的具体用法?PHP symlink怎么用?PHP symlink使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了symlink函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: postInstall
public static function postInstall(Event $event)
{
// Check if a config.json file exists, copy the config.dist.json if not
if (!file_exists('App/Config/config.json')) {
copy('App/Config/config.dist.json', 'App/Config/config.json');
}
// Make sure the assets directory exists
if (!is_dir('www/assets')) {
mkdir('www/assets', 0755);
}
// Symlink img
$bsImagePath = '../../vendor/twbs/bootstrap/docs/assets/img';
$imgAssetsPath = 'www/assets/img';
if (!file_exists($imgAssetsPath)) {
symlink($bsImagePath, $imgAssetsPath);
}
// Symlink js
$bsJSPath = '../../vendor/twbs/bootstrap/docs/assets/js';
$jsAssetsPath = 'www/assets/js';
if (!file_exists($jsAssetsPath)) {
symlink($bsJSPath, $jsAssetsPath);
}
// Symlink css
$bsCSSPath = '../../vendor/twbs/bootstrap/docs/assets/css';
$cssAssetsPath = 'www/assets/css';
if (!file_exists($cssAssetsPath)) {
symlink($bsCSSPath, $cssAssetsPath);
}
}
开发者ID:KBO-Techo-Dev,项目名称:MagazinePro-jfw,代码行数:29,代码来源:InstallScript.php
示例17: copyr
/**
* Recursively copies from one directory to another
*
* @access public
* @param string
* @param string
* @return array
*/
function copyr($source, $dest)
{
// Simple copy for a file
if (is_file($source)) {
return copy($source, $dest);
}
// Make destination directory
if (!is_dir($dest)) {
mkdir($dest);
}
// If the source is a symlink
if (is_link($source)) {
$link_dest = readlink($source);
return symlink($link_dest, $dest);
}
// Loop through the folder
$dir = dir($source);
if (!is_object($dir)) {
return FALSE;
}
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry == '.' or $entry == '..') {
continue;
}
// Deep copy directories
if ($dest !== "{$source}/{$entry}") {
copyr("{$source}/{$entry}", "{$dest}/{$entry}");
}
}
// Clean up
$dir->close();
return true;
}
开发者ID:kbjohnson90,项目名称:FUEL-CMS,代码行数:42,代码来源:MY_directory_helper.php
示例18: copy
/**
* Copy all folders and files in given path to another location.
* @param string $source Directory to copy.
* @param string $dest Directory to copy $source to.
* @param bool $recursive Should it be created recursively.
* @return bool true if successfull, otherwise false.
*/
public static function copy($source, $dest, $recursive = false)
{
// Check for symlinks
if (is_link($source)) {
return symlink(readlink($source), $dest);
}
// Simple copy for a file
if (is_file($source)) {
return @copy($source, $dest);
}
// It's a directoy, should we recurse?
if (false === $recursive) {
return false;
}
// Make destination directory
if (false === is_dir($dest)) {
mkdir($dest);
}
// Loop through the folder
if ($dir = @dir($source)) {
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep copy directories
$this->copy($source . DIRECTORY_SEPARATOR . $entry, $dest . DIRECTORY_SEPARATOR . $entry);
}
// Clean up
$dir->close();
return true;
}
return false;
}
开发者ID:nojacko,项目名称:twuddle-core,代码行数:41,代码来源:IO.php
示例19: symlink_force
function symlink_force($source, $dest)
{
if (file_exists($dest)) {
unlink($dest);
}
symlink($source, $dest);
}
开发者ID:thawkins,项目名称:torrentwatch-x,代码行数:7,代码来源:rss_dl_utils.php
示例20: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->setupBuildDir($output);
$modules = $this->getModulesToProcess($input);
$manager = $this->neptune['assets'];
foreach ($modules as $name => $module) {
$output->writeln('');
$config = $this->neptune['config'];
if (!($command = $config->get("{$name}.assets.build_cmd", false))) {
$output->writeln("Skipping <info>{$name}</info>");
continue;
}
$output->writeln("Building <info>{$name}</info>");
$dir = $module->getDirectory();
passthru("cd {$dir} && {$command}");
//move built assets into public dir
$build_dir = $dir . 'assets_built/';
if (!file_exists($build_dir)) {
throw new \Exception(sprintf('Assets build command for "%s" must create directory "%s"', $name, $build_dir));
}
$public_dir = $this->neptune->getRootDirectory() . 'public/assets/';
$group_dir = $public_dir . $name;
if (file_exists($group_dir)) {
unlink($group_dir);
}
symlink($build_dir, $group_dir);
$output->writeln(sprintf('Linking %s to %s', $build_dir, $group_dir));
//generate concatenated asset files
$manager->concatenateAssets($name, $public_dir);
$output->writeln('Creating concatenated group files');
}
$output->writeln('');
$output->writeln(sprintf('Built assets to <info>%s</info>', $this->build_dir));
}
开发者ID:glynnforrest,项目名称:neptune,代码行数:34,代码来源:AssetsBuildCommand.php
注:本文中的symlink函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论