@Override
    public void rewind() throws IOException {
        super.rewind();
        for (int i = size - 1; i >= 0; i--) {
            File fi = getNumberedFileName(i);
            if (Files.exists(Util.fileToPath(fi))) {
                File next = getNumberedFileName(i + 1);
                Files.move(Util.fileToPath(fi), Util.fileToPath(next), StandardCopyOption.REPLACE_EXISTING);
            }
        }
    }
@Issue("JENKINS-16634")
    @Test
    public void deletedFolder() throws Exception {
        assumeFalse("Windows does not allow deleting a directory with a "
            + "file open, so this case should never occur", Functions.isWindows());
        File dir = tmp.newFolder("dir");
        File base = new File(dir, "x.log");
        RewindableRotatingFileOutputStream os = new RewindableRotatingFileOutputStream(base, 3);
        for (int i = 0; i < 2; i++) {
            FileUtils.deleteDirectory(dir);
            os.write('.');
            FileUtils.deleteDirectory(dir);
            os.write('.');
            FileUtils.deleteDirectory(dir);
            os.rewind();
        }
    }