Bug 208672 - [Import/Export] Export to archive doesn't include empty directories
Summary: [Import/Export] Export to archive doesn't include empty directories
Status: RESOLVED DUPLICATE of bug 278402
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Tod Creasey CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2007-11-03 11:35 EDT by Alex Chapiro CLA
Modified: 2009-06-01 08:52 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Chapiro CLA 2007-11-03 11:35:21 EDT
Build ID: M20070921-1145

Steps To Reproduce:
1. Create empty directory in any project.
2. Export this project to archive. In wizard tree open this project node to confirm that this directory checked to copy to archive.
3. Open zip file - there is no this directory.




More information:
If you use external archiver, empty directories will be created
Comment 1 Tod Creasey CLA 2007-11-05 11:24:43 EST
How are you opening the zip file? Winzip may not show what is created by the java zip API.

If you export and then import back in again and have data loss then there is an issue
Comment 2 Alex Chapiro CLA 2007-11-05 11:54:21 EST
I used Total Commander. 
1) I packed this project using TC, then opened it using TC. I saw empty folders.
2) I packed this project using export feature and didn't see empty directories in the archive.
If you go to implementation (class ArchiveFileExportOperation, recursive method exportResource, it's getting clear why it happened: 

            IResource[] children = null;

            try {
                children = ((IContainer) exportResource).members();
            } catch (CoreException e) {
                // this should never happen because an #isAccessible check is done before #members is invoked
                addError(NLS.bind(DataTransferMessages.DataTransfer_errorExporting, exportResource.getFullPath()), e);
            }
// AC note: for empty container children.length == 0 ! It does  nothing for empty container
            for (int i = 0; i < children.length; i++) {
            exportResource(children[i], leadupDepth + 1);
         }
Comment 3 Tod Creasey CLA 2007-11-05 15:51:57 EST
Not all zip formats are the same. it is only valid if you use something that uses the java.util.Zip on both sides.
Comment 4 Alex Chapiro CLA 2007-11-05 16:25:49 EST
I expect consistency from Eclipse. If I open project node (left panel in Export Wizard) , I see that empty directory is checked. That's why I expect to see it in archive.
Comment 5 Tod Creasey CLA 2007-11-05 16:42:59 EST
Alex I think you misunderstand. We use the java.util.Zip API. Checking the results in a tool that doesn't may not give you a correct picture of the situation. WinZip for instance will filter out empty directories in some versions.

Of course I could have saved us all of this chat by checking <grin> and indeed they are not getting imported.
Comment 6 Alex Chapiro CLA 2007-11-05 17:12:50 EST
Oh, its up to you, you can fix the problem or ignore it. At last, I have a workaround.
I just have to mention that the idea there are utilities that do not save empty directories, and winzip is one of them, is not correct. Or maybe such program exists (definitely: Eclipse is one of them), but this is not winzip. This one saves in archive empty directories, but does not show them. However, you can see them using another viewers, and you can extract them later. See for example http://britishinside.com/archive/2007/06/18/Zip-files-and-hidden-folders.aspx :

ANSWER FROM WINZIP: "The empty folder name entries are normally not displayed in the WinZip window for cosmetic reasons, but Using Microsoft's 'regedit' utility from the 'run' option of the start menu will allow you to add a key to the registry to display the foldernames in the WinZip window. Locate the Key:

HKEY_CURRENT_USER\Software\Nico Mak Computing\WinZip\WinZip

The 'string value' key 'ShowDirEntries' can be added, and then set to '1'; This will display the empty folder entries in the WinZip window."
Comment 7 Prakash Rangaraj CLA 2009-06-01 08:52:46 EDT

*** This bug has been marked as a duplicate of bug 278402 ***