private boolean mkdir(Path f) throws IOException { try { FileStatus fileStatus = getFileStatus(f); if (!fileStatus.isDir()) { throw new IOException(String.format( "Can't make directory for path %s since it is a file.", f)); } } catch (FileNotFoundException e) { String key = pathToKey(f) + FOLDER_SUFFIX; store.storeEmptyFile(key); } return true; }
private boolean mkdir(Path f) throws IOException { try { FileStatus fileStatus = getFileStatus(f); if (!fileStatus.isDir()) { throw new IOException(String.format( "Can't make directory for path %s since it is a file.", f)); } } catch (FileNotFoundException e) { String key = pathToKey(f) + FOLDER_SUFFIX; store.storeEmptyFile(key); } return true; }
private boolean mkdir(Path f) throws IOException { try { FileStatus fileStatus = getFileStatus(f); if (fileStatus.isFile()) { throw new FileAlreadyExistsException(String.format( "Can't make directory for path '%s' since it is a file.", f)); } } catch (FileNotFoundException e) { if(LOG.isDebugEnabled()) { LOG.debug("Making dir '" + f + "' in S3"); } String key = pathToKey(f) + FOLDER_SUFFIX; store.storeEmptyFile(key); } return true; }
@Override public FSDataInputStream open(Path f, int bufferSize) throws IOException { FileStatus fs = getFileStatus(f); // will throw if the file doesn't exist if (fs.isDirectory()) { throw new FileNotFoundException("'" + f + "' is a directory"); } LOG.info("Opening '" + f + "' for reading"); Path absolutePath = makeAbsolute(f); String key = pathToKey(absolutePath); return new FSDataInputStream(new BufferedFSInputStream( new NativeS3FsInputStream(store, statistics, store.retrieve(key), key), bufferSize)); }
boolean dstIsFile = getFileStatus(dst).isFile(); if (dstIsFile) { if(LOG.isDebugEnabled()) { if (getFileStatus(dst.getParent()).isFile()) { if(LOG.isDebugEnabled()) { LOG.debug(debugPreamble + srcIsFile = getFileStatus(src).isFile(); } catch (FileNotFoundException e) { if(LOG.isDebugEnabled()) {
@Override public boolean delete(Path f, boolean recursive) throws IOException { FileStatus status; try { status = getFileStatus(f); } catch (FileNotFoundException e) { return false; } Path absolutePath = makeAbsolute(f); String key = pathToKey(absolutePath); if (status.isDir()) { FileStatus[] contents = listStatus(f); if (!recursive && contents.length > 0) { throw new IOException("Directory " + f.toString() + " is not empty."); } for (FileStatus p : contents) { if (!delete(p.getPath(), recursive)) { return false; } } store.delete(key + FOLDER_SUFFIX); } else { store.delete(key); } return true; }
@Override public boolean delete(Path f, boolean recursive) throws IOException { FileStatus status; try { status = getFileStatus(f); } catch (FileNotFoundException e) { return false; } Path absolutePath = makeAbsolute(f); String key = pathToKey(absolutePath); if (status.isDir()) { FileStatus[] contents = listStatus(f); if (!recursive && contents.length > 0) { throw new IOException("Directory " + f.toString() + " is not empty."); } for (FileStatus p : contents) { if (!delete(p.getPath(), recursive)) { return false; } } store.delete(key + FOLDER_SUFFIX); } else { store.delete(key); } return true; }
FileStatus status; try { status = getFileStatus(f); } catch (FileNotFoundException e) { if(LOG.isDebugEnabled()) {
if (!getFileStatus(dst.getParent()).isDir()) { return false; // parent dst is a file
if (!getFileStatus(dst.getParent()).isDir()) { return false; // parent dst is a file