GNOME Bugzilla – Bug 463235
Can't add an empty directory with --add option
Last modified: 2007-08-07 06:14:08 UTC
Steps to reproduce: 1. Start with the following file structure - EmptyDir (empty) - NotEmptyDir - File1.txt - File2.txt - EmptyDir2 (empty) 2. Highlight (in Nautilus) "EmptyDir" and "NotEmptyDir" 3. Right-click and select "Create archive..." 4. Name the archive "EmptyTest.zip" and press "Create" nautilus-file-roller starts file-roller with this command: file-roller --default-dir='/home/boyd/Desktop' --add '/home/boyd/Desktop/EmptyDir' '/home/boyd/Desktop/NotEmptyDir' The EmptyTest.zip file is created with the following entries (notice that "EmptyDir" is *not* included: /NotEmptyDir/File1.txt /NotEmptyDir/File2.txt /NotEmptyDir/EmptyDir2 I've been trying to track this one down without much success. I'm guessing the problem is somewhere in src/file-list.c. Can anyone give me a quick fix on this or point me in the right direction for what code I should look into?
Taking a quick look at the code you can try to set the property propAddCanStoreFolders to TRUE for fr-command-zip (the fr_command_init function in fr-command-zip.c) and then change the vd_path_list_done_cb function in src/file-list.c adding the visited folder to the list of files (vdd->files) if the folder was empty (pld->files and pld->dir are empty).
Created attachment 93073 [details] [review] Include empty top-level directory in archive. Thanks Paolo for the suggestion! This patch works at least using EXE and tar.gz types. I haven't had the time to test every single combination. I had to add checks to make sure that the path contains no children (pld->files == null && pld->dirs == NULL) and also that it was a top-level directory. I'm not sure if this is the most elegant way to go about fixing it, but this seems to work. I added the test/addition before pld->files and pld->dirs gets nulled out. I'm open to suggestions.
I've committed a change to svn trunk in which the base_dir is added to vdd->files in the visit_dir_async() function, it's also added to vdd->dirnames to prevent to add the directory more then once. This seems to work for me, can you test it please?
(In reply to comment #3) > I've committed a change to svn trunk in which the base_dir is added to > vdd->files in the visit_dir_async() function, it's also added to vdd->dirnames > to prevent to add the directory more then once. > > This seems to work for me, can you test it please? > Works great! Thanks for the help on this one.