Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 137765 Details for
Bug 278402
[Import/Export] Export project does not export empty folders
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Export wizard patch v1
bug278402-patch-v1.txt (text/plain), 15.43 KB, created by
Remy Suen
on 2009-05-30 21:32:56 EDT
(
hide
)
Description:
Export wizard patch v1
Filename:
MIME Type:
Creator:
Remy Suen
Created:
2009-05-30 21:32:56 EDT
Size:
15.43 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.ide >Index: src/org/eclipse/ui/internal/wizards/datatransfer/IFileExporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/IFileExporter.java,v >retrieving revision 1.4 >diff -u -r1.4 IFileExporter.java >--- src/org/eclipse/ui/internal/wizards/datatransfer/IFileExporter.java 16 Mar 2007 18:00:47 -0000 1.4 >+++ src/org/eclipse/ui/internal/wizards/datatransfer/IFileExporter.java 31 May 2009 01:29:56 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2004, 2006 IBM Corporation and others. >+ * Copyright (c) 2004, 2009 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 >@@ -12,6 +12,7 @@ > > import java.io.IOException; > >+import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.CoreException; > >@@ -32,6 +33,16 @@ > public void finished() throws IOException; > > /** >+ * Write the entry for the folder's name into the current archive. >+ * >+ * @param container the container to write >+ * @param destinationPath the path that will be used in the archive >+ * @throws IOException if an IO error occurs while writing the folder entry >+ */ >+ public void write(IContainer container, String destinationPath) >+ throws IOException; >+ >+ /** > * Write the passed resource to the current archive > * > * @param resource >Index: src/org/eclipse/ui/internal/wizards/datatransfer/ZipFileExporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ZipFileExporter.java,v >retrieving revision 1.7 >diff -u -r1.7 ZipFileExporter.java >--- src/org/eclipse/ui/internal/wizards/datatransfer/ZipFileExporter.java 8 May 2006 20:54:13 -0000 1.7 >+++ src/org/eclipse/ui/internal/wizards/datatransfer/ZipFileExporter.java 31 May 2009 01:29:56 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -17,6 +17,7 @@ > import java.util.zip.ZipEntry; > import java.util.zip.ZipOutputStream; > >+import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.CoreException; > >@@ -99,6 +100,12 @@ > outputStream.closeEntry(); > } > >+ public void write(IContainer container, String destinationPath) >+ throws IOException { >+ ZipEntry newEntry = new ZipEntry(destinationPath); >+ outputStream.putNextEntry(newEntry); >+ } >+ > /** > * Write the passed resource to the current archive. > * >Index: src/org/eclipse/ui/internal/wizards/datatransfer/TarFileExporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarFileExporter.java,v >retrieving revision 1.11 >diff -u -r1.11 TarFileExporter.java >--- src/org/eclipse/ui/internal/wizards/datatransfer/TarFileExporter.java 28 May 2007 13:17:35 -0000 1.11 >+++ src/org/eclipse/ui/internal/wizards/datatransfer/TarFileExporter.java 31 May 2009 01:29:56 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -19,6 +19,7 @@ > import java.util.zip.GZIPOutputStream; > > import org.eclipse.core.filesystem.EFS; >+import org.eclipse.core.resources.IContainer; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.IResource; > import org.eclipse.core.resources.ResourceAttributes; >@@ -95,6 +96,23 @@ > outputStream.closeEntry(); > } > >+ public void write(IContainer container, String destinationPath) >+ throws IOException { >+ TarEntry newEntry = new TarEntry(destinationPath); >+ if(container.getLocalTimeStamp() != IResource.NULL_STAMP) { >+ newEntry.setTime(container.getLocalTimeStamp() / 1000); >+ } >+ ResourceAttributes attributes = container.getResourceAttributes(); >+ if (attributes != null && attributes.isExecutable()) { >+ newEntry.setMode(newEntry.getMode() | 0111); >+ } >+ if (attributes != null && attributes.isReadOnly()) { >+ newEntry.setMode(newEntry.getMode() & ~0222); >+ } >+ newEntry.setFileType(TarEntry.DIRECTORY); >+ outputStream.putNextEntry(newEntry); >+ } >+ > /** > * Write the passed resource to the current archive. > * >Index: src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java,v >retrieving revision 1.7 >diff -u -r1.7 ArchiveFileExportOperation.java >--- src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java 20 Jun 2006 17:19:02 -0000 1.7 >+++ src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java 31 May 2009 01:29:56 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 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 >@@ -162,6 +162,22 @@ > throws InterruptedException { > exportResource(exportResource, 1); > } >+ >+ /** >+ * Creates and returns the string that should be used as the name of the entry in the archive. >+ * >+ * @param exportResource the resource to export >+ * @param leadupDepth the number of resource levels to be included in the path including the resourse itself. >+ * @since 3.6 >+ */ >+ private String createDestinationName(int leadupDepth, IResource exportResource) { >+ IPath fullPath = exportResource.getFullPath(); >+ if (createLeadupStructure) { >+ return fullPath.makeRelative().toString(); >+ } >+ return fullPath.removeFirstSegments( >+ fullPath.segmentCount() - leadupDepth).toString(); >+ } > > /** > * Export the passed resource to the destination .zip >@@ -177,14 +193,7 @@ > } > > if (exportResource.getType() == IResource.FILE) { >- String destinationName; >- IPath fullPath = exportResource.getFullPath(); >- if (createLeadupStructure) { >- destinationName = fullPath.makeRelative().toString(); >- } else { >- destinationName = fullPath.removeFirstSegments( >- fullPath.segmentCount() - leadupDepth).toString(); >- } >+ String destinationName = createDestinationName(leadupDepth, exportResource); > monitor.subTask(destinationName); > > try { >@@ -198,6 +207,15 @@ > monitor.worked(1); > ModalContext.checkCanceled(monitor); > } else { >+ // create an entry for ourselves, see bug 278402 >+ String destinationName = createDestinationName(leadupDepth, exportResource); >+ >+ try { >+ exporter.write((IContainer) exportResource, destinationName + java.io.File.separator); >+ } catch (IOException e) { >+ addError(NLS.bind(DataTransferMessages.DataTransfer_errorExporting, exportResource.getFullPath().makeRelative(), e.getMessage()), e); >+ } >+ > IResource[] children = null; > > try { >#P org.eclipse.ui.tests >Index: Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ExportArchiveFileOperationTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ExportArchiveFileOperationTest.java,v >retrieving revision 1.4 >diff -u -r1.4 ExportArchiveFileOperationTest.java >--- Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ExportArchiveFileOperationTest.java 8 Sep 2006 20:47:10 -0000 1.4 >+++ Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ExportArchiveFileOperationTest.java 31 May 2009 01:29:57 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2006 IBM Corporation and others. >+ * Copyright (c) 2005, 2009 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 >@@ -47,6 +47,7 @@ > private static final String ZIP_FILE_EXT = "zip"; > private static final String TAR_FILE_EXT = "tar"; > private static final String[] directoryNames = { "dir1", "dir2" }; >+ private static final String[] emptyDirectoryNames = { "dir3" }; > private static final String[] fileNames = { "file1.txt", "file2.txt" }; > > private String localDirectory; >@@ -84,9 +85,9 @@ > > operation.setUseCompression(false); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > >- verifyFolders(directoryNames.length, ZIP_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); > > } > >@@ -99,7 +100,7 @@ > > operation.setUseCompression(true); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > verifyCompressed(ZIP_FILE_EXT); > } > >@@ -123,9 +124,9 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(false); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > flattenPaths = true; >- verifyFolders(directoryNames.length, ZIP_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); > } > > public void testExportZipCreateSelectedDirectoriesWithFolders() throws Exception { >@@ -142,9 +143,9 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(false); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > excludeProjectPath = true; >- verifyFolders(directoryNames.length, ZIP_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); > } > > public void testExportZipCreateSelectedDirectoriesCompressed() throws Exception { >@@ -167,10 +168,10 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(true); > operation.setUseTarFormat(false); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > flattenPaths = true; > verifyCompressed(ZIP_FILE_EXT); >- verifyFolders(directoryNames.length, ZIP_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); > } > > public void testExportTar() throws Exception { >@@ -182,9 +183,9 @@ > operation.setUseTarFormat(true); > operation.setUseCompression(false); > >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > >- verifyFolders(directoryNames.length, TAR_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); > } > > public void testExportTarCompressed() throws Exception { >@@ -196,7 +197,7 @@ > > operation.setUseTarFormat(true); > operation.setUseCompression(true); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > verifyCompressed(TAR_FILE_EXT); > } > >@@ -220,9 +221,9 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(false); > operation.setUseTarFormat(true); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > flattenPaths = true; >- verifyFolders(directoryNames.length, TAR_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); > } > > public void testExportTarCreateSelectedDirectoriesWithFolders() throws Exception { >@@ -239,9 +240,9 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(false); > operation.setUseTarFormat(true); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > excludeProjectPath = true; >- verifyFolders(directoryNames.length, TAR_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); > > } > >@@ -265,10 +266,10 @@ > operation.setCreateLeadupStructure(false); > operation.setUseCompression(true); > operation.setUseTarFormat(true); >- openTestWindow().run(true, true, operation); >+ operation.run(new NullProgressMonitor()); > flattenPaths = true; > verifyCompressed(TAR_FILE_EXT); >- verifyFolders(directoryNames.length, TAR_FILE_EXT); >+ verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); > > } > >@@ -324,6 +325,12 @@ > true, new NullProgressMonitor()); > } > } >+ >+ // create empty folders to test bug 278402 >+ for(int i = 0; i < emptyDirectoryNames.length; i++){ >+ IFolder folder = project.getFolder(emptyDirectoryNames[i]); >+ folder.create(false, true, new NullProgressMonitor()); >+ } > } > catch(Exception e){ > fail(e.toString()); >@@ -405,7 +412,10 @@ > int idx = entryName.lastIndexOf("/"); > String folderPath = entryName.substring(0, idx); > String fileName = entryName.substring(idx+1, entryName.length()); >- files.add(fileName); >+ // we get empty strings for folder entries, don't add them as a file name >+ if (fileName.length() != 0) { >+ files.add(fileName); >+ } > int idx2 = folderPath.lastIndexOf("/"); > if (idx2 != -1){ > String folderName = folderPath.substring(idx2 + 1, folderPath.length()); >@@ -461,15 +471,15 @@ > if (directoryNames[i].equals(name)) > return true; > } >+ for (int i = 0; i < emptyDirectoryNames.length; i++){ >+ if (emptyDirectoryNames[i].equals(name)) >+ return true; >+ } > return false; > } > > private boolean isDirectory(IResource resource){ >- for (int i = 0; i < directoryNames.length; i++){ >- if (directoryNames[i].equals(resource.getName())) >- return true; >- } >- return false; >+ return isDirectory(resource.getName()); > } > > private boolean isFile(IResource resource){
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 278402
:
137765
|
149468
|
188350
|
192850