code: def makedirs(self, dir_name, mode=PERM_DEF, exist_ok=False):
          
          ends_with_sep = self.ends_with_path_separator(dir_name)
          dir_name = self.absnormpath(dir_name)
          if (ends_with_sep and self.is_macos and
                  self.exists(dir_name, check_link=True) and
                  not self.exists(dir_name)):
              # to avoid EEXIST exception, remove the link
              self.remove_object(dir_name)
  
          path_components = self._path_components(dir_name)
  
          # Raise a permission denied error if the first existing directory
          # is not writeable.
          current_dir = self.root
          for component in path_components:
              if (component not in current_dir.contents
                      or not isinstance(current_dir.contents, dict)):
                  break
              else:
                  current_dir = current_dir.contents[component]
          try:
              self.create_dir(dir_name, mode & ~self.umask)
          except (IOError, OSError) as e:
              if (not exist_ok or
                      not isinstance(self.resolve(dir_name), FakeDirectory)):
                  if self.is_windows_fs and e.errno == errno.ENOTDIR:
                      e.errno = errno.ENOENT
                  self.raise_os_error(e.errno, e.filename)
docs: Create a leaf Fake directory and create any non-existent
          parent dirs.
  
          Args:
              dir_name: (str) Name of directory to create.
              mode: (int) Mode to create directory (and any necessary parent
                  directories) with. This argument defaults to 0o777.
                  The umask is applied to this mode.
            exist_ok: (boolean) If exist_ok is False (the default), an OSError is
                  raised if the target directory already exists.
                  New in Python 3.2.
  
          Raises:
              OSError: if the directory already exists and exist_ok=False,
                  or as per :py:meth:`create_dir`.