File system · 8 / 15 Exercise Medium

Size of a folder

Objective

The program runs inside a folder that already contains the files of the test case. path.stat() returns information about a file, and st_size is its size in bytes. For a folder you must add up the size of all the files it contains, including those in subfolders.

Instructions

  • Read the name of a folder inside the current folder.
  • Show Total size: n bytes with the sum of the sizes of all the files inside it, at any depth.

Example. With datos/a.txt (4 bytes) and datos/sub/b.txt (10 bytes), the input datos produces Total size: 14 bytes.

Input
datos
Output
Total size: 14 bytes

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise