<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def mkdir(self, mode=0o777, parents=False, exist_ok=False):
 """ Create a new directory at this given path. """

        if self._closed:
            self._raise_closed()

        def _try_func():
            self._accessor.mkdir(self, mode)

        def _exc_func(exc):
            if not parents or self.parent == self:
                raise exc
            self.parent.mkdir(parents=True, exist_ok=True)
            self.mkdir(mode, parents=False, exist_ok=exist_ok)

        try:
            _try_except_filenotfounderror(_try_func, _exc_func)
        except OSError:
            if not exist_ok or not self.is_dir():
                raise