code: def _mkdirs_impacket(path, share='C$', conn=None, host=None, username=None, password=None):
      '''
      Recursively create a directory structure on an SMB share
  
      Paths should be passed in with forward-slash delimiters, and should not
      start with a forward-slash.
      '''
      if conn is None:
          conn = get_conn(host, username, password)
  
      if conn is False:
          return False
  
      comps = path.split('/')
      pos = 1
      for comp in comps:
          cwd = '\\'.join(comps[0:pos])
          try:
              conn.listPath(share, cwd)
          except (smbSessionError, smb3SessionError):
              log.exception('Encountered error running conn.listPath')
              conn.createDirectory(share, cwd)
          pos += f _mkdirs_impacket(path, share='C$', conn=None, host=None, username=None, password=None):
      '''
      Recursively create a directory structure on an SMB share
  
      Paths should be passed in with forward-slash delimiters, and should not
      start with a forward-slash.
      '''
      if conn is None:
          conn = get_conn(host, username, password)
  
      if conn is False:
          return False
  
      comps = path.split('/')
      pos = 1
      for comp in comps:
          cwd = '\\'.join(comps[0:pos])
          try:
              conn.listPath(share, cwd)
          except (smbSessionError, smb3SessionError):
              log.exception('Encountered error running conn.listPath')
              conn.createDirectory(share, cwd)
          pos += 1
docs: Recursively create a directory structure on an SMB share
  
      Paths should be passed in with forward-slash delimiters, and should not
      start with a forward-slash.