/** * Find the parents of this file * * @param file * @param parents */ public static void findParents(File file, List<File> parents) { File parentFile = file.getParentFile(); if (parentFile != null) { parents.add(parentFile); findParents(parentFile, parents); } }
if (filters != null && filters.size() > 0) filteredList = BaseFileTransferUtils.filterList(list, filters);
if (!fileEncoding.equals("UTF-8")) files.add(BaseFileTransferUtils.stringEncoder(path));
public BaseFileTransferMappedRecord get(ClientListEntry clientListEntry) throws ClientCommandGetException { // Construct file path and get the file into an // BaseFileTransferMappedRecord URI uri = clientListEntry.getUri(); File srcFile = new File((uri).getPath()); logger.debug("Getting file [" + srcFile.getPath() + "] into an BaseFileTransferMappedRecord"); //$NON-NLS-1$ //$NON-NLS-2$ // Getting the file content ByteArrayOutputStream output = new ByteArrayOutputStream(); String fileName = srcFile.getName(); BaseFileTransferMappedRecord record = null; try { if(!this.ftpClient.retrieveFile(fileName, output)) { throw new ClientCommandGetException("Failed to get file [" + fileName //$NON-NLS-1$ + "] from directory [" + uri.getPath()); //$NON-NLS-1$ } record = BaseFileTransferUtils.createBaseFileTransferMappedRecord(uri, output); output.close(); } catch (IOException e) { throw new ClientCommandGetException("Failed to get file [" + fileName //$NON-NLS-1$ + "] from directory [" + uri.getPath(), e); //$NON-NLS-1$ } return record; }
public BaseFileTransferMappedRecord get(ClientListEntry clientListEntry) throws ClientCommandGetException { // Construct file path and get the file into an // BaseFileTransferMappedRecord URI uri = clientListEntry.getUri(); File srcFile = new File((uri).getPath()); logger.debug("Getting file [" + srcFile.getPath() + "] into an BaseFileTransferMappedRecord"); //$NON-NLS-1$ //$NON-NLS-2$ // Getting the file content ByteArrayOutputStream output = new ByteArrayOutputStream(); String fileName = srcFile.getName(); BaseFileTransferMappedRecord record = null; try { if(!this.ftpClient.retrieveFile(fileName, output)) { throw new ClientCommandGetException("Failed to get file [" + fileName //$NON-NLS-1$ + "] from directory [" + uri.getPath()); //$NON-NLS-1$ } record = BaseFileTransferUtils.createBaseFileTransferMappedRecord(uri, output); output.close(); } catch (IOException e) { throw new ClientCommandGetException("Failed to get file [" + fileName //$NON-NLS-1$ + "] from directory [" + uri.getPath(), e); //$NON-NLS-1$ } return record; }
/** * Creates, if necessary all the parents in given file path * * @param filePath * @throws ClientCommandLsException * @throws ClientCommandMkdirException */ private void ensureParentsExist(String filePath) throws ClientCommandLsException, ClientCommandMkdirException { logger.debug("ensureParentsExist called with [" + filePath + "]"); //$NON-NLS-1$//$NON-NLS-2$ File file = new File(filePath); List<File> parents = new ArrayList<File>(); BaseFileTransferUtils.findParents(file, parents); Collections.reverse(parents); for (File directory : parents) { if (!dirExists(directory)) { logger.debug("creating new parent dir [" + directory.getPath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ mkdir(directory.getPath()); } } }
return BaseFileTransferUtils.createBaseFileTransferMappedRecord(uri, output);
filteredList = BaseFileTransferUtils.filterList(list, filters);
/** * Creates, if necessary all the parents in given file path * * @param filePath The path to the file * @throws ClientCommandLsException Exception if we cannot list files * @throws ClientCommandMkdirException Exception if we cannot make a * directory */ private void ensureParentsExist(String filePath) throws ClientCommandLsException, ClientCommandMkdirException { logger.debug("ensureParentsExist called with [" + filePath + "]"); //$NON-NLS-1$//$NON-NLS-2$ File file = new File(filePath); List<File> parents = new ArrayList<File>(); BaseFileTransferUtils.findParents(file, parents); Collections.reverse(parents); for (File directory : parents) { if(!dirExists(directory)) { logger.debug("creating new parent dir [" + directory.getPath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ mkdir(directory.getPath()); } } }
public BaseFileTransferMappedRecord get(String filePath) throws ClientCommandGetException { URI uri; BaseFileTransferMappedRecord record = null; ByteArrayOutputStream output = new ByteArrayOutputStream(); try { uri = new URI(filePath); try { logger.debug("getting file from filepath: [" + filePath + "]"); //$NON-NLS-1$ //$NON-NLS-2$ if(!this.ftpClient.retrieveFile(filePath, output)) { throw new ClientCommandGetException("Failed to get file from [" + filePath + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } record = BaseFileTransferUtils.createBaseFileTransferMappedRecord(uri, output); output.close(); } catch (IOException e) { throw new ClientCommandGetException("Failed to get file from [" + filePath + "]", e); //$NON-NLS-1$ //$NON-NLS-2$ } } catch (URISyntaxException e) { throw new ClientCommandGetException("could not create URI from filePath", e); //$NON-NLS-1$ } return record; }
filteredList = BaseFileTransferUtils.filterList(list, filters);
/** * Creates, if necessary all the parents in given file path * * @param filePath The path to the file * @throws ClientCommandLsException Exception if we cannot list files * @throws ClientCommandMkdirException Exception if we cannot make a * directory */ private void ensureParentsExist(String filePath) throws ClientCommandLsException, ClientCommandMkdirException { logger.debug("ensureParentsExist called with [" + filePath + "]"); //$NON-NLS-1$//$NON-NLS-2$ File file = new File(filePath); List<File> parents = new ArrayList<File>(); BaseFileTransferUtils.findParents(file, parents); Collections.reverse(parents); for (File directory : parents) { if(!dirExists(directory)) { logger.debug("creating new parent dir [" + directory.getPath() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ mkdir(directory.getPath()); } } }
public BaseFileTransferMappedRecord get(String filePath) throws ClientCommandGetException { URI uri; BaseFileTransferMappedRecord record = null; ByteArrayOutputStream output = new ByteArrayOutputStream(); try { uri = new URI(filePath); try { logger.debug("getting file from filepath: [" + filePath + "]"); //$NON-NLS-1$ //$NON-NLS-2$ if(!this.ftpClient.retrieveFile(filePath, output)) { throw new ClientCommandGetException("Failed to get file from [" + filePath + "]"); //$NON-NLS-1$ //$NON-NLS-2$ } record = BaseFileTransferUtils.createBaseFileTransferMappedRecord(uri, output); output.close(); } catch (IOException e) { throw new ClientCommandGetException("Failed to get file from [" + filePath + "]", e); //$NON-NLS-1$ //$NON-NLS-2$ } } catch (URISyntaxException e) { throw new ClientCommandGetException("could not create URI from filePath", e); //$NON-NLS-1$ } return record; }
throw new ClientCommandGetException(sb.toString(), e); BaseFileTransferMappedRecord record = BaseFileTransferUtils.createBaseFileTransferMappedRecord(uri, output); return record;