Java Code Examples for jcifs.smb.SmbFile#canRead()

The following examples show how to use jcifs.smb.SmbFile#canRead() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JCIFS_NGController.java    From DanDanPlayForAndroid with MIT License 6 votes vote down vote up
@Override
public List<SmbFileInfo> getSelfList() {
    if (isRootDir())
        return rootFileList;

    List<SmbFileInfo> fileInfoList = new ArrayList<>();
    try {
        SmbFile smbFile = new SmbFile(mAuthUrl + mPath, cifsContext);
        if (smbFile.isDirectory() && smbFile.canRead()) {
            fileInfoList.addAll(getFileInfoList(smbFile.listFiles()));
        }
    } catch (MalformedURLException | SmbException e) {
        e.printStackTrace();
    }

    return fileInfoList;
}
 
Example 2
Source File: JCIFS_NGController.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public List<SmbFileInfo> getParentList() {
    if (isRootDir())
        return new ArrayList<>();

    List<SmbFileInfo> fileInfoList = new ArrayList<>();
    try {
        //is first directory like smbJ share
        String parentPath = mPath.substring(0, mPath.length() - 1);
        int index = parentPath.indexOf("/", 1);

        //get parent path index
        int endIndex = parentPath.lastIndexOf("/");
        mPath = mPath.substring(0, endIndex) + "/";

        if (index == -1)
            return rootFileList;

        SmbFile smbFile = new SmbFile(mAuthUrl + mPath, cifsContext);
        if (smbFile.isDirectory() && smbFile.canRead()) {
            fileInfoList.addAll(getFileInfoList(smbFile.listFiles()));
        }
    } catch (MalformedURLException | SmbException e) {
        e.printStackTrace();
    }

    return fileInfoList;
}
 
Example 3
Source File: JCIFS_NGController.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public List<SmbFileInfo> getChildList(String dirName) {
    List<SmbFileInfo> fileInfoList = new ArrayList<>();
    try {
        mPath += dirName + "/";
        SmbFile smbFile = new SmbFile(mAuthUrl + mPath, cifsContext);
        if (smbFile.isDirectory() && smbFile.canRead()) {
            fileInfoList.addAll(getFileInfoList(smbFile.listFiles()));
        }
    } catch (MalformedURLException | SmbException e) {
        e.printStackTrace();
    }

    return fileInfoList;
}
 
Example 4
Source File: JCIFS_NGController.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public InputStream getFileInputStream(String fileName) {
    try {
        String filePath = mPath + fileName + "/";
        SmbFile smbFile = new SmbFile(mAuthUrl + filePath, cifsContext);
        if (smbFile.isFile() && smbFile.canRead()) {
            inputStream = smbFile.getInputStream();
            return inputStream;
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}
 
Example 5
Source File: JCIFS_NGController.java    From DanDanPlayForAndroid with MIT License 5 votes vote down vote up
@Override
public long getFileLength(String fileName) {
    try {
        String filePath = mPath + fileName + "/";
        SmbFile smbFile = new SmbFile(mAuthUrl + filePath, cifsContext);
        if (smbFile.isFile() && smbFile.canRead()) {
            return smbFile.getContentLengthLong();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return 0;
}