@Override public Path createFile(Path path){ if (!isActive()) { return null; } return getIOService().createFile(path); }
public Path getPath(String path){ if (!isActive()) { return null; } return getIOService().get(path); }
public Iterable<Path> listDirectories(final Path path){ if (!isActive()) { return new ArrayList<Path>(); } return getIOService().newDirectoryStream( path, new DirectoryStream.Filter<Path>() { @Override public boolean accept( final Path entry ) throws IOException { if ( Files.isDirectory(entry) ) { return true; } return false; } } ); }
@Override public boolean exists(Path file){ if (!isActive()) { return false; } return getIOService().exists(file); }
@Override public Iterable<Path> loadFilesByType( final Path path, final String fileType ) { if (!isActive()) { return new ArrayList<Path>(); } return getIOService().newDirectoryStream( path, new DirectoryStream.Filter<Path>() { @Override public boolean accept( final Path entry ) throws IOException { if ( !Files.isDirectory( entry ) && (entry.getFileName().toString().endsWith( fileType ) || entry.getFileName().toString().matches(fileType))) { return true; } return false; } } ); }
@Override public Path createDirectory(Path path){ if (!isActive()) { return null; } checkNotNull( "path", path ); return getIOService().createDirectory(path); }
@Override public boolean deleteIfExists(Path path){ if (!isActive()) { return false; } checkNotNull( "path", path ); return getIOService().deleteIfExists(path); }
@Override public OutputStream openFile(Path path){ if (!isActive()) { return null; } checkNotNull( "path", path ); return getIOService().newOutputStream(path); }
@Override public void move(Path source, Path dest){ if (!isActive()) { return; } this.copy(source, dest); getIOService().delete(source); }
@Override public void copy(Path source, Path dest){ if (!isActive()) { return; } checkNotNull( "source", source ); checkNotNull( "dest", dest ); getIOService().copy(source, dest); }
@Override public byte[] loadFile( final Path file ) throws FileException { if (!isActive()) { return new byte[0]; } checkNotNull( "file", file ); try { return getIOService().readAllBytes( file ); } catch ( IOException ex ) { throw new FileException( ex.getMessage(), ex ); } }