function _parseMode($mode)
{
// values come from http://lxr.free-electrons.com/source/include/uapi/linux/stat.h#L12
// see, also, http://linux.die.net/man/2/stat
switch ($mode & 0170000) {
// ie. 1111 0000 0000 0000
case 00:
// no file type specified - figure out the file type using alternative means
return false;
case 040000:
return NET_SFTP_TYPE_DIRECTORY;
case 0100000:
return NET_SFTP_TYPE_REGULAR;
case 0120000:
return NET_SFTP_TYPE_SYMLINK;
// new types introduced in SFTPv5+
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-05#section-5.2
// new types introduced in SFTPv5+
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-05#section-5.2
case 010000:
// named pipe (fifo)
return NET_SFTP_TYPE_FIFO;
case 020000:
// character special
return NET_SFTP_TYPE_CHAR_DEVICE;
case 060000:
// block special
return NET_SFTP_TYPE_BLOCK_DEVICE;
case 0140000:
// socket
return NET_SFTP_TYPE_SOCKET;
case 0160000:
// whiteout
// "SPECIAL should be used for files that are of
// a known type which cannot be expressed in the protocol"
return NET_SFTP_TYPE_SPECIAL;
default:
return NET_SFTP_TYPE_UNKNOWN;
}
}