Create an in-memory file system that supports the following operations:
list
: Given a string path, if the path points to a file, return a list containing only the file's name. If it points to a directory, return a list of all files and directories inside it. The returned list should be sorted in alphabetical order.makeDir
: Given a directory path that doesn't exist, create all directories along the path. This method does not return anything.appendToFile
: Given a file path and some content, if the file doesn't exist, create it with the given content. If it exists, append the content to the file. This method does not return anything.readFile
: Given a file path, return the content stored in the file as a string.Input: ["SimpleFS","list","makeDir","appendToFile","list","readFile"] [[],["/"],["/x/y/z"],["/x/y/z/file1","world"],["/x/y"],["/x/y/z/file1"]] Output: [null,[],null,null,["z"],"world"] Explanation: - The file system is initialized. - Listing the root directory returns an empty list. - Creating directory path "/x/y/z". - Adding content "world" to the file "/x/y/z/file1". - Listing directory "/x/y" returns ["z"] because "z" is a directory inside "/x/y". - Reading the content of "/x/y/z/file1" returns "world".
/
, except the root which is just /
.