• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP lchown函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: chown

 /**
  * Change the owner of an array of files or directories.
  *
  * @param string|array|\Traversable $files     A filename, an array of files, or a \Traversable instance to change owner
  * @param string                    $user      The new owner user name
  * @param bool                      $recursive Whether change the owner recursively or not
  *
  * @throws IOException When the change fail
  */
 public function chown($files, $user, $recursive = false)
 {
     foreach ($this->toIterator($files) as $file) {
         if ($recursive && is_dir($file) && !is_link($file)) {
             $this->chown(new \FilesystemIterator($file), $user, true);
         }
         if (is_link($file) && function_exists('lchown')) {
             if (true !== @lchown($file, $user)) {
                 throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
             }
         } else {
             if (true !== @chown($file, $user)) {
                 throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
             }
         }
     }
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:26,代码来源:Filesystem.php


示例2: chown

 /**
  * {@inheritdoc}
  */
 public function chown($file, $user)
 {
     $file = $this->normalizePath($file);
     return is_link($file) && function_exists('lchown') ? lchown($file, $user) : chown($file, $user);
 }
开发者ID:jacobjjc,项目名称:PageKit-framework,代码行数:8,代码来源:FilesystemAdapter.php


示例3: changeOwner

 /**
  * Change file owner.
  *
  * @access  public
  * @param   mixed   $user   User.
  * @return  bool
  */
 public function changeOwner($user)
 {
     return lchown($this->getStreamName(), $user);
 }
开发者ID:Hywan,项目名称:File,代码行数:11,代码来源:Link.php


示例4: chown

 /**
  * Sets the owner for the fs resource
  *
  * @param mixed $owner
  * @return boolean True if successful
  */
 public function chown($owner)
 {
     if ($this->isLink() && function_exists('lchown')) {
         return @lchown($this->path, $owner);
     } else {
         return @chown($this->path, $owner);
     }
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:14,代码来源:modfilehandler.class.php


示例5: setChown

 /**
  * Change file owner
  * 
  * Change a file owner to filepath
  * 
  * @param string $path Path to the file
  * @param string $user A file owner name or number UID
  * @param bool $recursive Recursive set a group
  * @return bool State of changes
  * @throws \RuntimeException
  */
 public function setChown($path, $user, $recursive = false)
 {
     $state = false;
     if ($recursive) {
         $iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD);
         foreach ($iter as $val) {
             if (is_link($val->getPathName())) {
                 if (!@lchown($path, $user)) {
                     throw new \Exception(sprintf("Can not change file owner for link %s with user %s", $path, $user));
                 }
                 $state = true;
             } else {
                 if ($val->isFile()) {
                     if (!@chown($path, $user)) {
                         throw new \Exception(sprintf("Can not change file owner for file %s with user %s", $path, $user));
                     }
                     $state = true;
                 }
             }
         }
     } else {
         if (is_link($path)) {
             if (!lchown($path, $user)) {
                 throw new Exception(sprintf("Can not change file owner for link %s with user %s", $path, $user));
             }
             $state = true;
         } else {
             if (is_file($path)) {
                 if (!chown($path, $user)) {
                     throw new Exception(sprintf("Can not change file owner for file %s with user %s", $path, $user));
                 }
                 $state = true;
             }
         }
     }
     return $state;
 }
开发者ID:ionitium,项目名称:filesystem,代码行数:48,代码来源:Filesystem.php


示例6: var_dump

var_dump(is_writable($path1));
var_dump(is_writeable($path1));
var_dump(is_readable($path1));
var_dump(is_executable($path1));
var_dump(is_file($path1));
var_dump(is_dir($path1));
var_dump(is_link($path1));
var_dump(file_exists($path1));
var_dump(stat($path1));
var_dump(lstat($path1));
var_dump(realpath($path1));
var_dump(disk_free_space($path1));
var_dump(diskfreespace($path1));
var_dump(disk_total_space($path1));
var_dump(chmod($path1, '644'));
var_dump(chown($path1, 'nobody'));
var_dump(lchown($path1, 'nobody'));
var_dump(chgrp($path1, 'nogrp'));
var_dump(lchgrp($path1, 'nogrp'));
var_dump(touch($path1));
var_dump(copy($path1, $path2));
var_dump(rename($path1, $path2));
var_dump(unlink($path1, $path2));
var_dump(link($path1, $path2));
var_dump(symlink($path1, $path2));
var_dump(fnmatch($path1, $path2));
var_dump(tempnam($path1, 'tmp'));
var_dump(mkdir($path1));
var_dump(chdir($path1));
var_dump(chroot($path1));
var_dump(scandir($path1));
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:null_path.php


示例7: extractCurrent

 /**
  * Extract the current entry to which the iterator points.
  *
  * Extract the current entry to which the iterator points, and return true if the current entry is extracted.
  * If the iterator doesn't point to a valid entry, this method returns false.
  *
  * True if the file is extracted correctly, otherwise false.
  *
  * @param string $target
  *        The full path to which the target should be extracted.
  * @param bool $keepExisting
  *        True if the file shouldn't be overwritten if they already exist.
  *        For the opposite behaviour, false should be given.
  *
  * @throws ezcArchiveValueException     if the archive contains invalid values.
  * @throws ezcBaseFileNotFoundException if the link cannot be found.
  *
  * @return bool
  */
 public function extractCurrent($target, $keepExisting = false)
 {
     if ($this->file === null) {
         throw new ezcArchiveException("The archive is closed");
     }
     if (!$this->valid()) {
         return false;
     }
     $isWindows = substr(php_uname('s'), 0, 7) == 'Windows' ? true : false;
     $entry = $this->current();
     $type = $entry->getType();
     $fileName = $target . DIRECTORY_SEPARATOR . $entry->getPath();
     if ($type == ezcArchiveEntry::IS_LINK) {
         $linkName = $target . DIRECTORY_SEPARATOR . $entry->getLink();
         if (!file_exists($linkName)) {
             throw new ezcBaseFileNotFoundException($linkName, "link", "Hard link could not be created.");
         }
     }
     $this->createDefaultDirectory($fileName);
     if (!$keepExisting || !is_link($fileName) && !file_exists($fileName)) {
         if ((file_exists($fileName) || is_link($fileName)) && !is_dir($fileName)) {
             unlink($fileName);
         }
         if (!file_exists($fileName)) {
             switch ($type) {
                 case ezcArchiveEntry::IS_CHARACTER_DEVICE:
                     if (ezcBaseFeatures::hasFunction('posix_mknod')) {
                         posix_mknod($fileName, POSIX_S_IFCHR, $entry->getMajor(), $entry->getMinor());
                     } else {
                         throw new ezcArchiveValueException($type);
                     }
                     break;
                 case ezcArchiveEntry::IS_BLOCK_DEVICE:
                     if (ezcBaseFeatures::hasFunction('posix_mknod')) {
                         posix_mknod($fileName, POSIX_S_IFBLK, $entry->getMajor(), $entry->getMinor());
                     } else {
                         throw new ezcArchiveValueException($type);
                     }
                     break;
                 case ezcArchiveEntry::IS_FIFO:
                     if (ezcBaseFeatures::hasFunction('posix_mknod')) {
                         posix_mknod($fileName, POSIX_S_IFIFO);
                     } else {
                         throw new ezcArchiveValueException($type);
                     }
                     break;
                 case ezcArchiveEntry::IS_SYMBOLIC_LINK:
                     if ($isWindows) {
                         // FIXME.. need to be sure that target file
                         // already extracted before copying it to link destination.
                         $sourcePath = dirname($fileName) . '/' . $entry->getLink();
                         $fileName = str_replace('/', '\\', $fileName);
                         copy($sourcePath, $fileName);
                     } else {
                         symlink($entry->getLink(), $fileName);
                     }
                     break;
                 case ezcArchiveEntry::IS_LINK:
                     if ($isWindows) {
                         copy($target . DIRECTORY_SEPARATOR . $entry->getLink(), $fileName);
                     } else {
                         link($target . DIRECTORY_SEPARATOR . $entry->getLink(), $fileName);
                     }
                     break;
                 case ezcArchiveEntry::IS_DIRECTORY:
                     $permissions = $entry->getPermissions();
                     if ($permissions === null || $permissions === false) {
                         $permissions = '0777';
                     }
                     mkdir($fileName, octdec($permissions), true);
                     break;
                 case ezcArchiveEntry::IS_FILE:
                     $this->writeCurrentDataToFile($fileName);
                     break;
                 default:
                     throw new ezcArchiveValueException($type);
             }
             if ($type == ezcArchiveEntry::IS_SYMBOLIC_LINK && ezcBaseFeatures::hasFunction('posix_geteuid') && posix_geteuid() == 0) {
                 $user = $entry->getUserId();
                 $group = $entry->getGroupId();
                 @lchown($fileName, $user);
//.........这里部分代码省略.........
开发者ID:alex-fang,项目名称:Archive,代码行数:101,代码来源:archive.php


示例8: lchown

<?php

/* Prototype  : bool lchown (string filename, mixed user)
 * Description: Change file owner of a symlink
 * Source code: ext/standard/filestat.c
 * Alias to functions: 
 */
echo "*** Testing lchown() : basic functionality ***\n";
$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown_basic.txt';
$symlink = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown_basic_symlink.txt';
$uid = posix_getuid();
var_dump(touch($filename));
var_dump(symlink($filename, $symlink));
var_dump(lchown($filename, $uid));
var_dump(fileowner($symlink) === $uid);
?>
===DONE===
<?php 
$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown_basic.txt';
$symlink = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown_basic_symlink.txt';
unlink($filename);
unlink($symlink);
开发者ID:alphaxxl,项目名称:hhvm,代码行数:22,代码来源:lchown_basic.php


示例9: chownSingleFile

 /**
  * Change the owner of an array of files or directories.
  *
  * @internal services:
  *     (+) FilesystemInterface chown($files, string $user, bool $recursive = false);
  *
  * @param string $file The filename to change owner
  * @param string $user The new owner user name
  *
  * @throws IOException When the change fails
  *
  * @return FilesystemInterface The current interface
  */
 protected function chownSingleFile($file, string $user) : FilesystemInterface
 {
     if (is_link($file)) {
         if (true !== @lchown($file, $user)) {
             throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
         }
     } else {
         if (true !== @chown($file, $user)) {
             throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
         }
     }
     return $this;
 }
开发者ID:ucsdmath,项目名称:filesystem,代码行数:26,代码来源:FilesystemStandardOperations.php


示例10: lchown

 /**
  * Changes user ownership of symlink
  *
  * @param string $filename Path to the file.
  * @param mixed  $user     User name or number.
  *
  * @return bool
  */
 public function lchown(string $filename, $user) : bool
 {
     return lchown($filename, $user);
 }
开发者ID:aurimasniekis,项目名称:php-wrappers,代码行数:12,代码来源:Filesystem.php


示例11: chown

 /**
  * Change the owner of an array of files or directories.
  *
  * @param string|array|Traversable $files     A filename, an array of files, or a Traversable instance to change owner
  * @param string                    $user      The new owner user name
  * @param bool                      $recursive Whether change the owner recursively or not
  *
  * @throws ehough_filesystem_exception_IOException When the change fail
  */
 public function chown($files, $user, $recursive = false)
 {
     foreach ($this->toIterator($files) as $file) {
         if ($recursive && is_dir($file) && !is_link($file)) {
             if (version_compare(PHP_VERSION, '5.3.0') < 0) {
                 $this->chown(new ehough_filesystem_iterator_SkipDotsRecursiveDirectoryIterator($file), $user, true);
             } else {
                 $this->chown(new FilesystemIterator($file), $user, true);
             }
         }
         if (is_link($file) && function_exists('lchown')) {
             if (true !== @lchown($file, $user)) {
                 throw new ehough_filesystem_exception_IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
             }
         } else {
             if (true !== @chown($file, $user)) {
                 throw new ehough_filesystem_exception_IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
             }
         }
     }
 }
开发者ID:ehough,项目名称:filesystem,代码行数:30,代码来源:Filesystem.php


示例12: lchown

<?php

/* Prototype  : bool lchown (string filename, mixed user)
 * Description: Change file owner of a symlink
 * Source code: ext/standard/filestat.c
 * Alias to functions: 
 */
echo "*** Testing lchown() : error functionality ***\n";
// Set up
$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchown.txt';
touch($filename);
$uid = posix_getuid();
// Less than expected arguments
var_dump(lchown($filename));
// More than expected arguments
var_dump(lchown($filename, $uid, 'foobar'));
// Non-existent filename
var_dump(lchown('foobar_lchown.txt', $uid));
// Wrong argument types
var_dump(lchown(new StdClass(), $uid));
var_dump(lchown(array(), $uid));
// Bad user
var_dump(lchown($filename, -5));
?>
===DONE===
开发者ID:gleamingthecube,项目名称:php,代码行数:25,代码来源:ext_standard_tests_file_lchown_error.php


示例13: url_stat

    {
        return true;
    }
    public function url_stat($path, $flags)
    {
        return true;
    }
}
stream_wrapper_register("abc", "A") or die("Failed to register protocol");
touch('abc://a');
touch('abc://b', 15);
touch('abc://c', 15, 25);
chmod('abc://d', 0123);
chmod('abc://e', 0345);
chown('abc://f', 0);
chown('abc://g', 10);
chown('abc://h', 'root');
lchown('abc://i', 0);
lchown('abc://j', 10);
lchown('abc://k', 'root');
chgrp('abc://l', 0);
chgrp('abc://m', 10);
chgrp('abc://n', 'root');
lchgrp('abc://o', 0);
lchgrp('abc://p', 10);
lchgrp('abc://q', 'root');
// explicit errors
chown('abc://r', []);
lchown('abc://s', []);
chgrp('abc://t', []);
lchgrp('abc://u', []);
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:stream_wrapper_register_metadata.php


示例14: tempnam

<?php

$file = tempnam('/tmp', 'lchown');
$link = tempnam('/tmp', 'lchown');
touch($file);
@symlink($file, $link);
var_dump(lchown($link, 'ihopenomachinehasthisuserthatwouldbebad'));
var_dump(chown($file, 'ihopenomachinehasthisuserthatwouldbebad'));
开发者ID:jeremyadoux,项目名称:hhvm,代码行数:8,代码来源:lchown_wronguser.php


示例15: lchgrp

 function lchgrp($fn, $group)
 {
     return lchown($fn, ":{$group}");
 }
开发者ID:ateliee,项目名称:php_lib,代码行数:4,代码来源:upgrade.php


示例16: chown

 /** 
  * Create chown function to allow mocking in unit tests 
  * Attempts to change the owner of the file filename  to user user . 
  * Only the superuser may change the owner of a file. 
  * 
  * @param string $path Path to the file. 
  * @param mixed  $uid  A user name or number.
  * 
  * @return boolean true on success or false on failure
  */
 public function chown($path, $uid)
 {
     if (is_link($path)) {
         return lchown($path, $uid);
     }
     return chown($path, $uid);
 }
开发者ID:blestab,项目名称:tuleap,代码行数:17,代码来源:Backend.class.php


示例17: setOwner

 /**
  * Changes file owner
  *
  * Attempts to change the owner. Only the superuser may change the owner of a file.
  *
  * @param mixed $user A user name or number.
  * @return boolean Returns TRUE on success or FALSE on failure.
  */
 public function setOwner($user)
 {
     if ($this->isLink()) {
         return lchown($this->pathname, $user);
     } else {
         return chown($this->pathname, $user);
     }
 }
开发者ID:phootwork,项目名称:file,代码行数:16,代码来源:FileOperationTrait.php


示例18: chown

 /**
  * @param mixed $newOwner The user name or user number or an object representing the user.
  * @param bool $recursive
  * @return bool TRUE if the owner has been successfully modified, FALSE otherwise.
  * @throws EyeIOException
  */
 public function chown($newOwner, $recursive = false)
 {
     if ($recursive) {
         //TODO recursive chown
         throw new EyeNotImplementedException(__METHOD__ . ': $recursive = true');
     }
     $path = AdvancedPathLib::getPhpLocalHackPath($this->path);
     try {
         if ($this->isLink()) {
             return lchown($path, $newOwner);
         } else {
             return chown($path, $newOwner);
         }
     } catch (EyeErrorException $e) {
         throw new EyeIOException('Unable to change file\'s owner at ' . $this->path . '.', 0, $e);
     }
 }
开发者ID:DavidGarciaCat,项目名称:eyeos,代码行数:23,代码来源:GenericFile.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP lcm_fetch_array函数代码示例发布时间:2022-05-15
下一篇:
PHP lchgrp函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap