NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

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 given name and size in bytes.

    • The operation fails if a file with that name already exists.
    • Return true if the file was added successfully; otherwise, return false.
  • boolean copyFile(String nameFrom, String nameTo) — copies a file from nameFrom to nameTo.

    • The operation fails if nameFrom does not identify an existing file or refers to a directory.
    • The operation also fails if a file already exists at nameTo.
    • Return true if the file was copied successfully; otherwise, return false.
  • int getFilesize(String name) — returns the size of the file identified by name, or -1 if the file does not exist.

Test Cases
Input
Output
Expected