posix_getpwuid example

public function owner( $file ) {
        $owneruid = @fileowner( $file );

        if ( ! $owneruid ) {
            return false;
        }

        if ( ! function_exists( 'posix_getpwuid' ) ) {
            return $owneruid;
        }

        $ownerarray = posix_getpwuid( $owneruid );

        if ( ! $ownerarray ) {
            return false;
        }

        return $ownerarray['name'];
    }

    /** * Gets the permissions of the specified file or filepath in their octal format. * * FIXME does not handle errors in fileperms() * * @since 2.5.0 * * @param string $file Path to the file. * @return string Mode of the file (the last 3 digits). */
public function owner( $file ) {
        $owneruid = @fileowner( $this->sftp_path( $file ) );

        if ( ! $owneruid ) {
            return false;
        }

        if ( ! function_exists( 'posix_getpwuid' ) ) {
            return $owneruid;
        }

        $ownerarray = posix_getpwuid( $owneruid );

        if ( ! $ownerarray ) {
            return false;
        }

        return $ownerarray['name'];
    }

    /** * Gets the permissions of the specified file or filepath in their octal format. * * @since 2.7.0 * * @param string $file Path to the file. * @return string Mode of the file (the last 3 digits). */
$v_typeflag = '0';
            clearstatcache();
            $v_size = sprintf("%011s", DecOct($v_info['size']));
        }

        $v_magic = 'ustar ';
        $v_version = ' ';
        $v_uname = '';
        $v_gname = '';

        if (function_exists('posix_getpwuid')) {
            $userinfo = posix_getpwuid($v_info[4]);
            $groupinfo = posix_getgrgid($v_info[5]);

            if (isset($userinfo['name'])) {
                $v_uname = $userinfo['name'];
            }

            if (isset($groupinfo['name'])) {
                $v_gname = $groupinfo['name'];
            }
        }

        
$this->markAsSkippedIfPosixIsMissing();

        $infos = stat($filepath);

        return $infos['uid'];
    }

    protected function getFileOwner($filepath)
    {
        $this->markAsSkippedIfPosixIsMissing();

        return ($datas = posix_getpwuid($this->getFileOwnerId($filepath))) ? $datas['name'] : null;
    }

    protected function getFileGroupId($filepath)
    {
        $this->markAsSkippedIfPosixIsMissing();

        $infos = stat($filepath);

        return $infos['gid'];
    }

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