@Override public boolean move(FtpFile destination) { return mFile.renameTo(new File(destination.getAbsolutePath())); }
/** * 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; }
/** * 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; }
/** * Notifies the {@link FTPCallback} that a request to rename a file finished * * @see FTPCallback#onRenameEnd */ @Override public FtpletResult onRenameEnd(FtpSession session, FtpRequest request) throws FtpException, IOException { UserDetails user = user(session.getUser()); File workingDir = workingDir(session); String fileName = request.getArgument(); File renameTo = new File(workingDir, fileName); File renameFrom = new File(session.getRenameFrom().getAbsolutePath()); return toFtpResult(callback.onRenameEnd(user, workingDir, renameFrom, renameTo)); }
/** * Notifies the {@link FTPCallback} of a request to rename a file * * @see FTPCallback#onRenameStart */ @Override public FtpletResult onRenameStart(FtpSession session, FtpRequest request) throws FtpException, IOException { UserDetails user = user(session.getUser()); File workingDir = workingDir(session); String fileName = request.getArgument(); File renameTo = new File(workingDir, fileName); File renameFrom = new File(session.getRenameFrom().getAbsolutePath()); return toFtpResult(callback.onRenameStart(user, workingDir, renameFrom, renameTo)); }
/** * 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)); }
if (fsView != null) { try { varVal = fsView.getWorkingDirectory().getAbsolutePath();
String dirName = cwd.getAbsolutePath(); session.write(LocalizedFileActionFtpReply.translate(session, request, context, FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CDUP",
dirName = cwd.getAbsolutePath(); session.write(LocalizedFileActionFtpReply.translate(session, request, context, FtpReply.REPLY_250_REQUESTED_FILE_ACTION_OKAY, "CWD",
return; toFileStr = toFile.getAbsolutePath(); String logFrFileAbsolutePath = frFile.getAbsolutePath(); toFile.getAbsolutePath()); } else { session
} else { session.setRenameFrom(renFr); fileName = renFr.getAbsolutePath(); session .write(LocalizedFtpReply
fileName = file.getAbsolutePath(); if (!file.doesExist()) { session.write(LocalizedFtpReply.translate(session, request, context,
fileName = file.getAbsolutePath(); if (file.doesExist()) { String dateStr = DateUtils.getFtpDate(file.getLastModified());
fileName = file.getAbsolutePath();
return; fileName = file.getAbsolutePath();
return; String fileName = file.getAbsolutePath();
fileName = file.getAbsolutePath();
fileName = file.getAbsolutePath(); if (!file.isWritable()) { session.write(LocalizedFileActionFtpReply.translate(session, request, context,
return; fileName = file.getAbsolutePath();
return; fileName = file.getAbsolutePath();