Java Code Examples for jcifs.smb.SmbFile#getName()
The following examples show how to use
jcifs.smb.SmbFile#getName() .
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: HFile.java From PowerFileExplorer with GNU General Public License v3.0 | 6 votes |
/** * @deprecated use {@link #getName(Context)} * @return */ public String getName() { String name = null; switch (mode) { case SMB: SmbFile smbFile = getSmbFile(); if (smbFile != null) return smbFile.getName(); break; case FILE: return new File(path).getName(); case ROOT: return new File(path).getName(); default: //StringBuilder builder = new StringBuilder(path); name = path.substring(path.lastIndexOf("/") + 1, path.length()); } return name; }
Example 2
Source File: HFile.java From PowerFileExplorer with GNU General Public License v3.0 | 6 votes |
public String getName(Context context) { String name = null; switch (mode) { case SMB: SmbFile smbFile=getSmbFile(); if (smbFile != null) return smbFile.getName(); break; case FILE: return new File(path).getName(); case ROOT: return new File(path).getName(); case OTG: return OTGUtil.getDocumentFile(path, context, false).getName(); default: //StringBuilder builder = new StringBuilder(path); name = path.substring(path.lastIndexOf("/") + 1, path.length()); } return name; }
Example 3
Source File: JCIFS_NGController.java From DanDanPlayForAndroid with MIT License | 6 votes |
private List<SmbFileInfo> getFileInfoList(SmbFile[] smbFiles) { List<SmbFileInfo> fileInfoList = new ArrayList<>(); for (SmbFile smbFile : smbFiles) { boolean isDirectory = false; try { isDirectory = smbFile.isDirectory(); } catch (SmbException ignore) { } //remove / at the end of the path String smbFileName = smbFile.getName(); smbFileName = smbFileName.endsWith("/") ? smbFileName.substring(0, smbFileName.length() - 1) : smbFileName; fileInfoList.add(new SmbFileInfo(smbFileName, isDirectory)); } return fileInfoList; }
Example 4
Source File: NetworkExplorer.java From jcifs with GNU Lesser General Public License v2.1 | 6 votes |
protected int compareTypes ( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { String f2name, t1, t2; int i; if ( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } f2name = f2.getName(); if ( f1.isDirectory() ) { return f1name.compareToIgnoreCase(f2name); } i = f1name.lastIndexOf('.'); t1 = i == -1 ? "" : f1name.substring(i + 1); i = f2name.lastIndexOf('.'); t2 = i == -1 ? "" : f2name.substring(i + 1); i = t1.compareToIgnoreCase(t2); if ( i == 0 ) { return f1name.compareToIgnoreCase(f2name); } return i; }
Example 5
Source File: NetworkExplorer.java From jcifs-ng with GNU Lesser General Public License v2.1 | 6 votes |
protected int compareTypes ( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { String f2name, t1, t2; int i; if ( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } f2name = f2.getName(); if ( f1.isDirectory() ) { return f1name.compareToIgnoreCase(f2name); } i = f1name.lastIndexOf('.'); t1 = i == -1 ? "" : f1name.substring(i + 1); i = f2name.lastIndexOf('.'); t2 = i == -1 ? "" : f2name.substring(i + 1); i = t1.compareToIgnoreCase(t2); if ( i == 0 ) { return f1name.compareToIgnoreCase(f2name); } return i; }
Example 6
Source File: Samba1FileSystem.java From iaf with Apache License 2.0 | 6 votes |
@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 7
Source File: StreamSource.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
public StreamSource(SmbFile file,long l) throws SmbException { fp = 0; len = l; mime = MimeTypeMap.getFileExtensionFromUrl(file.getName()); name = file.getName(); this.file = file; bufferSize = 1024*60; }
Example 8
Source File: JCifsUtil.java From seed with Apache License 2.0 | 5 votes |
/** * 拷贝远程文件到本地目录 * @param smbFile 远程SmbFile * @param localDirectory 本地存储目录,本地目录不存在时会自动创建,本地目录存在时可自行选择是否清空该目录下的文件 * @return 拷贝结果,true--成功,false--失败 */ private static boolean copyRemoteFile(SmbFile smbFile, String localDirectory) { File[] localFiles = new File(localDirectory).listFiles(); if(null == localFiles){ //目录不存在的话,就创建目录 //new File("D:/aa/bb.et").mkdirs()会在aa文件夹下创建一个名为bb.et的文件夹 new File(localDirectory).mkdirs(); }else if(localFiles.length > 0){ for(File file : localFiles){ //清空本地目录下的所有文件 //new File("D:/aa/bb.et").delete()会删除bb.et文件,但aa文件夹还存在 file.delete(); } } try(SmbFileInputStream in=new SmbFileInputStream(smbFile); FileOutputStream out=new FileOutputStream(localDirectory+smbFile.getName())){ byte[] buffer = new byte[1024]; int len; while((len=in.read(buffer)) > -1){ out.write(buffer, 0, len); } out.flush(); } catch (Exception e) { LogUtil.getLogger().info("拷贝远程文件到本地目录时发生异常,堆栈轨迹如下", e); return false; } return true; }
Example 9
Source File: SMBFileInfo.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 5 votes |
/** * Similar to SmbFile.getName(), but removes trailing slash (in case of directories). */ public static String getName(SmbFile file) { String name = file.getName(); if (name.endsWith("/")) { name = name.substring(0, name.length() - 1); } return name; }
Example 10
Source File: StreamSource.java From Amphitheatre with Apache License 2.0 | 5 votes |
public StreamSource(SmbFile file) throws SmbException{ fp = 0; len = file.length(); mime = VideoUtils.getMimeType(file.getName(), false); name = file.getName(); this.file = file; bufferSize = 1024*32; }
Example 11
Source File: StreamSource.java From Mizuu with Apache License 2.0 | 5 votes |
public StreamSource(SmbFile file) throws SmbException{ fp = 0; len = file.length(); mime = "video/*"; name = file.getName(); this.file = file; bufferSize = 16 * 1024; }
Example 12
Source File: Samba1FileSystem.java From iaf with Apache License 2.0 | 4 votes |
@Override public String getName(SmbFile f) { return f.getName(); }