Creating ZIP files

When you upload an assignment to Canvas, it renames your ZIP file to include include your name and the assignment. My workflow use these additions to unpack your submission in a directory which is you name.

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.

TL;DR

In the direcory where you did the homework run the commands
make clean
zip hw3.zip *
where 3 in this case represents the number of the homework.

The GUI problem

When you view the ZIP file in the GUI, these extra directories are often hidden. However if you view the contents of the ZIP file using the command line utility, you will see that there is a leading directory on all the files.
$ 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 files
In 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.

Installing the command line tools

On OSX and Linux the command line tools are typically installed by default. If they are not, it is simple to install them using the package manager. For example, on Ubuntu do
apt-get install zip unzip
or on MSYS do
pacman -S zip unzip
This 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.

Creating a ZIP file from the command line

The GUI tools provided by OSX and Windows will always add this extra directory. The simplest way to create the appropriate format ZIP file is from the command line. Navigate to the directory in question and run the command
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 files
Note 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 clean
which will remove these files. If you use Qt the command
make distclean
will also get rid of the meta-objects and similar installation-specific stuff I cannot use.

Data subdirectories

It is acceptable to put files like textures or shaders or objects in subdirectories. Adding these subdirectories to reduce clutter in the base directory is fine, as long as the README, makefile and final executable unpacks in the base directory.

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

__MACOSX

Programs like Xcode create work directories that I do not need. For example, the __MACOSX directory contains numerous hidden files where the file name starts with a period.

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.