public static IVirtualFile rotate (IVirtualDirectory directory, String prefix, String extension, int maxRotations) {
for (int i=maxRotations; i>0; i--) {
IVirtualFile rotation = directory.getFile(getRotatedFileName(prefix, extension, i));
if (rotation != null) {
if (i == maxRotations) rotation.remove();
else rotation.rename(getRotatedFileName(prefix, extension, i+1));
}
}
return directory.getFile(getRotatedFileName(prefix, extension, 1), true);
}