In this task, you’re goal is to make the wordcount
command handle directories and missing files gracefully. This is crucial for making your program robust and user-friendly. Instead of failing with an error message when encountering a directory or a non-existent file, your program should report zeros for lines, words, and bytes, along with a descriptive message.
Acceptance Criteria
- When the path provided as a command-line argument is a directory, your program should output zeros for lines, words, and bytes, followed by the directory name and the message (is a directory).
- When the specified file doesn’t exist, your program should output zeros for lines, words, and bytes, followed by the missing file name and the message (no such file or directory).
- For regular files and standard input, the behavior should remain unchanged.
Examples
Given a directory input: