If your ZIP file creates additional directories, it breaks my workflow. When you use the Click on a directory in the GUI to ZIP method to create a ZIP file, this prepends the directory in the file name.
make clean zip hw3.zip *where 3 in this case represents the number of the homework.
$ unzip -v hw3.zip Archive: hw3.zip Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ---- 0 Stored 0 0% 2024-06-11 08:29 00000000 hw3/ 3259 Defl:N 1294 60% 2022-01-12 13:07 974ec9f9 hw3/loadtexbmp.c 4513 Defl:N 1719 62% 2023-06-14 18:33 5117802c hw3/hw3.c 342 Defl:N 220 36% 2024-06-06 08:09 c5378919 hw3/README 9981 Defl:N 3279 67% 2022-01-13 14:09 43213f5e hw3/loadobj.c 1044 Defl:N 541 48% 2024-06-06 08:09 6922b669 hw3/makefile 268 Defl:N 189 30% 2021-06-30 16:27 2f95bb35 hw3/fatal.c 271 Defl:N 207 24% 2021-06-30 16:29 3c1944fb hw3/errcheck.c 630 Defl:N 326 48% 2021-06-30 16:26 f1b38844 hw3/projection.c 1558 Defl:N 667 57% 2024-06-06 07:58 a0176a4c hw3/CSCIx229.h 603 Defl:N 393 35% 2021-06-30 16:29 9b7f14e6 hw3/print.c -------- ------- --- ------- 22469 8835 61% 11 filesIn this example, an extra directory named hw3 is created and all the files are extracted in that subdirectory. This is wrong and breaks my workflow.
apt-get install zip unzipor on MSYS do
pacman -S zip unzipThis will add the zip and unzip commands to create and unpack ZIP archives.
There are a number of other commands that will also create ZIP archives such as, for example 7z, but the syntax for these commands will be different.
zip hw3.zip *Most ZIP programs will be smart enough to not also match the name of the ZIP archive if it already exists. If your ZIP program is not smart enough to do that, place the ZIP file in the parent directory like this:
zip ../hw3.zip *This ZIP file will have the file names without the leading directory
$ unzip -v hw3.zip Archive: hw3.zip Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ---- 1558 Defl:N 667 57% 2024-06-06 07:58 a0176a4c CSCIx229.h 271 Defl:N 207 24% 2021-06-30 16:29 3c1944fb errcheck.c 268 Defl:N 189 30% 2021-06-30 16:27 2f95bb35 fatal.c 4513 Defl:N 1719 62% 2023-06-14 18:33 5117802c hw3.c 9981 Defl:N 3279 67% 2022-01-13 14:09 43213f5e loadobj.c 3259 Defl:N 1294 60% 2022-01-12 13:07 974ec9f9 loadtexbmp.c 1044 Defl:N 541 48% 2024-06-06 08:09 6922b669 makefile 603 Defl:N 393 35% 2021-06-30 16:29 9b7f14e6 print.c 630 Defl:N 326 48% 2021-06-30 16:26 f1b38844 projection.c 342 Defl:N 220 36% 2024-06-06 08:09 c5378919 README -------- ------- --- ------- 22469 8835 61% 10 filesNote that the ZIP archive does not contain any .o (object) or .a (archive) or executable files. These files will be specific to your OS and of no use to me. You can get rid of these files by running
make cleanwhich will remove these files. If you use Qt the command
make distcleanwill also get rid of the meta-objects and similar installation-specific stuff I cannot use.
In order to ZIP the contents of such subdirectories, the -r flag is required on the zip command. For example
zip -r hw3.zip *will result in a ZIP archive like this
$ unzip -v hw3.zip Archive: hw3.zip Length Method Size Cmpr Date Time CRC-32 Name -------- ------ ------- ---- ---------- ----- -------- ---- 1558 Defl:N 667 57% 2024-06-06 07:58 a0176a4c CSCIx229.h 271 Defl:N 207 24% 2021-06-30 16:29 3c1944fb errcheck.c 268 Defl:N 189 30% 2021-06-30 16:27 2f95bb35 fatal.c 11516 Defl:N 3440 70% 2023-10-12 16:33 b984a32e hw3.c 9981 Defl:N 3279 67% 2022-01-13 14:09 43213f5e loadobj.c 3259 Defl:N 1294 60% 2022-01-12 13:07 974ec9f9 loadtexbmp.c 1044 Defl:N 542 48% 2024-06-06 08:09 84e9e42e makefile 603 Defl:N 393 35% 2021-06-30 16:29 9b7f14e6 print.c 630 Defl:N 326 48% 2021-06-30 16:26 f1b38844 projection.c 646 Defl:N 314 51% 2024-06-06 08:09 e23eed05 README 0 Stored 0 0% 2024-06-11 09:17 00000000 textures/ 12342 Defl:N 1988 84% 2006-10-06 09:58 2d59ff1d textures/img2.bmp 12342 Defl:N 1090 91% 2006-10-06 09:59 e3c31ee4 textures/img4.bmp 196662 Defl:N 78512 60% 2006-10-05 21:03 c583d59a textures/crate.bmp 12342 Defl:N 2082 83% 2006-10-06 09:57 f2c6ee00 textures/img1.bmp 12342 Defl:N 1994 84% 2006-10-06 09:58 7ab35472 textures/img3.bmp 49206 Defl:N 15785 68% 2007-10-07 16:35 43fbecb8 textures/img5.bmp 12342 Defl:N 1688 86% 2006-10-06 09:59 c733bf9a textures/img6.bmp -------- ------- --- ------- 337354 113790 66% 18 files
To eliminate these kinds of work directories from the archive, you need to deliberately exclude them using the -x flag. For example,
zip -r hw3.zip * -x __MACOSX\*The backslash in the above command is important to prevent the shell from expanding the exclusion to match only the directory. Always check that the ZIP archive does not contain garbage from such subdirectories.