phpseclib\Net\SFTP::_parseLongname PHP Method

_parseLongname() public method

SFTPv3 doesn't provide any easy way of identifying a file type. You could try to open a file as a directory and see if an error is returned or you could try to parse the SFTPv3-specific longname field of the SSH_FXP_NAME packet. That's what this function does. The result is returned using the {@link http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2 SFTPv4 type constants}. If the longname is in an unrecognized format bool(false) is returned.
public _parseLongname ( string $longname ) : mixed
$longname string
return mixed
    function _parseLongname($longname)
    {
        // http://en.wikipedia.org/wiki/Unix_file_types
        // http://en.wikipedia.org/wiki/Filesystem_permissions#Notation_of_traditional_Unix_permissions
        if (preg_match('#^[^/]([r-][w-][xstST-]){3}#', $longname)) {
            switch ($longname[0]) {
                case '-':
                    return NET_SFTP_TYPE_REGULAR;
                case 'd':
                    return NET_SFTP_TYPE_DIRECTORY;
                case 'l':
                    return NET_SFTP_TYPE_SYMLINK;
                default:
                    return NET_SFTP_TYPE_SPECIAL;
            }
        }
        return false;
    }