CS 355 - Systems Programming Lab 6 - implementing multicolumn ls
Objective: write a program that can print the names of files in the current directory in multiple columns.
- Write a C program myls2 whose behavior resembles that of the system command ls. myls2 must print the names of files in the current directory in columns of equal width. myls2 must accept the following parameters:
$ myls2 [-ars] [directory]
Overall behavior of myls2 is identical to that of myls1 described in lab5.
myls2 needs to present its output using multiple columns of the same width as shown below:
$ myls2 dirA
file0.txt file2.txt file5.txt file8.txt
file0a.txt file3.txt file6.txt file9.txt
file1.txt file4.txt file7.txt
$ myls2
file0a.txt file444444444a.txt file8a.txt
file1a.txt file5a.txt file9a.txt
file2a.txt file6a.txt
file3a.txt file7a.txt
Use the hint on p. 164 (Molay textbook) to determine the width of the current terminal window.
Test myls2 using the files with names of varying length archived in this ZIP file or with the files in dirA and dirA1 directories available on our github repository.
Use the following test cases when running myls1 from the directory at the same level with dirA and dirA1:
$ myls2
$ myls2 dirA
$ myls2 -as dirA
$ myls2 -r dirA1
Run each of the test cases above twice:
- in a relatively wide terminal window resulting in at least two rows of file names, and
- in a relatively narrow terminal window resulting in at least four rows of file names.
- A single C source code file with your work.
- Several screenshots (in PNG or JPG format) showing the results of executing all test cases listed above on a Linux terminal.