Sale!

CSE 241 Programming Assignment 5 solved

Original price was: $35.00.Current price is: $35.00. $17.50

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

This assignment is about implementing and testing classes for directory/file hierarchy
• Your program reads two files:
– files.txt
– commands.txt
• 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.
files.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.
• Example:
• Below is the contents of a files.txt file:
directory1/directory2/file1
directory2/file3
directory0/directory1/file5
directory0/file4
• For this example, the structure is as follows:
directory0
directory1
directory2
file1
file3
file5
file4
commands.txt
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
delete A
1
cd A
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
delete A
Removes A from the structure.
cd A
This command changes the current directory to A. A is definitely a directory not a file. There are special replacements
for A:
• .. : changes the current director to the parent directory.(If there is no parent, current directory does not
change)
• / : changes the current directory to root. Root directory is the top directory. There isn’t a parent directory
above the root directory.
Example:
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:
directory0
directory1
directory2
file1
file3
file5
file1
file4
• 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:
directory0
directory1
directory2
file1
file3
file4
file5
file1
file4
2
• If there is a command delete directory1, it will change the structure as follows:
directory0
file1
file4
output.txt
This file lists all the files and directories with their full addresses.
If your directory structure is as follows:
directory0
directory1
directory2
file1
file3
file4
file5
file1
file4
You should create the following output.txt file:
directory0
directory0/directory1
directory0/file1
directory0/file4
directory0/directory1/directory2
directory0/directory1/file4
directory0/directory1/file5
directory0/directory1/directory2/file1
directory0/directory1/directory2/file4
Remarks
• 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
directories.
• 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.
Turn in:
• 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
output format.
• 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.
3