This assignment is about implementing and testing classes for directory/file hierarchy
• Your program reads two files:
• According to content in files.txt, the program dynamically creates necessary objects for a directory
structure and evaluates the commands listed in commands.txt.
• Your program prints the list of files and directories with their full addresses to a file called output.txt.
• Each line is a file or directory name. This file lists all the necessary information for you to create a full directory
structure. There won’t be any errors but the order can be arbitrary. You have to figure out the root directory
and the rest of the hierarchy from this file. For this initial file, you can assume all the directory names will be
unique. You can read the file line by line and create independent structures for each line, then you can combine
all the created structures in order to create the final structure. Assume, there isn’t any empty directory. Each
line ends with a file name.
• Below is the contents of a files.txt file:
• For this example, the structure is as follows:
This file includes several commands which work on the directory structure you read from files.txt. Each line is a
command. The following should be recognized:
copy A B
move A B
copy A B
This command has two operants: A and B. B is a directory. A can be a directory or a file. This command copies
A and places it under directory B. If A is a directory, all the structure under A is copied under B. A and B can be
provided as full directory or relative directory.
move A B
Similar to copy A B. This moves A under B and deletes the original copy of A
Removes A from the structure.
This command changes the current directory to A. A is definitely a directory not a file. There are special replacements
• .. : changes the current director to the parent directory.(If there is no parent, current directory does not
• / : changes the current directory to root. Root directory is the top directory. There isn’t a parent directory
above the root directory.
Assume that your program reads the example files.txt given above. Current directory is the top(root) directory
which is directory0
• Issuing the command copy /directory0/directory1/directory2/file1 /directory0, copies file1 and
places it under directory0. Following is the result of this command:
• similarly, the command copy file4 directory1 copies file4 to the directory directory1. Here, current
directory is directory0 so, file4 and directory1 are given as relative addresses. After this command, the
structure changes to the following version:
• If there is a command delete directory1, it will change the structure as follows:
This file lists all the files and directories with their full addresses.
If your directory structure is as follows:
You should create the following output.txt file:
• This assignment is about using linked lists. You should use classes and inheritance. (You need a base class
from which file and directory classes inherit.). A directory object holds a linked-list of files or other
• You need to keep the track of current directory and issue the commands. For this, you can create a file
manager class. This class can deal with reading files.txt, commands.txt and create a output.txt.
• You can assume that all the files and directories under the same parent directory will have different names.
• Source code of a complete C++ program and a suitable makefile. You should use c++11 standard. Your code
will be tested in a linux-gcc environment.
• A script will be used in order to check the correctness of your results. So, be careful not to violate the expected
• Provide comments unless you are not interested in partial credit. (If I cannot easily understand your design,
you may loose points.)
• You cannot get full credit if your implementation contradicts with the statements in this document.