/** * Copies a file from one directory to another. * * @param fs the {@link FileSystemAbstraction} the file exist on * @param fileName base filename of the file to move, not the complete path * @param fromDirectory directory currently containing filename * @param toDirectory directory to host filename * @throws IOException if the file couldn't be copied */ @Override public void perform( FileSystemAbstraction fs, String fileName, File fromDirectory, boolean skipNonExistentFromFile, File toDirectory, ExistingTargetStrategy existingTargetStrategy ) throws IOException { File fromFile = fromFile( fs, fromDirectory, fileName, skipNonExistentFromFile ); if ( fromFile != null ) { File toFile = toFile( fs, toDirectory, fileName, existingTargetStrategy ); if ( toFile != null ) { fs.copyFile( fromFile, toFile ); } } } },
@Override public void copyFile( File from, File to ) throws IOException { delegate.copyFile( from, to ); }
@Override public void copyFile( File from, File to ) throws IOException { fs.copyFile( from, to ); }
@Override public void copyFile( File from, File to ) throws IOException { adversary.injectFailure( SecurityException.class, FileNotFoundException.class, IOException.class ); delegate.copyFile( from, to ); }
@Override public void copyFile( File from, File to ) throws IOException { chooseFileSystem( from ).copyFile( from, to ); }
private File copyLabelIndexFile() throws IOException { DatabaseLayout databaseLayout = db.databaseLayout(); File labelIndexFileCopy = databaseLayout.file( "label_index_copy" ); db.restartDatabase( ( fs, directory ) -> fs.copyFile( databaseLayout.labelScanStore(), labelIndexFileCopy ) ); return labelIndexFileCopy; }
private void replaceLabelIndexWithCopy( File labelIndexFileCopy ) throws IOException { db.restartDatabase( ( fs, directory ) -> { DatabaseLayout databaseLayout = db.databaseLayout(); fs.deleteFile( databaseLayout.labelScanStore() ); fs.copyFile( labelIndexFileCopy, databaseLayout.labelScanStore() ); } ); }
/** * Copies a file from one directory to another. * * @param fs the {@link FileSystemAbstraction} the file exist on * @param fileName base filename of the file to move, not the complete path * @param fromDirectory directory currently containing filename * @param toDirectory directory to host filename * @throws IOException if the file couldn't be copied */ @Override public void perform( FileSystemAbstraction fs, String fileName, File fromDirectory, boolean skipNonExistentFromFile, File toDirectory, ExistingTargetStrategy existingTargetStrategy ) throws IOException { File fromFile = fromFile( fs, fromDirectory, fileName, skipNonExistentFromFile ); if ( fromFile != null ) { File toFile = toFile( fs, toDirectory, fileName, existingTargetStrategy ); if ( toFile != null ) { fs.copyFile( fromFile, toFile ); } } } },