private static void deleteFile( Path path ) throws IOException { windowsSafeIOOperation( () -> Files.delete( path ) ); }
public static void truncateFile( SeekableByteChannel fileChannel, long position ) throws IOException { windowsSafeIOOperation( () -> fileChannel.truncate( position ) ); }
/** * Removes content of the lucene directory denoted by the given {@link File file}. This might seem unnecessary * since we cleanup the folder using {@link FileSystemAbstraction file system} but in fact for testing we often use * in-memory directories whose content can't be removed via the file system. * <p> * Uses {@link FileUtils#windowsSafeIOOperation(FileUtils.Operation)} underneath. * * @param folder the path to the directory to cleanup. * @throws IOException if removal operation fails. */ private void cleanupLuceneDirectory( File folder ) throws IOException { try ( Directory dir = directoryFactory.open( folder ) ) { String[] indexFiles = dir.listAll(); for ( String indexFile : indexFiles ) { FileUtils.windowsSafeIOOperation( () -> dir.deleteFile( indexFile ) ); } } } }
private static void deleteFile( Path path ) throws IOException { windowsSafeIOOperation( () -> Files.delete( path ) ); }
public static void truncateFile( SeekableByteChannel fileChannel, long position ) throws IOException { windowsSafeIOOperation( () -> fileChannel.truncate( position ) ); }