I think @atgeirr means you should be prepared to handle failures from `create_directories()` as those are certainly within the realms of possibility (exhausted inode space, no permissions &c), not from `is_directory()`.  The latter is mostly of no consequence.