Java Code Examples for jcifs.smb.SmbFile#lastModified()
The following examples show how to use
jcifs.smb.SmbFile#lastModified() .
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 |
public long lastModified() throws MalformedURLException, SmbException { switch (mode) { case SMB: SmbFile smbFile = getSmbFile(); if (smbFile != null) return smbFile.lastModified(); break; case FILE: new File(path).lastModified(); break; case ROOT: BaseFile baseFile = generateBaseFileFromParent(); if (baseFile != null) return baseFile.date; } return new File("/").lastModified(); }
Example 2
Source File: SambaSenderOld.java From iaf with Apache License 2.0 | 6 votes |
private XmlBuilder getFileAsXmlBuilder(SmbFile file) throws SmbException { XmlBuilder fileXml = new XmlBuilder("file"); fileXml.addAttribute("name", file.getName()); long fileSize = file.length(); fileXml.addAttribute("size", "" + fileSize); fileXml.addAttribute("fSize", "" + Misc.toFileSize(fileSize, true)); fileXml.addAttribute("directory", "" + file.isDirectory()); fileXml.addAttribute("canonicalName", file.getCanonicalPath()); // Get the modification date of the file Date modificationDate = new Date(file.lastModified()); //add date String date = DateUtils.format(modificationDate, DateUtils.FORMAT_DATE); fileXml.addAttribute("modificationDate", date); // add the time String time = DateUtils.format(modificationDate, DateUtils.FORMAT_TIME_HMS); fileXml.addAttribute("modificationTime", time); return fileXml; }
Example 3
Source File: NetworkExplorer.java From jcifs with GNU Lesser General Public License v2.1 | 5 votes |
protected int compareDates ( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if ( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } if ( f1.isDirectory() ) { return f1name.compareToIgnoreCase(f2.getName()); } return f1.lastModified() > f2.lastModified() ? -1 : 1; }
Example 4
Source File: NetworkExplorer.java From jcifs-ng with GNU Lesser General Public License v2.1 | 5 votes |
protected int compareDates ( SmbFile f1, String f1name, SmbFile f2 ) throws IOException { if ( f1.isDirectory() != f2.isDirectory() ) { return f1.isDirectory() ? -1 : 1; } if ( f1.isDirectory() ) { return f1name.compareToIgnoreCase(f2.getName()); } return f1.lastModified() > f2.lastModified() ? -1 : 1; }
Example 5
Source File: SMBOperationHandler.java From CloverETL-Engine with GNU Lesser General Public License v2.1 | 4 votes |
private void copyInternal(SmbFile source, SmbFile target, CopyParameters params) throws IOException { if (Thread.currentThread().isInterrupted()) { throw new IOException(FileOperationMessages.getString("IOperationHandler.interrupted")); //$NON-NLS-1$ } source = toCannonicalFile(source); target = toCannonicalFile(target); if (source.equals(target)) { throw new SameFileException(source, target); } boolean makeParents = Boolean.TRUE.equals(params.isMakeParents()); if (source.isDirectory()) { if (!params.isRecursive()) { throw new IOException(MessageFormat.format(FileOperationMessages.getString("IOperationHandler.cannot_copy_directory"), source)); //$NON-NLS-1$ } if (target.exists() && !target.isDirectory()) { throw new IOException(MessageFormat.format(FileOperationMessages.getString("IOperationHandler.cannot_overwrite_not_a_directory"), source, target)); //$NON-NLS-1$ } source = ensureTrailingSlash(source); target = ensureTrailingSlash(target); if (!target.exists()) { try { if (makeParents) { target.mkdirs(); } else { target.mkdir(); } } catch (SmbException e) { throw new IOException(MessageFormat.format(FileOperationMessages.getString("IOperationHandler.create_failed"), target), e); //$NON-NLS-1$ } source.copyTo(target); } else { for (SmbFile child: source.listFiles()) { copyInternal(child, new SmbFile(target, child.getName()), params); } } } else { if (target.exists()) { if (params.isNoOverwrite()) { return; } if (params.isUpdate() && (source.lastModified() <= target.lastModified())) { return; } } else if (makeParents) { mkParentDirs(target); } source.copyTo(target); } }