Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program simulating a cd Unix command that changes a current directory in an abstract file system. The simulated command takes two path strings

Write a program simulating a "cd" Unix command that changes a current directory in an abstract file system. The simulated command takes two path strings from the command line and prints either a new path or an error. The first path is a current directory. The second path is a new directory. To make it simple let's assume that a directory name can only contain alphanumeric characters. A single dot (".") indicates a current directory, and the two dots ("..") indicate a step to a previous directory, up from the current one. A single forward slash "/" indicates a root directory. Multiple consecutive slashes are treated as equivalent to a single one. The program needs to check that the new directory path is valid without relying on any OS system call such as chdir() for verification, to construct a new path, and print it out. Since it is a simulator, it should be OS-independent. Write a program using Java. Automated unit tests are a plus.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions