Return all files under a path
Company: Dropbox
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
You are building a simple file crawler.
## Task
Implement an API/function:
- **Input:** a filesystem path `rootPath`
- **Output:** a list/array of **all file paths** contained under `rootPath` (recursively), in any order.
Assume:
- Paths can be directories or files.
- You are given a helper function similar to:
- `listChildren(path) -> (subdirs, files)` where `subdirs` are immediate child directories and `files` are immediate child files.
## Notes / edge cases to clarify in your solution
- If `rootPath` is a file, return just `[rootPath]`.
- Decide what to do if the path does not exist or is not accessible (e.g., throw an error vs return empty).
- Avoid infinite loops if the filesystem can contain symlinks (state your assumption if you ignore symlinks).
Quick Answer: This question evaluates filesystem traversal and recursive/iterative algorithm skills, including handling different path types, edge cases such as missing or inaccessible paths, and robustness concerns like symlink cycles when enumerating files.