import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public Attribute getAttribute(VFSNode node, SftpATTRS attrs, String name, boolean isDir, boolean update)
throws VrsException
{
// Optimization: only update if a SftpAttribute AND an update is
// requested:
if (name == null)
return null;
// initialize attributes if not yet fetched!
if (attrs == null)
{
attrs = this.getSftpAttrs(node.getPath());
}
// get attributes from same holder:
if (name.compareTo(ATTR_MODIFICATION_TIME) == 0)
{
return AttributeUtil.createDateFromMilliesSinceEpoch(name, getModificationTime(attrs));
}
else if (name.compareTo(ATTR_LASTACCESS_TIME) == 0)
{
return new Attribute(AttributeType.DATETIME, name, getAccessTime(attrs));
}
else if (name.compareTo(ATTR_FILE_SIZE) == 0)
{
return new Attribute(name, attrs.getSize());
}
else if (name.compareTo(ATTR_UNIX_USERID) == 0)
{
return new Attribute(name, attrs.getUId());
}
else if (name.compareTo(ATTR_UNIX_GROUPID) == 0)
{
return new Attribute(name, attrs.getGId());
}
else if (name.compareTo(ATTR_UNIX_FILE_MODE) == 0)
{
// note sftp attributes return higher value the (8)07777 (isdir and
// islink)
return new Attribute(name, "0" + Integer.toOctalString(attrs.getPermissions() % 07777));
}
return null;
}