Throw an exception if mkdirs fails

File.mkdirs returns false if directories couldn't be created instead
of throwing an exception; check for this and throw an exception
instead of ignoring the failure.
If mkdirs fails, verify that directory doesn't exist before throwing an exception.