Implement a cloud storage system with operations for adding files, copying them, and looking up their sizes.
-
boolean addFile(String name, int size)— adds a file with the givennameand size in bytes.- The operation fails if a file with that name already exists.
- Return
trueif the file was added successfully; otherwise, returnfalse.
-
boolean copyFile(String nameFrom, String nameTo)— copies a file fromnameFromtonameTo.- The operation fails if
nameFromdoes not identify an existing file or refers to a directory. - The operation also fails if a file already exists at
nameTo. - Return
trueif the file was copied successfully; otherwise, returnfalse.
- The operation fails if
-
int getFilesize(String name)— returns the size of the file identified byname, or-1if the file does not exist.
Ask AI Assistant

Ask AI Assistant
Ask me anything about this coding question!
Test Cases
Input
Output
Expected