@Override public void copyRecursively( File fromDirectory, File toDirectory ) throws IOException { Path target = path( toDirectory ); Path source = path( fromDirectory ); copyRecursively( source, target ); }
@Override public boolean mkdir( File fileName ) { if ( !fileExists( fileName ) ) { try { Files.createDirectory( path( fileName ) ); return true; } catch ( IOException ignore ) { } } return false; }
@Override public StoreChannel create( File fileName ) throws IOException { return open( fileName, OpenMode.READ_WRITE ); }
@Test void delegatedFileSystemWatcher() throws IOException { FileSystem fileSystem = mock(FileSystem.class); try ( DelegateFileSystemAbstraction abstraction = new DelegateFileSystemAbstraction( fileSystem ) ) { assertNotNull( abstraction.fileWatcher() ); } verify( fileSystem ).newWatchService(); } }
@Override public Reader openAsReader( File fileName, Charset charset ) throws IOException { return new InputStreamReader( openAsInputStream( fileName ), charset ); }
@Override public Writer openAsWriter( File fileName, Charset charset, boolean append ) throws IOException { return new OutputStreamWriter( openAsOutputStream( fileName, append ), charset ); }
private void copyRecursively( Path source, Path target ) throws IOException { try ( DirectoryStream<Path> directoryStream = Files.newDirectoryStream( source ) ) { for ( Path sourcePath : directoryStream ) { Path targetPath = target.resolve( sourcePath.getFileName() ); if ( Files.isDirectory( sourcePath ) ) { Files.createDirectories( targetPath ); copyRecursively( sourcePath, targetPath ); } else { Files.copy( sourcePath, targetPath, REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES ); } } } }
@Override public Reader openAsReader( File fileName, Charset charset ) throws IOException { return new InputStreamReader( openAsInputStream( fileName ), charset ); }
@Override public Writer openAsWriter( File fileName, Charset charset, boolean append ) throws IOException { return new OutputStreamWriter( openAsOutputStream( fileName, append ), charset ); }
private void copyRecursively( Path source, Path target ) throws IOException { try ( DirectoryStream<Path> directoryStream = Files.newDirectoryStream( source ) ) { for ( Path sourcePath : directoryStream ) { Path targetPath = target.resolve( sourcePath.getFileName() ); if ( Files.isDirectory( sourcePath ) ) { Files.createDirectories( targetPath ); copyRecursively( sourcePath, targetPath ); } else { Files.copy( sourcePath, targetPath, REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES ); } } } }
@Override public long getFileSize( File fileName ) { try { return Files.size( path( fileName ) ); } catch ( IOException e ) { return 0; } }
@Override public void deleteRecursively( File directory ) throws IOException { if ( fileExists( directory ) ) { FileUtils.deletePathRecursively( path( directory ) ); } }
@Override public void copyRecursively( File fromDirectory, File toDirectory ) throws IOException { Path target = path( toDirectory ); Path source = path( fromDirectory ); copyRecursively( source, target ); }
@Override public StoreChannel create( File fileName ) throws IOException { return open( fileName, OpenMode.READ_WRITE ); }
@Override public void deleteFileOrThrow( File file ) throws IOException { Files.delete( path( file ) ); }
@Override public boolean mkdir( File fileName ) { if ( !fileExists( fileName ) ) { try { Files.createDirectory( path( fileName ) ); return true; } catch ( IOException ignore ) { } } return false; }
@Override public void mkdirs( File fileName ) throws IOException { Files.createDirectories( path( fileName ) ); }
@Override public void deleteRecursively( File directory ) throws IOException { if ( fileExists( directory ) ) { FileUtils.deletePathRecursively( path( directory ) ); } }