当前位置: 首页>>代码示例>>Java>>正文


Java SmbFile.canRead方法代码示例

本文整理汇总了Java中jcifs.smb.SmbFile.canRead方法的典型用法代码示例。如果您正苦于以下问题:Java SmbFile.canRead方法的具体用法?Java SmbFile.canRead怎么用?Java SmbFile.canRead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jcifs.smb.SmbFile的用法示例。


在下文中一共展示了SmbFile.canRead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: performListing

import jcifs.smb.SmbFile; //导入方法依赖的package包/类
private Set<SmbFile> performListing(final SmbFile directory2, final boolean recurseSubdirectories) throws SmbException {
    if (!directory2.canRead() || !directory2.canWrite()) {
        throw new IllegalStateException("Directory '" + directory2 + "' does not have sufficient permissions (i.e., not writable and readable)");
    }
    final Set<SmbFile> queue = new HashSet<SmbFile>();
    if (!directory2.exists()) {
        return queue;
    }

    final SmbFile[] children = directory2.listFiles();
    if (children == null) {
        return queue;
    }

    for (final SmbFile child : children) {
        if (child.isDirectory()) {
            if (recurseSubdirectories) {
                queue.addAll(performListing(child,  recurseSubdirectories));
            }
        } else  {
            queue.add(child);
        }
    }

    return queue;
}
 
开发者ID:dream-lab,项目名称:echo,代码行数:27,代码来源:GetSmbFiles.java

示例2: checkAccess

import jcifs.smb.SmbFile; //导入方法依赖的package包/类
/**
 * Checks access to file under the provided {@link SMBPath}.
 *
 * @param path {@link SMBPath} for which access should be checked.
 * @param modes AccessModes that should be checked. Onl yREAD and WRITE are supported.
 *
 * @throws NoSuchFileException If file or folder specified by {@link SMBPath} does not exist.
 * @throws AccessDeniedException If requested access cannot be provided for file or folder under {@link SMBPath}.
 * @throws IllegalArgumentException If provided path is not a {@link SMBPath} instance.
 * @throws IOException If checking accessfails for some reason.
 */
@Override
public void checkAccess(Path path, AccessMode... modes) throws IOException {
    SmbFile smbFile = SMBPath.fromPath(path).getSmbFile();

    /* First check if file exists. */
    if (!smbFile.exists()) throw new NoSuchFileException("The specified SMB resource does not exist.");

    /* Determin which attributes to check. */
    boolean checkRead = false;
    boolean checkWrite = false;
    for (AccessMode mode : modes) {
        if (mode.equals(AccessMode.READ)) checkRead = true;
        if (mode.equals(AccessMode.WRITE)) checkWrite = true;
    }

    /* Perform necessary checks. */
    if (checkRead && !smbFile.canRead())  throw new AccessDeniedException("The specified SMB resource is not readable.");
    if (checkWrite && !smbFile.canWrite())  throw new AccessDeniedException("The specified SMB resource is not writable.");
}
 
开发者ID:pontiussoftware,项目名称:smb-nio,代码行数:31,代码来源:SMBFileSystemProvider.java


注:本文中的jcifs.smb.SmbFile.canRead方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。