|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 9-15
Link Here
|
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
| 10 |
* Francis Lynch (Wind River) - [301563] Save and load tree snapshots |
10 |
* Francis Lynch (Wind River) - [301563] Save and load tree snapshots |
| 11 |
* Francis Lynch (Wind River) - [305718] Allow reading snapshot into renamed project |
11 |
* Francis Lynch (Wind River) - [305718] Allow reading snapshot into renamed project |
| 12 |
* Broadcom Corporation - build configurations and references |
12 |
* Broadcom Corporation - ongoing development |
| 13 |
*******************************************************************************/ |
13 |
*******************************************************************************/ |
| 14 |
package org.eclipse.core.internal.resources; |
14 |
package org.eclipse.core.internal.resources; |
| 15 |
|
15 |
|
|
Lines 17-23
Link Here
|
| 17 |
import java.net.URI; |
17 |
import java.net.URI; |
| 18 |
import java.util.*; |
18 |
import java.util.*; |
| 19 |
import java.util.zip.*; |
19 |
import java.util.zip.*; |
| 20 |
import org.eclipse.core.filesystem.*; |
20 |
import org.eclipse.core.filesystem.EFS; |
|
|
21 |
import org.eclipse.core.filesystem.IFileStore; |
| 21 |
import org.eclipse.core.internal.events.*; |
22 |
import org.eclipse.core.internal.events.*; |
| 22 |
import org.eclipse.core.internal.localstore.*; |
23 |
import org.eclipse.core.internal.localstore.*; |
| 23 |
import org.eclipse.core.internal.utils.*; |
24 |
import org.eclipse.core.internal.utils.*; |
|
Lines 1201-1208
Link Here
|
| 1201 |
try { |
1202 |
try { |
| 1202 |
masterTable.store(output, "master table"); //$NON-NLS-1$ |
1203 |
masterTable.store(output, "master table"); //$NON-NLS-1$ |
| 1203 |
output.succeed(); |
1204 |
output.succeed(); |
| 1204 |
} finally { |
|
|
| 1205 |
output.close(); |
1205 |
output.close(); |
|
|
1206 |
} finally { |
| 1207 |
FileUtil.safeClose(output); |
| 1206 |
} |
1208 |
} |
| 1207 |
} catch (IOException e) { |
1209 |
} catch (IOException e) { |
| 1208 |
throw new ResourceException(IResourceStatus.INTERNAL_ERROR, null, NLS.bind(Messages.resources_exSaveMaster, location.toOSString()), e); |
1210 |
throw new ResourceException(IResourceStatus.INTERNAL_ERROR, null, NLS.bind(Messages.resources_exSaveMaster, location.toOSString()), e); |
|
Lines 1278-1285
Link Here
|
| 1278 |
try { |
1280 |
try { |
| 1279 |
output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); |
1281 |
output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); |
| 1280 |
writeTree(project, output, monitor); |
1282 |
writeTree(project, output, monitor); |
| 1281 |
} finally { |
|
|
| 1282 |
output.close(); |
1283 |
output.close(); |
|
|
1284 |
} finally { |
| 1285 |
FileUtil.safeClose(output); |
| 1283 |
} |
1286 |
} |
| 1284 |
OutputStream snapOut = store.openOutputStream(EFS.NONE, monitor); |
1287 |
OutputStream snapOut = store.openOutputStream(EFS.NONE, monitor); |
| 1285 |
out = new ZipOutputStream(snapOut); |
1288 |
out = new ZipOutputStream(snapOut); |
|
Lines 1295-1308
Link Here
|
| 1295 |
} |
1298 |
} |
| 1296 |
out.closeEntry(); |
1299 |
out.closeEntry(); |
| 1297 |
} finally { |
1300 |
} finally { |
| 1298 |
in.close(); |
1301 |
FileUtil.safeClose(in); |
| 1299 |
} |
1302 |
} |
|
|
1303 |
out.close(); |
| 1300 |
} catch (IOException e) { |
1304 |
} catch (IOException e) { |
| 1301 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, snapshotPath, Messages.resources_copyProblem, e); |
1305 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, snapshotPath, Messages.resources_copyProblem, e); |
| 1302 |
} finally { |
1306 |
} finally { |
| 1303 |
if (out!=null) { |
1307 |
FileUtil.safeClose(out); |
| 1304 |
try { out.close(); } catch (IOException e) { /*ignore*/ } |
|
|
| 1305 |
} |
| 1306 |
if (tmpTree!=null) tmpTree.delete(); |
1308 |
if (tmpTree!=null) tmpTree.delete(); |
| 1307 |
} |
1309 |
} |
| 1308 |
} |
1310 |
} |
|
Lines 1322-1329
Link Here
|
| 1322 |
try { |
1324 |
try { |
| 1323 |
output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); |
1325 |
output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); |
| 1324 |
writeTree(computeStatesToSave(contexts, workspace.getElementTree()), output, monitor); |
1326 |
writeTree(computeStatesToSave(contexts, workspace.getElementTree()), output, monitor); |
| 1325 |
} finally { |
|
|
| 1326 |
output.close(); |
1327 |
output.close(); |
|
|
1328 |
} finally { |
| 1329 |
FileUtil.safeClose(output); |
| 1327 |
} |
1330 |
} |
| 1328 |
} catch (Exception e) { |
1331 |
} catch (Exception e) { |
| 1329 |
String msg = NLS.bind(Messages.resources_writeWorkspaceMeta, treeLocation); |
1332 |
String msg = NLS.bind(Messages.resources_writeWorkspaceMeta, treeLocation); |
|
Lines 1549-1560
Link Here
|
| 1549 |
if (root.getType() != IResource.ROOT) |
1552 |
if (root.getType() != IResource.ROOT) |
| 1550 |
o2 = new DataOutputStream(new SafeFileOutputStream(syncInfoLocation.toOSString(), syncInfoTempLocation.toOSString())); |
1553 |
o2 = new DataOutputStream(new SafeFileOutputStream(syncInfoLocation.toOSString(), syncInfoTempLocation.toOSString())); |
| 1551 |
} catch (IOException e) { |
1554 |
} catch (IOException e) { |
| 1552 |
if (o1 != null) |
1555 |
FileUtil.safeClose(o1); |
| 1553 |
try { |
|
|
| 1554 |
o1.close(); |
| 1555 |
} catch (IOException e2) { |
| 1556 |
// ignore |
| 1557 |
} |
| 1558 |
message = NLS.bind(Messages.resources_writeMeta, root.getFullPath()); |
1556 |
message = NLS.bind(Messages.resources_writeMeta, root.getFullPath()); |
| 1559 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, root.getFullPath(), message, e); |
1557 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, root.getFullPath(), message, e); |
| 1560 |
} |
1558 |
} |
|
Lines 1610-1617
Link Here
|
| 1610 |
removeGarbage(markersOutput, markersLocation, markersTempLocation); |
1608 |
removeGarbage(markersOutput, markersLocation, markersTempLocation); |
| 1611 |
// if we have the workspace root the output stream will be null and we |
1609 |
// if we have the workspace root the output stream will be null and we |
| 1612 |
// don't have to perform cleanup code |
1610 |
// don't have to perform cleanup code |
| 1613 |
if (syncInfoOutput != null) |
1611 |
if (syncInfoOutput != null) { |
| 1614 |
removeGarbage(syncInfoOutput, syncInfoLocation, syncInfoTempLocation); |
1612 |
removeGarbage(syncInfoOutput, syncInfoLocation, syncInfoTempLocation); |
|
|
1613 |
syncInfoOutput.close(); |
| 1614 |
} |
| 1615 |
markersOutput.close(); |
| 1615 |
} catch (IOException e) { |
1616 |
} catch (IOException e) { |
| 1616 |
message = NLS.bind(Messages.resources_writeMeta, root.getFullPath()); |
1617 |
message = NLS.bind(Messages.resources_writeMeta, root.getFullPath()); |
| 1617 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, root.getFullPath(), message, e); |
1618 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, root.getFullPath(), message, e); |
|
Lines 1719-1726
Link Here
|
| 1719 |
System.out.println("Snap SyncInfo for " + root.getFullPath() + ": " + snapTimes[1] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
1720 |
System.out.println("Snap SyncInfo for " + root.getFullPath() + ": " + snapTimes[1] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| 1720 |
if (markerFileSize != markersOutput.size()) |
1721 |
if (markerFileSize != markersOutput.size()) |
| 1721 |
safeMarkerStream.succeed(); |
1722 |
safeMarkerStream.succeed(); |
| 1722 |
if (safeSyncInfoStream != null && syncInfoFileSize != syncInfoOutput.size()) |
1723 |
if (safeSyncInfoStream != null && syncInfoFileSize != syncInfoOutput.size()) { |
| 1723 |
safeSyncInfoStream.succeed(); |
1724 |
safeSyncInfoStream.succeed(); |
|
|
1725 |
syncInfoOutput.close(); |
| 1726 |
} |
| 1727 |
markersOutput.close(); |
| 1724 |
} catch (IOException e) { |
1728 |
} catch (IOException e) { |
| 1725 |
message = NLS.bind(Messages.resources_writeMeta, root.getFullPath()); |
1729 |
message = NLS.bind(Messages.resources_writeMeta, root.getFullPath()); |
| 1726 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, root.getFullPath(), message, e); |
1730 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, root.getFullPath(), message, e); |
|
Lines 1969-1977
Link Here
|
| 1969 |
output.writeUTF((String) it.next()); |
1973 |
output.writeUTF((String) it.next()); |
| 1970 |
for (Iterator it = additionalConfigNames.iterator(); it.hasNext();) |
1974 |
for (Iterator it = additionalConfigNames.iterator(); it.hasNext();) |
| 1971 |
output.writeUTF((String) it.next()); |
1975 |
output.writeUTF((String) it.next()); |
|
|
1976 |
output.close(); |
| 1972 |
} finally { |
1977 |
} finally { |
| 1973 |
if (output != null) |
1978 |
FileUtil.safeClose(output); |
| 1974 |
output.close(); |
|
|
| 1975 |
if (!wasImmutable) |
1979 |
if (!wasImmutable) |
| 1976 |
workspace.newWorkingTree(); |
1980 |
workspace.newWorkingTree(); |
| 1977 |
} |
1981 |
} |
|
Lines 1990-1997
Link Here
|
| 1990 |
DataOutputStream output = new DataOutputStream(safe); |
1994 |
DataOutputStream output = new DataOutputStream(safe); |
| 1991 |
output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); |
1995 |
output.writeInt(ICoreConstants.WORKSPACE_TREE_VERSION_2); |
| 1992 |
writeTree(project, output, null); |
1996 |
writeTree(project, output, null); |
| 1993 |
} finally { |
|
|
| 1994 |
safe.close(); |
1997 |
safe.close(); |
|
|
1998 |
} finally { |
| 1999 |
FileUtil.safeClose(safe); |
| 1995 |
} |
2000 |
} |
| 1996 |
} catch (IOException e) { |
2001 |
} catch (IOException e) { |
| 1997 |
String msg = NLS.bind(Messages.resources_writeMeta, project.getFullPath()); |
2002 |
String msg = NLS.bind(Messages.resources_writeMeta, project.getFullPath()); |