boolean success = false; try { success = fsview.changeWorkingDirectory(".."); } catch (Exception ex) { LOG.debug("Failed to change directory in file system", ex); FtpFile cwd = fsview.getWorkingDirectory(); if (success) { String dirName = cwd.getAbsolutePath();
/** * Get the file list. Files will be listed in alphabetlical order. */ private List<? extends FtpFile> listFiles(FileSystemView fileSystemView, String file) { List <? extends FtpFile> files = null; try { FtpFile virtualFile = fileSystemView.getFile(file); if (virtualFile.isFile()) { List<FtpFile> auxFiles = new ArrayList<FtpFile>(); auxFiles.add(virtualFile); files = auxFiles; } else { files = virtualFile.listFiles(); } } catch (FtpException ex) { } return files; } }
if(fs != null) { try { fs.dispose(); } catch (Exception e) { LOG.warn("FileSystemView threw an exception on disposal", e);
file = session.getFileSystemView().getFile(fileName); } catch (Exception ex) { LOG.debug("Exception getting file object", ex); FtpFile cwd = session.getFileSystemView().getWorkingDirectory(); if(file.equals(cwd)) { session.write(LocalizedFileActionFtpReply.translate(session, request, context,
/** * Extracts the working directory of the current session to an absolute file system path * (contrary to what {@link FileSystemView#getWorkingDirectory() returns, which is relative to * the user's home dir}) */ private File workingDir(FtpSession session) throws FtpException { FtpFile workingDirectory = session.getFileSystemView().getWorkingDirectory(); String home = session.getUser().getHomeDirectory(); String absolutePath = workingDirectory.getAbsolutePath().substring(1); File workingDir = new File(new File(home), absolutePath); return workingDir; }
@Override public FileSystemView createFileSystemView(final User user) throws FtpException { final FileSystemView fsView = super.createFileSystemView(user); fsView.changeWorkingDirectory("home/test"); return fsView; } };
/** * Execute command */ public void execute(final FtpIoSession session, final FtpServerContext context, final FtpRequest request) throws IOException, FtpException { session.resetState(); FileSystemView fsview = session.getFileSystemView(); String currDir = fsview.getWorkingDirectory().getAbsolutePath(); session.write(LocalizedFtpReply.translate(session, request, context, FtpReply.REPLY_257_PATHNAME_CREATED, "PWD", currDir)); }
@Override public FileSystemView createFileSystemView(final User user) throws FtpException { final FileSystemView fsView = super.createFileSystemView(user); fsView.changeWorkingDirectory("home/test"); return fsView; } };
/** * Get unique file object. */ //TODO may need synchronization protected FtpFile getUniqueFile(FtpIoSession session, FtpFile oldFile) throws FtpException { FtpFile newFile = oldFile; FileSystemView fsView = session.getFileSystemView(); String fileName = newFile.getAbsolutePath(); while (newFile.doesExist()) { newFile = fsView.getFile(fileName + '.' + System.currentTimeMillis()); if (newFile == null) { break; } } return newFile; }
boolean success = false; try { success = fsview.changeWorkingDirectory(dirName); } catch (Exception ex) { LOG.debug("Failed to change directory in file system", ex); FtpFile cwd = fsview.getWorkingDirectory(); if (success) { dirName = cwd.getAbsolutePath();
if (fsView != null) { try { varVal = fsView.getWorkingDirectory().getAbsolutePath();
file = session.getFileSystemView().getFile(fileName); } catch (Exception ex) { LOG.debug("Exception getting the file object: " + fileName, ex);
file = session.getFileSystemView().getFile(fileName); } catch (Exception ex) { LOG.debug("Exception getting the file object: " + fileName, ex);
file = session.getFileSystemView().getFile(fileName); } catch (Exception ex) { LOG.debug("Exception getting the file object: " + fileName, ex);
renFr = session.getFileSystemView().getFile(fileName); } catch (Exception ex) { LOG.debug("Exception getting file object", ex);
file = session.getFileSystemView().getFile(fileName); } catch (Exception ex) { LOG.debug("Exception getting file object", ex);
file = session.getFileSystemView().getFile( parsedArg.getFile()); if (file != null && file.doesExist()) {
file = session.getFileSystemView().getFile(fileName); } catch (Exception ex) { LOG.debug("Exception getting file object", ex);
FtpFile file = session.getFileSystemView().getFile(parsedArg.getFile());