Create an in-memory file system supporting the following operations:
show
: Given a string path, if it leads to a file, return a list containing only the file name. If it leads to a folder, return a list of all files and subfolder names in that folder, sorted in lexicographical order.makeDir
: Given a new folder path, create the folder. If any intermediate folders do not exist, create them as well. This method returns nothing.writeFile
: Given a file path and content as a string, create the file and set its content. If the file already exists, append the new content to the existing content. This method returns nothing.readFile
: Given a file path, return its content as a string.Input: ["MemorySystem","show","makeDir","writeFile","show","readFile"] [[],["/"],["/x/y/z"],["/x/y/z/file1","sample"],["/"],["/x/y/z/file1"]] Output: [null,[],null,null,["x"],"sample"] Explanation: After creating the folder structure and adding a file with content "sample", listing files at the root gives ["x"], and reading the content at "/x/y/z/file1" returns "sample".
/
, and do not end with /
(except "/"
itself).