Purpose of the Assignment
The general purpose of this assignment is to develop some simple?C++ utilities for the?, given a number of requirements, making use of the principles and techniques discussed throughout the course. This assignment is designed to give you experience in:
- object-oriented programming using C++, using basic language constructs, classes, and data types
- looking through Linux manual pages and documentation,?as you will likely need to do this in your projects later
- getting acquainted with the Linux-based??system and services,?which will help in your use of an actual Raspberry Pi later in the course
Your assignment task is to familiarize yourself with the??and develop some simple C++ utilities that help manage files on the system.? In a way, you are building some stripped down replacements to utilities like?,?,?,?,?,?, and?.? Because of the way Linux works, this is surprisingly easy and doesn’t take a whole lot of work. ?(Please note that manual pages??above and below are for Debian Stretch, the same basic Linux distribution that??is based upon.? That said, things may look or function differently under??itself, and so you should consult the man pages on the system itself as your primary source of documentation.)
Familiarizing Yourself with Raspberry Pi Desktop
To complete this assignment, you will need access to?, including its C++ compiler?and requisite supporting tools, libraries, and packages.? It is likely easiest to build yourself a virtual machine running this system; details on how to do so can be found under Useful Links in the OWL site side bar.? You should do this as early as possible to make sure you are set up and ready to go for the assignment.
If you have a computer that completely lacks virtualization support, Science Technology Services has a solution for remotely accessing something that is compatible for this work.? They have created a cloud based Linux machine running?; this can be found at?.? To access this machine, you should be able ssh to log in from pretty much anywhere, using your Western credentials for access.? You can scp/sftp files to and from this machine as necessary.
Modeling for this Assignment
For this assignment, you will be creating a C++ class to help manage files on the??system. ?(You might also be creating other support classes too, depending on how you do things.) ?This class will nicely encapsulate both information pulled from the file system?for the file(s) in question, as well as operations that can be performed on the files, with each instance of the class handling a single file.? This will be accomplished using a collection of system calls and file I/O operations.? First we will discuss the data that you need to concern yourselves with and how to access it, and then we will discuss operations that should be supported by your class?and how to execute them.
The file manager class you are to create will include at least the following information for this assignment:
- Name. ? The name of the file, given to the class through its constructor.
- Type.? Whether the file is a regular file, directory, and so on.? Not only is this useful information to have, but this will also allow you to permit certain operators on certain types of files. ?(When we explore design patterns in more detail, we will discuss a better way of doing this.).?This can be retrieved using the??function, and can be found in the st_mode field of the structure provided by this function.? You can store the type as a string representation or using the same numeric code used in the st_mode field.
- Size.? The size of the file.? This can be retrieved using the??function, and can be found in the st_size field of the structure provided by this function.
- Owner.? The user who owns the file.? This can be retrieved using the??function, and can be found in the st_uid field of the structure provided by this function.? You must keep the numeric user ID from this field, as well as the string user name obtained using the??function.
- Group.? The group of the file.? This can be retrieved using the??function, and can be found in the st_gid field of the structure provided by this function.? You must keep the numeric group ID from this field, as well as the string group name obtained using the??function.