Lines 11-27
Link Here
|
11 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
12 |
package org.eclipse.core.internal.resources; |
12 |
package org.eclipse.core.internal.resources; |
13 |
|
13 |
|
14 |
import org.eclipse.core.runtime.OperationCanceledException; |
|
|
15 |
|
16 |
import org.eclipse.core.filesystem.IFileStore; |
17 |
|
18 |
import org.eclipse.core.filesystem.EFS; |
19 |
|
20 |
import java.net.URI; |
21 |
|
22 |
import java.io.*; |
14 |
import java.io.*; |
|
|
15 |
import java.net.URI; |
23 |
import java.util.*; |
16 |
import java.util.*; |
24 |
import java.util.zip.*; |
17 |
import java.util.zip.ZipOutputStream; |
|
|
18 |
import org.eclipse.core.filesystem.EFS; |
19 |
import org.eclipse.core.filesystem.IFileStore; |
25 |
import org.eclipse.core.internal.events.*; |
20 |
import org.eclipse.core.internal.events.*; |
26 |
import org.eclipse.core.internal.localstore.*; |
21 |
import org.eclipse.core.internal.localstore.*; |
27 |
import org.eclipse.core.internal.utils.*; |
22 |
import org.eclipse.core.internal.utils.*; |
Lines 725-736
Link Here
|
725 |
* and <code>false</code> if the refresh snapshot was not found or could not be opened. |
720 |
* and <code>false</code> if the refresh snapshot was not found or could not be opened. |
726 |
* @exception CoreException if an error occurred reading the snapshot file. |
721 |
* @exception CoreException if an error occurred reading the snapshot file. |
727 |
*/ |
722 |
*/ |
728 |
protected boolean restoreFromRefreshSnapshot(Project project, |
723 |
protected boolean restoreFromRefreshSnapshot(Project project, URI snapshotLocation, |
729 |
IProgressMonitor monitor) throws CoreException { |
724 |
IProgressMonitor monitor) throws CoreException { |
730 |
boolean status = true; |
725 |
boolean status = true; |
731 |
IPath snapshotPath = workspace.getMetaArea().getRefreshLocationFor(project); |
726 |
//IPath snapshotPath = workspace.getMetaArea().getRefreshLocationFor(project); |
732 |
java.io.File snapshotFile = snapshotPath.toFile(); |
727 |
//java.io.File snapshotFile = snapshotPath.toFile(); |
733 |
if (!snapshotFile.exists()) |
728 |
if (snapshotLocation==null) { |
|
|
729 |
return false; |
730 |
} |
731 |
java.io.File snapshotFile = EFS.getStore(snapshotLocation).toLocalFile(EFS.NONE, null); |
732 |
if (snapshotFile==null || !snapshotFile.exists()) |
734 |
return false; |
733 |
return false; |
735 |
if (Policy.DEBUG_RESTORE) |
734 |
if (Policy.DEBUG_RESTORE) |
736 |
System.out.println("Restore project " + project.getFullPath() + ": starting..."); //$NON-NLS-1$ //$NON-NLS-2$ |
735 |
System.out.println("Restore project " + project.getFullPath() + ": starting..."); //$NON-NLS-1$ //$NON-NLS-2$ |
Lines 1031-1049
Link Here
|
1031 |
try { |
1030 |
try { |
1032 |
monitor.beginTask("", Policy.totalWork); //$NON-NLS-1$ |
1031 |
monitor.beginTask("", Policy.totalWork); //$NON-NLS-1$ |
1033 |
InputStream snapIn = new FileInputStream(snapshotFile); |
1032 |
InputStream snapIn = new FileInputStream(snapshotFile); |
1034 |
ZipInputStream zip = new ZipInputStream(snapIn); |
1033 |
//ZipInputStream zip = new ZipInputStream(snapIn); |
1035 |
ZipEntry treeEntry = zip.getNextEntry(); |
1034 |
//ZipEntry treeEntry = zip.getNextEntry(); |
1036 |
if (treeEntry == null || !treeEntry.getName().equals("resource-index.tree")) { //$NON-NLS-1$ |
1035 |
//if (treeEntry == null || !treeEntry.getName().equals("resource-index.tree")) { //$NON-NLS-1$ |
1037 |
zip.close(); |
1036 |
// zip.close(); |
1038 |
return false; |
1037 |
// return false; |
1039 |
} |
1038 |
//} |
1040 |
DataInputStream input = new DataInputStream(zip); |
1039 |
DataInputStream input = new DataInputStream(snapIn); |
1041 |
try { |
1040 |
try { |
1042 |
WorkspaceTreeReader reader = WorkspaceTreeReader.getReader(workspace, input.readInt()); |
1041 |
WorkspaceTreeReader reader = WorkspaceTreeReader.getReader(workspace, input.readInt()); |
1043 |
reader.readTree(project, input, Policy.subMonitorFor(monitor, Policy.totalWork)); |
1042 |
reader.readTree(project, input, Policy.subMonitorFor(monitor, Policy.totalWork)); |
1044 |
} finally { |
1043 |
} finally { |
1045 |
input.close(); |
1044 |
input.close(); |
1046 |
zip.close(); |
1045 |
snapIn.close(); |
1047 |
} |
1046 |
} |
1048 |
} catch (IOException e) { |
1047 |
} catch (IOException e) { |
1049 |
snapshotPath = new Path(snapshotFile.getPath()); |
1048 |
snapshotPath = new Path(snapshotFile.getPath()); |
Lines 1278-1297
Link Here
|
1278 |
output.close(); |
1277 |
output.close(); |
1279 |
} |
1278 |
} |
1280 |
OutputStream snapOut = store.openOutputStream(EFS.NONE, monitor); |
1279 |
OutputStream snapOut = store.openOutputStream(EFS.NONE, monitor); |
1281 |
out = new ZipOutputStream(snapOut); |
1280 |
//out = new ZipOutputStream(snapOut); |
1282 |
out.setLevel(Deflater.BEST_COMPRESSION); |
1281 |
//out.setLevel(Deflater.BEST_COMPRESSION); |
1283 |
ZipEntry e = new ZipEntry("resource-index.tree"); //$NON-NLS-1$ |
1282 |
//ZipEntry e = new ZipEntry("resource-index.tree"); //$NON-NLS-1$ |
1284 |
out.putNextEntry(e); |
1283 |
//out.putNextEntry(e); |
1285 |
int read = 0; |
1284 |
int read = 0; |
1286 |
byte[] buffer = new byte[4096]; |
1285 |
byte[] buffer = new byte[4096]; |
1287 |
InputStream in = new FileInputStream(tmpTree); |
1286 |
InputStream in = new FileInputStream(tmpTree); |
1288 |
try { |
1287 |
try { |
1289 |
while ((read = in.read(buffer)) >= 0) { |
1288 |
while ((read = in.read(buffer)) >= 0) { |
1290 |
out.write(buffer, 0, read); |
1289 |
snapOut.write(buffer, 0, read); |
1291 |
} |
1290 |
} |
1292 |
out.closeEntry(); |
1291 |
//out.closeEntry(); |
1293 |
} finally { |
1292 |
} finally { |
1294 |
in.close(); |
1293 |
in.close(); |
|
|
1294 |
snapOut.close(); |
1295 |
} |
1295 |
} |
1296 |
} catch (IOException e) { |
1296 |
} catch (IOException e) { |
1297 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, snapshotPath, Messages.resources_copyProblem, e); |
1297 |
throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, snapshotPath, Messages.resources_copyProblem, e); |