<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def confirmdir(self, target_directory):
 """Test that the target is actually a directory, raising OSError if not. Args: target_directory: Path to the target directory within the fake filesystem. Returns: The FakeDirectory object corresponding to target_directory. Raises: OSError: if the target is not a directory. """

        try:
            directory = self.resolve(target_directory)
        except IOError as exc:
            self.raise_os_error(exc.errno, target_directory)
        if not directory.st_mode & S_IFDIR:
            if self.is_windows_fs and IS_PY2:
                error_nr = errno.EINVAL
            else:
                error_nr = errno.ENOTDIR
            self.raise_os_error(error_nr, target_directory, 267)
        return directory