1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-03 07:05:24 +02:00

[367424] [dstore] upload mechanism should provide backups of files

This commit is contained in:
David McKnight 2011-12-23 16:58:41 +00:00
parent 0f73384cd4
commit b9b1c246f5

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2002, 2009 IBM Corporation and others.
* Copyright (c) 2002, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -14,6 +14,7 @@
* Contributors:
* David McKnight (IBM) [224906] [dstore] changes for getting properties and doing exit due to single-process capability
* David McKnight (IBM) [281712] [dstore] Warning message is needed when disk is full
* David McKnight (IBM) [367424] [dstore] upload mechanism should provide backups of files
*******************************************************************************/
package org.eclipse.dstore.core.model;
@ -22,6 +23,8 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import org.eclipse.dstore.internal.core.model.IDataStoreSystemProperties;
/**
* <p>
* The ByteStreamHandler class is used to abstract file read and write operations
@ -86,9 +89,15 @@ public class ByteStreamHandler implements IByteStreamHandler
}
else
{
// backup file on upload by default
String doBackups = System.getProperty("backupfiles"); //$NON-NLS-1$
if (doBackups == null || doBackups.equals("true")){ //$NON-NLS-1$
// backup the file first
file.renameTo(new File(fileName+"~")); //$NON-NLS-1$
}
}
File newFile = new File(fileName);
File newFile = new File(fileName);
FileOutputStream fileStream = new FileOutputStream(newFile);
if (binary)