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


PHP lchgrp函数代码示例

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


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

示例1: chgrp

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

示例2: chgrp

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

示例3: chgrp

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

示例4: changeGroup

 /**
  * Change file group.
  *
  * @access  public
  * @param   mixed   $group    Group name or number.
  * @return  bool
  */
 public function changeGroup($group)
 {
     return lchgrp($this->getStreamName(), $group);
 }
开发者ID:Hywan,项目名称:File,代码行数:11,代码来源:Link.php

示例5: setChgrp

 /**
  * Changes file group
  * 
  * Change group of file and directory or a link
  * Set a group like name or GUID (ex: 1000)
  * 
  * @param string $path Path to the file
  * @param string $user A group name or number
  * @param bool $recursive Recursive set a group
  * @return bool State of changes
  * @throws \RuntimeException
  */
 public function setChgrp($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 (!lchgrp($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 (!chgrp($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 (!lchgrp($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 (!chgrp($path, $user)) {
                     throw new Exception(sprintf("Can not change file owner for file %s with user %s", $path, $user));
                 }
                 $state = true;
             }
         }
     }
     clearstatcache();
     return $state;
 }
开发者ID:ionitium,项目名称:filesystem,代码行数:50,代码来源:Filesystem.php

示例6: chgrp

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

示例7: extractCurrent


//.........这里部分代码省略.........
     $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);
                 @lchgrp($fileName, $group);
             }
             // Change the username and group if the filename exists and if
             // the intention is to keep it as a file. A zip archive
             // stores the symlinks in a file; thus don't change these.
             if (file_exists($fileName) && ($type == ezcArchiveEntry::IS_FILE || $type == ezcArchiveEntry::IS_DIRECTORY)) {
                 $group = $entry->getGroupId();
                 $user = $entry->getUserId();
                 $time = $entry->getModificationTime();
                 $perms = octdec($entry->getPermissions());
                 if ($this->options && $this->options->extractCallback) {
                     $this->options->extractCallback->{$type == ezcArchiveEntry::IS_DIRECTORY ? 'createDirectoryCallback' : 'createFileCallback'}($fileName, $perms, $user, $group);
                 }
                 if (ezcBaseFeatures::hasFunction('posix_geteuid') && posix_geteuid() === 0) {
                     @chgrp($fileName, $group);
                     @chown($fileName, $user);
                 }
                 if ($perms != false) {
                     chmod($fileName, $perms);
                 }
                 touch($fileName, $time);
             }
         }
         return true;
     }
     return false;
 }
开发者ID:alex-fang,项目名称:Archive,代码行数:101,代码来源:archive.php

示例8: dirname

<?php

$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchgrp.txt';
$symlink = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'symlink.txt';
$gid = posix_getgid();
var_dump(touch($filename));
var_dump(symlink($filename, $symlink));
var_dump(lchgrp($filename, $gid));
var_dump(filegroup($symlink) === $gid);
?>
===DONE===
<?php 
$filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'lchgrp.txt';
$symlink = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'symlink.txt';
unlink($filename);
unlink($symlink);
开发者ID:alphaxxl,项目名称:hhvm,代码行数:16,代码来源:lchgrp_basic.php

示例9: chgrp

 /**
  * Change the group of an array of files or directories.
  *
  * @param string|array|Traversable $files     A filename, an array of files, or a Traversable instance to change group
  * @param string                    $group     The group name
  * @param bool                      $recursive Whether change the group recursively or not
  *
  * @throws ehough_filesystem_exception_IOException When the change fail
  */
 public function chgrp($files, $group, $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->chgrp(new ehough_filesystem_iterator_SkipDotsRecursiveDirectoryIterator($file), $group, true);
             } else {
                 $this->chgrp(new FilesystemIterator($file), $group, true);
             }
         }
         if (is_link($file) && function_exists('lchgrp')) {
             if (true !== @lchgrp($file, $group) || defined('HHVM_VERSION') && !posix_getgrnam($group)) {
                 throw new ehough_filesystem_exception_IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
             }
         } else {
             if (true !== @chgrp($file, $group)) {
                 throw new ehough_filesystem_exception_IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
             }
         }
     }
 }
开发者ID:ehough,项目名称:filesystem,代码行数:30,代码来源:Filesystem.php

示例10: chgrpSingleFile

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

示例11: lchgrp

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

示例12: 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,代码行数:30,代码来源:stream_wrapper_register_metadata.php

示例13: 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

示例14: setGroup

 /**
  * Attempts to change the group.
  *
  * Only the superuser may change the group arbitrarily; other users may
  * change the group of a file to any group of which that user is a member.
  *
  * @param mixed $group A group name or number.
  * @return boolean Returns TRUE on success or FALSE on failure.
  */
 public function setGroup($group)
 {
     if ($this->isLink()) {
         return lchgrp($this->pathname, $group);
     } else {
         return chgrp($this->pathname, $group);
     }
 }
开发者ID:phootwork,项目名称:file,代码行数:17,代码来源:FileOperationTrait.php

示例15: chgrp

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


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