code: public static URI convertToDirectoryPath(PathCodec pathCodec, URI path) {
      StorageResourceId resourceId = pathCodec.validatePathAndGetId(path, true);
  
      if (resourceId.isStorageObject()) {
        if (!objectHasDirectoryPath(resourceId.getObjectName())) {
          resourceId = convertToDirectoryPath(resourceId);
          path = pathCodec.getPath(
              resourceId.getBucketName(), resourceId.getObjectName(), false /* allow empty name */);
        }
      }
      return path;
    }
docs: Converts the given path to look like a directory path.
  If the path already looks like a directory path then
  this call is a no-op.
  
  @param path Path to convert.
  @return Directory path for the given path.