def create_directory(self):
        """
        Creates a directory under the selected directory (if the selected item
        is a file, the parent directory is used).
        """
        src = self.get_current_path()
        name, status = QtWidgets.QInputDialog.getText(
            self.tree_view, _('Create directory'), _('Name:'),
            QtWidgets.QLineEdit.Normal, '')
        if status:
            fatal_names = ['.', '..']
            for i in fatal_names:
                if i == name:
                    QtWidgets.QMessageBox.critical(
                        self.tree_view, _("Error"), _("Wrong directory name"))
                    return

            if os.path.isfile(src):
                src = os.path.dirname(src)
            dir_name = os.path.join(src, name)
            try:
                os.makedirs(dir_name, exist_ok=True)
            except OSError as e:
                QtWidgets.QMessageBox.warning(
                    self.tree_view, _('Failed to create directory'),
                    _('Failed to create directory: "%s".\n\n%s') % (dir_name, str(e)))