Returns the directory/filename where the subject will be stored.

  Args:
   subject: The subject.
   regexes: The list of regular expressions by priority.

  Returns:
   File name and directory.

def ResolveSubjectDestination(subject, regexes):
  """Returns the directory/filename where the subject will be stored.

  Args:
   subject: The subject.
   regexes: The list of regular expressions by priority.

  Returns:
   File name and directory.
  """
  components = Components(subject)
  if not components:
    # No components to work with.
    return "aff4", ""
  # Make all the components safe to use.
  path = utils.JoinPath(*[ConvertStringToFilename(x) for x in components])
  for route in regexes:
    m = route.match(path)
    if m:
      value = m.group("path")
      if value:
        base = os.path.basename(value)
        dirname = os.path.dirname(value)
        return base, dirname
  # Default value if nothing else matches.
  return "aff4", ""