本文整理汇总了Java中com.jcraft.jsch.SftpATTRS.getPermissions方法的典型用法代码示例。如果您正苦于以下问题:Java SftpATTRS.getPermissions方法的具体用法?Java SftpATTRS.getPermissions怎么用?Java SftpATTRS.getPermissions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jcraft.jsch.SftpATTRS
的用法示例。
在下文中一共展示了SftpATTRS.getPermissions方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStatInfo
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
private StatInfo createStatInfo(String dirName, String baseName, SftpATTRS attrs, ChannelSftp cftp) throws SftpException {
String linkTarget = null;
if (attrs.isLink()) {
String path = dirName + '/' + baseName;
RemoteStatistics.ActivityID activityID = RemoteStatistics.startChannelActivity("readlink", path); // NOI18N
try {
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "performing readlink {0}", path);
}
linkTarget = cftp.readlink(path);
} finally {
RemoteStatistics.stopChannelActivity(activityID);
}
}
Date lastModified = new Date(attrs.getMTime() * 1000L);
StatInfo result = new FileInfoProvider.StatInfo(baseName, attrs.getUId(), attrs.getGId(), attrs.getSize(),
attrs.isDir(), attrs.isLink(), linkTarget, attrs.getPermissions(), lastModified);
return result;
}
示例2: getFile
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public SshFile getFile(String path) {
path = getAbsolutePath(path);
try {
SftpATTRS attr = getSftpChannel().stat(path);
// FIXME following 2 statements cost about 400ms per each.
String groupName = getGroupNameByGID(attr.getGId());
String userName = getUserNameByUID(attr.getUId());
String fileName = getFileName(path);
SshFile file = new SshFile();
file.setName(fileName);
file.setPath(path);
file.setGroup(groupName);
file.setOwner(userName);
file.setLength(attr.getSize());
FilePermission permission = new FilePermission(attr.getPermissions());
file.setPermission(permission);
FileType t = FileType.parse(attr.getPermissions() & FileType.S_IFMT);
file.setType(t);
file.setLastAccessTime(new Date(((long) attr.getATime()) * 1000L));
file.setLastModifiedTime(new Date(((long) attr.getMTime()) * 1000L));
return file;
} catch (Exception e) {
throw new SshException(e);
}
}
示例3: getFileStatus
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
@Override
public FileStatus getFileStatus(Path path) throws IOException {
ChannelSftp channelSftp = null;
ChannelExec channelExec1 = null;
ChannelExec channelExec2 = null;
try {
channelSftp = fsHelper.getSftpChannel();
SftpATTRS sftpAttrs = channelSftp.stat(path.toString());
FsPermission permission = new FsPermission((short) sftpAttrs.getPermissions());
channelExec1 = fsHelper.getExecChannel("id " + sftpAttrs.getUId());
String userName = IOUtils.toString(channelExec1.getInputStream());
channelExec2 = fsHelper.getExecChannel("id " + sftpAttrs.getGId());
String groupName = IOUtils.toString(channelExec2.getInputStream());
FileStatus fs =
new FileStatus(sftpAttrs.getSize(), sftpAttrs.isDir(), 1, 0l, (long) sftpAttrs.getMTime(),
(long) sftpAttrs.getATime(), permission, StringUtils.trimToEmpty(userName),
StringUtils.trimToEmpty(groupName), path);
return fs;
} catch (SftpException e) {
throw new IOException(e);
} finally {
safeDisconnect(channelSftp);
safeDisconnect(channelExec1);
safeDisconnect(channelExec2);
}
}
示例4: getFileStatus
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
@Override
public FileStatus getFileStatus(Path path) throws IOException {
ChannelSftp channelSftp = null;
ChannelExec channelExec1 = null;
ChannelExec channelExec2 = null;
try {
channelSftp = this.fsHelper.getSftpChannel();
SftpATTRS sftpAttrs = channelSftp.stat(HadoopUtils.toUriPath(path));
FsPermission permission = new FsPermission((short) sftpAttrs.getPermissions());
channelExec1 = this.fsHelper.getExecChannel("id " + sftpAttrs.getUId());
String userName = IOUtils.toString(channelExec1.getInputStream());
channelExec2 = this.fsHelper.getExecChannel("id " + sftpAttrs.getGId());
String groupName = IOUtils.toString(channelExec2.getInputStream());
FileStatus fs =
new FileStatus(sftpAttrs.getSize(), sftpAttrs.isDir(), 1, 0l, sftpAttrs.getMTime(), sftpAttrs.getATime(),
permission, StringUtils.trimToEmpty(userName), StringUtils.trimToEmpty(groupName), path);
return fs;
} catch (SftpException e) {
throw new IOException(e);
} finally {
safeDisconnect(channelSftp);
safeDisconnect(channelExec1);
safeDisconnect(channelExec2);
}
}
示例5: isWritable
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public boolean isWritable(String path) throws VrsException
{
// check user writable:
SftpATTRS attrs = getSftpAttrs(path);
int mod = attrs.getPermissions();
return ((mod & 0200) > 0);
}
示例6: isReadable
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public boolean isReadable(String path) throws VrsException
{
// check user readable:
SftpATTRS attrs = getSftpAttrs(path);
int mod = attrs.getPermissions();
return ((mod & 0400) > 0);
}
示例7: getACL
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public Attribute[][] getACL(String path, boolean isDir) throws VrsException
{
SftpATTRS attrs = getSftpAttrs(path);
// sftp support unix styl file permissions
int mode = attrs.getPermissions();
return VFS.convertFileMode2ACL(mode, isDir);
}
示例8: listFiles
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public List<SshFile> listFiles(String path) {
path = getAbsolutePath(path);
try {
Vector vector = getSftpChannel().ls(path);
if (vector == null || vector.isEmpty()) {
return Collections.EMPTY_LIST;
}
List<SshFile> sshFiles = new ArrayList<>(vector.size());
for (Iterator<LsEntry> iter = vector.iterator(); iter.hasNext(); ) {
LsEntry entry = iter.next();
String filename = entry.getFilename();
if (filename.equals(".") || filename.equals("..")) {
continue;
}
SftpATTRS attr = entry.getAttrs();
SshFile file = new SshFile();
file.setName(entry.getFilename());
String filePath = createPath(path, entry.getFilename());
file.setPath(getAbsolutePath(filePath));
file.setLength(attr.getSize());
FilePermission permission = new FilePermission(attr.getPermissions());
file.setPermission(permission);
FileType t = FileType.parse(attr.getPermissions() & FileType.S_IFMT);
file.setType(t);
List<String> tokens = splitStringAndOmitEmpty(entry.getLongname(), " ");
String owner = tokens.get(2);
String group = tokens.get(3);
file.setOwner(owner);
file.setGroup(group);
file.setLastAccessTime(new Date(((long) attr.getATime()) * 1000L));
file.setLastModifiedTime(new Date(((long) attr.getMTime()) * 1000L));
sshFiles.add(file);
}
return sshFiles;
} catch (Exception e) {
if (e instanceof SshException) {
throw (SshException) e;
}
throw new SshException(e);
}
}
示例9: BasicAttributes
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public BasicAttributes(final SftpATTRS attr) {
Preconditions.checkArgument(attr != null, "specified null sftp attributes");
m_modifyTime = attr.getMTime();
m_isExecutable = (attr.getPermissions() & 0100) != 0;
}
示例10: getUnixMode
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public int getUnixMode(SftpATTRS attrs, boolean isDir) throws VrsException
{
return attrs.getPermissions();
}
示例11: getPermissions
import com.jcraft.jsch.SftpATTRS; //导入方法依赖的package包/类
public int getPermissions(SftpATTRS attrs) throws VrsException
{
return attrs.getPermissions();
}