in appengine-plugins-core/src/main/java/com/google/cloud/tools/io/FilePermissions.java [42:62]
public static void verifyDirectoryCreatable(Path path)
throws AccessDeniedException, NotDirectoryException {
Preconditions.checkNotNull(path, "Null directory path");
for (Path segment = path; segment != null; segment = segment.getParent()) {
if (Files.exists(segment)) {
if (Files.isDirectory(segment)) {
// Can't create a directory if the bottom most currently existing directory in
// the path is not writable.
if (!Files.isWritable(segment)) {
throw new AccessDeniedException(segment + " is not writable");
}
} else {
// Can't create a directory if a non-directory file already exists with that name
// somewhere in the path.
throw new NotDirectoryException(segment + " is a file");
}
break;
}
}
}