<<

SEng 265 — Introduction to Software Engineering Fall 2001 Assignment No. 4

Note 1 This assignment is to be done individually.

Note 2 Your assignment will be tested on aserver.

Due date: Nov. 16, 2001, at the beginning of the class.

This assignment is worth 20 points.

This assignment is worth 8% of your total course mark.

Clearly mark your lab section and student number on all submissions.

Objectives After completing this assignment, you will have:

learned the basics of perl and regular expressions.

Introduction I have a large library of mp3s on one of my linux boxes. Because I am the retentive type of person, I organize them in the following way:

For each I create a directory whose name is the name of the band.

Inside this directory I create one directory per each album that the band has released. The name of the directory starts with the year (4 digits number) in which it was released.

Finally, inside each album directory, I name each mp3 file with the number of the song in the album, and its title.

For example, the albums Boy (1980) of , and The Bends (1995) of Radiohead correspond to:

U2/1980_Boy/04_Into_the_Heart.mp3 U2/1980_Boy/01_I_will_follow.mp3 U2/1980_Boy/02_Twilight.mp3 U2/1980_Boy/03_An_Cat_Dubh.mp3 U2/1980_Boy/06_Stories_for_Boys_2.mp3 U2/1980_Boy/05_Out_of_Control_2.mp3 U2/1980_Boy/08_A_Day_without_Me.mp3 U2/1980_Boy/07_The_Ocean_2.mp3 U2/1980_Boy/09_Another_Time_Another_Place.mp3 U2/1980_Boy/10_Electric_Co_2.mp3 U2/1980_Boy/11_Shadows_and_Tall_Trees_2.mp3 Radiohead/1995_The_Bends/10_Black_Star.mp3 Radiohead/1995_The_Bends/08_MyIron_Lung.mp3 Radiohead/1995_The_Bends/04_Fake_Plastic_Trees.mp3 Radiohead/1995_The_Bends/05_Bones.mp3 Radiohead/1995_The_Bends/13_Killer_Cars.mp3 Radiohead/1995_The_Bends/03_High_and_Dry.mp3 Radiohead/1995_The_Bends/14_How_Can_You_Be_Sure.mp3

1 Radiohead/1995_The_Bends/01_Planet_Telex.mp3 Radiohead/1995_The_Bends/02_The_Bends.mp3 Radiohead/1995_The_Bends/07_Just.mp3 Radiohead/1995_The_Bends/11_Sulk.mp3 Radiohead/1995_The_Bends/06_Nice_Dream.mp3 Radiohead/1995_The_Bends/09_Bullet_Proof_I_Wish.mp3 Radiohead/1995_The_Bends/12_Street_Spirit.mp3

My collection is getting to the point where it is difficult to find what I want to play. For example, I’d like to say: show me all the songs from 1995. Or show me all the songs by in the 90’s. Or show me all the songs that include woman and women in their title.

Your task, should you choose to accept it I want you to write the command: abbey road. This is its man page: abbey_road(1)

NAME abbey_road - search for songs in a collection of mp3s

SYNOPSIS abbey_road [OPTIONS]... filename [PATTERN]

DESCRIPTION

Search for PATTERN in the title of a song in a collection of mp3 filenames of the format:

/_/_.mp3</p><p> filename file that contains the mp3s filenames.</p><p>PATTERN PATTERN is an optional valid perl regular expression. abbey_road will search for that pattern in the names of all the songs in the file. For example: You can search for ’wi[a-z]h’ (wi followed by any character, followed by h) and expect as output:</p><p>U2/1980_Boy/08_A_Day_without_Me.mp3 Radiohead/1995_The_Bends/09_Bullet_Proof_I_Wish.mp3</p><p>OPTIONS</p><p>--casesensitive By default abbey_road is case insensitive. This option forces the search to be case sensitive.</p><p>--band=PATTERN restric the search to the bands that match PATTERN</p><p>2 only. --band=’ˆu’ will search in bands whose name starts with a U (like U2). --band=who will restrict the search to bands that include ’who’ in their title: Guess Who, The Who.</p><p>--album=PATTERN restric the search to albums that match PATTERN only. --album=boy will search only songs from albums that include the string boy in their title</p><p>--year=PATTERN restric the search to years that match PATTERN only. --year=’199[5-7]’ will search only songs of albums that were released between 1995 and 1997.</p><p>--songnumber=NUMBER search only for a song which is number NUMBER in the album. --song=3 will search only for the third song in an album.</p><p>NOTES: Abbey_road does not read anything from standard input and writes its output to standard output. At the end it prints to standard error the number of matching songs, e.g.:</p><p>End of search. 1 song(s) matching.</p><p>Or:</p><p>End of search. No songs matching.</p><p>The search should be case insensitive unless otherwise specified.</p><p>Inside the mp3s collection file, underscores (_) are used instead of spaces. abbey_road takes this into account. For instance:</p><p> abbey_road --album=’the bends’ ’planet telex’</p><p> should output:</p><p>Radiohead/1995_The_Bends/01_Planet_Telex.mp3</p><p>EXAMPLES:</p><p>What is the fifth song of the album Boy:</p><p> abbey_road --album=’ˆBoy$’ --number=5 my_mp3s.txt</p><p>U2/1980_Boy/05_Out_of_Control_2.mp3</p><p>3 What songs were released in the 90’s whose title include the string ’be’:</p><p> abbey_road --year=’199[0-9]’ my_mp3s.txt be</p><p>Radiohead/1995_The_Bends/14_How_Can_You_Be_Sure.mp3 Radiohead/1995_The_Bends/02_The_Bends.mp3</p><p>AUTHOR Written by you.</p><p>REPORTING BUGS Report bugs to <you@uvic.ca>.</p><p>COPYRIGHT Copyright 2001 Your Name</p><p>Implementation Notes</p><p>The same option cannot appear more than once in the same command line. For instance, you cannot say:</p><p> abbey_road --album=’ˆBad$’ --number=3 --number=5 my_mp3s.txt</p><p>There are no restrictions on how to implement this command but you should use a reasonable amount of memory and CPU (less than 100 Mbytes to scan a 1000 songs file, and terminate within few seconds, for instance).</p><p>Your program can safely assume that all the input conforms to the expected format.</p><p>You should follow our C coding standards (where applicable). Any disparity or question will be resolved in the bulletin board.</p><p>You can find an example of an mp3 songs file from /home/seng265/assign4/mp3s.txt</p><p>What to submit</p><p>Submit your source code (abbey road) via CVS (see assignment 2) in the src directory of your module</p><p>At the start of the class on the deadline, hand in a printed copy of your cvs commit script as well as a hard copy of your source code file.</p><p>Remember, no line in your source code should exceed 80 characters long! and this assignment is to be done individually.</p><p>4</p> </div> </div> </div> </div> </div> </div> </div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js" integrity="sha512-aVKKRRi/Q/YV+4mjoKBsE4x3H+BkegoM/em46NNlCqNTmUYADjBbeNefNxYV7giUp0VxICtqdrbqU7iVaeZNXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="/js/details118.16.js"></script> <script> var sc_project = 11552861; var sc_invisible = 1; var sc_security = "b956b151"; </script> <script src="https://www.statcounter.com/counter/counter.js" async></script> <noscript><div class="statcounter"><a title="Web Analytics" href="http://statcounter.com/" target="_blank"><img class="statcounter" src="//c.statcounter.com/11552861/0/b956b151/1/" alt="Web Analytics"></a></div></noscript> </body> </html>