|
7 | 7 | import java.util.List;
|
8 | 8 | import java.util.Map;
|
9 | 9 |
|
10 |
| -/** |
11 |
| - * 588. Design In-Memory File System |
12 |
| - * |
13 |
| - * Design an in-memory file system to simulate the following functions: |
14 |
| -
|
15 |
| - ls: Given a path in string format. If it is a file path, return a list that only contains this file's name. |
16 |
| - If it is a directory path, return the list of file and directory names in this directory. |
17 |
| - Your output (file and directory names together) should in lexicographic order. |
18 |
| -
|
19 |
| - mkdir: Given a directory path that does not exist, |
20 |
| - you should make a new directory according to the path. |
21 |
| - If the middle directories in the path don't exist either, |
22 |
| - you should create them as well. This function has void return type. |
23 |
| -
|
24 |
| - addContentToFile: Given a file path and file content in string format. |
25 |
| - If the file doesn't exist, you need to create that file containing given content. |
26 |
| - If the file already exists, you need to append given content to original content. |
27 |
| - This function has void return type. |
28 |
| -
|
29 |
| - readContentFromFile: Given a file path, return its content in string format. |
30 |
| -
|
31 |
| - Example: |
32 |
| - Input: |
33 |
| - ["FileSystem","ls","mkdir","addContentToFile","ls","readContentFromFile"] |
34 |
| - [[],["/"],["/a/b/c"],["/a/b/c/d","hello"],["/"],["/a/b/c/d"]] |
35 |
| - Output: |
36 |
| - [null,[],null,null,["a"],"hello"] |
37 |
| -
|
38 |
| - Note: |
39 |
| -
|
40 |
| - You can assume all file or directory paths are absolute paths which begin with / and do not end with / except that the path is just "/". |
41 |
| - You can assume that all operations will be passed valid parameters and users will not attempt to retrieve file content or list a directory or file that does not exist. |
42 |
| - You can assume that all directory names and file names only contain lower-case letters, and same names won't exist in the same directory. |
43 |
| -
|
44 |
| - */ |
45 | 10 | public class _588 {
|
46 | 11 | public static class Solution1 {
|
47 | 12 | /**
|
|
0 commit comments