Question: Data Structure using C++ Write a program that will simulate a Unix File System. This program will use a tree to represent the file system.

Data Structure using C++

Write a program that will simulate a Unix File System. This program will use a tree to represent the file system. It should provide, at a minimum, the following functionality to the user: mkdir, touch, cd, ls, and exit. When this program runs it should display a welcome prompt and then wait for input from the user. The user should be then be able type in their commands. The idea is to simulate the command prompt of windows or the shell prompt of Linux. Your program should feel similar to either of these shells.

mkdir This should create a new directory in the current directory with dirname as its name.

touch This should create a new file in the current directory with filename as its name.

cd This should change the current directory to the directory specified by path. It should be able to accept both relative and absolute paths. A relative path starts with a / and describes a path from the root. A relative path will start with a . and describes a path from the current directory. .. indicates the parent directory. . Indicates the current directory. Paths should use a / to separate folders in the path. For example ../home/fconlon. A / by itself indicates the root directory. If a user attempts to cd to a file or a directory that does not exist an error message should be displayed, and the program should continue to run.

ls This should display all of the files and directories in the directory specified by path. If not path is specified then it should display all the files and directories in the current directory. This command should first display all the directories in the current directory in alphabetical order the display all of the files in the current directory in alphabetical order. path should follow the same conventions for the path argument from cd. It should display the same errors under the same conditions as cd.

Exit This should exit the program. Dont forget to clear any memory that you allocated.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!