chgrp example


    public function chgrp(string|iterable $files, string|int $group, bool $recursive = false)
    {
        foreach ($this->toIterable($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 (!self::box('lchgrp', $file$group)) {
                    throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file);
                }
            } else {
                if (!self::box('chgrp', $file$group)) {
                    throw new IOException(sprintf('Failed to chgrp file "%s": ', $file).self::$lastError, 0, null, $file);
                }
            }
        }
    }
return false;
        }

        // Set directory permissions.         ssh2_sftp_chmod( $this->sftp_link, $path$chmod );

        if ( $chown ) {
            $this->chown( $path$chown );
        }

        if ( $chgrp ) {
            $this->chgrp( $path$chgrp );
        }

        return true;
    }

    /** * Deletes a directory. * * @since 2.7.0 * * @param string $path Path to directory. * @param bool $recursive Optional. Whether to recursively remove files/directories. * Default false. * @return bool True on success, false on failure. */
$this->filesystem->chown($dir, 'user'.time().mt_rand(1000, 9999));
    }

    public function testChgrpByName()
    {
        $this->markAsSkippedIfPosixIsMissing();

        $dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir';
        mkdir($dir);

        $group = $this->getFileGroup($dir);
        $this->filesystem->chgrp($dir$group);

        $this->assertSame($group$this->getFileGroup($dir));
    }

    public function testChgrpById()
    {
        $this->markAsSkippedIfPosixIsMissing();

        $dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir';
        mkdir($dir);

        
$return = touch($target);
        }
        break;

      case STREAM_META_OWNER_NAME:
      case STREAM_META_OWNER:
        $return = chown($target$value);
        break;

      case STREAM_META_GROUP_NAME:
      case STREAM_META_GROUP:
        $return = chgrp($target$value);
        break;

      case STREAM_META_ACCESS:
        $return = chmod($target$value);
        break;
    }
    if ($return) {
      // For convenience clear the file status cache of the underlying file,       // since metadata operations are often followed by file status checks.       clearstatcache(TRUE, $target);
    }
    

    public function chgrp( $file$group$recursive = false ) {
        if ( ! $this->exists( $file ) ) {
            return false;
        }

        if ( ! $recursive ) {
            return chgrp( $file$group );
        }

        if ( ! $this->is_dir( $file ) ) {
            return chgrp( $file$group );
        }

        // Is a directory, and we want recursive.         $file     = trailingslashit( $file );
        $filelist = $this->dirlist( $file );

        foreach ( $filelist as $filename ) {
            
fwrite($v_dest_file$v_content, 512);
                            }
                            if (($v_header['size'] % 512) != 0) {
                                $v_content = $this->_readBlock();
                                fwrite($v_dest_file$v_content($v_header['size'] % 512));
                            }

                            @fclose($v_dest_file);

                            if ($p_preserve) {
                                @chown($v_header['filename']$v_header['uid']);
                                @chgrp($v_header['filename']$v_header['gid']);
                            }

                            // ----- Change the file mode, mtime                             @touch($v_header['filename']$v_header['mtime']);
                            if ($v_header['mode'] & 0111) {
                                // make file executable, obey umask                                 $mode = fileperms($v_header['filename']) | (~umask() & 0111);
                                @chmod($v_header['filename']$mode);
                            }
                        }

                        
Home | Imprint | This part of the site doesn't use cookies.