@Override public IResourceReference backup(final IResourceReference resourceReference) throws IOException { if (!this.referenceHandler.exsits(resourceReference)) { return null; } try { final File file = this.referenceHandler.getFile(resourceReference); if (file.exists()) { final File backup = new File(file.getPath() + "~"); //$NON-NLS-1$ Files.move(file.toPath(), backup.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); if (!backup.exists()) { throw new IOException("Coudn't create backup file " + backup); //$NON-NLS-1$ } if (file.exists()) { throw new IOException("Coudn't delete file " + file); //$NON-NLS-1$ } } return null; } catch (final URISyntaxException exception) { throw new IOException(exception.getLocalizedMessage(), exception); } } }
@Override public IResourceReference backup(final IResourceReference resourceReference) throws IOException { if (!this.referenceHandler.exsits(resourceReference)) { return null; } try { final File file = this.referenceHandler.getFile(resourceReference); if (file.exists()) { final File backup = new File(file.getPath() + "~"); //$NON-NLS-1$ Files.move(file.toPath(), backup.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE); if (!backup.exists()) { throw new IOException("Coudn't create backup file " + backup); //$NON-NLS-1$ } if (file.exists()) { throw new IOException("Coudn't delete file " + file); //$NON-NLS-1$ } } return null; } catch (final URISyntaxException exception) { throw new IOException(exception.getLocalizedMessage(), exception); } } }