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

The following examples show how to use jcifs.smb.SmbFile#isFile() . 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: Samba1FileSystem.java    From iaf with Apache License 2.0 6 votes vote down vote up
@Override
public void deleteFile(SmbFile f) throws FileSystemException {
	try {
		if (!f.exists()) {
			throw new FileSystemException("File ["+f.getName()+"] not found");
		}
		if (f.isFile()) {
			f.delete();
		} else {
			throw new FileSystemException(
					"Trying to remove [" + f.getName() + "] which is a directory instead of a file");
		}
	} catch (SmbException e) {
		throw new FileSystemException(e);
	}
}
 
Example 2
Source File: Futils.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
public static long folderSize(SmbFile directory) {
    long length = 0;
    try {
        for (SmbFile file:directory.listFiles()) {

            if (file.isFile())
                length += file.length();
            else
                length += folderSize(file);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return length;
}
 
Example 3
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 4
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;
}