Project Objective:

Develop a program that simulate a Linux file system and a terminal to interact with the "simulated" file system.

Learning Outcomes:

Develop a Java program that uses:

  • Trees data structure

Project overview:

The goal of this assignment is to make a basic directory maintenance simulator that processes basic Unix/Linux commands.

We will use a tree to represent the directory structure: see image.

For simplicity, we will use the same type of node to represent a file or a directory. Also, since we will need to traverse the tree towards the root for some commands, it is useful to maintain a reference within each node that points to its parent.

This Project We will simulate several of the UNIX/Linux operating system commands for a directory system in order to add directories, add files, list directory contents, etc. Issuing a command to create a directory, or example, should not result into creating an actual directory in your file system, but rather a node in your simulated directory tree.

Project Requirements:

Your application must function as described below:

  • Your program must satisfy all requirements in the test suites contained in src/test/java.
    • Running all tests can be accomplished in the command line by running gradle test.
    • Individual tests can be run by running gradle test_node_creation, gradle test_node_chaining, gradle test_fs_basic, gradle test_fs_mv, gradle test_fs_ls , and gradle test_fs_rm.

Commands

We will implement the following commands:

ls // lists all files and directories in the current directory,
// indicating whether the entry is a file or directory. See the test cases
mkdir < dirname> // creates a new directory if it does not already exist
cd < dirname> // changes into specified directory if it exists
cd .. // changes to the parent directory
pwd // specifies the current directory: root/nextdir/etc/
touch < filename> // adds a file to the current directory
mv < fname1> < fname2> //change the name of the file or directory to the new name
rm < filename> // locate and remove the file or directory
exit // ends the session

For simplicity, commands are expected to operate on the current directory only. In other words, you will NOT need to handle cases such as touch test/dir1/dir2.

Sample Run

The following is a sample run of the File System Simulator:

$ pwd
/root
$ mkdir test

$ cd foo
No such file or directory
$ cd test

$ ls

$ mkdir dir

$ pwd
/root/test
$ ls
d dir

$ cd dir

$ pwd
/root/test/dir
$ cd anothertest
No such file or directory
$ mkdir dir2

$ touch dir2
File or directory already exists
$ ls
d dir2

$ touch file

$ ls
f file
d dir2

$ mv dir2 dir

$ ls
f file
d dir

$ rm file

$ ls
d dir

$ rm nofile
No such file or directory
$ pwd
/root/test/dir
$ wrongcommand
unknown command
$ touch
improper command
$ exit
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.