#K54872. File System Simulation: Create and Move Files
File System Simulation: Create and Move Files
File System Simulation: Create and Move Files
You are required to implement a basic file system simulation that supports two operations:
- create path size: Create a file at the specified
path
with the givensize
. - move sourcePath destinationPath: Move a file from
sourcePath
todestinationPath
.
After processing all commands, output the list of files present in the file system. The files must be printed in lexicographical order based on their paths. Each line of the output should include the file's path and its size separated by a single space.
Note: The file system is initially empty and you only need to handle file creation and file moving operations.
inputFormat
The input is read from standard input (stdin) and has the following format:
N command_1 command_2 ... command_N
Where:
N
is an integer representing the number of commands.- Each
command
is in one of the following formats:create path size
(e.g.,create /a/b 100
)move sourcePath destinationPath
(e.g.,move /a/b /a/c
)
outputFormat
The output should be printed to standard output (stdout) and must consist of the list of files present in the file system after processing all commands. Each line should contain the file's path and its size separated by a single space. The files must be listed in lexicographical order based on their paths.
## sample3
create /a/b/c 50
move /a/b/c /a/b/d
create /x/y/z 30
/a/b/d 50
/x/y/z 30
</p>