def create_dir(self, directory_path, perm_bits=PERM_DEF):
        """Create `directory_path`, and all the parent directories.

        Helper method to set up your test faster.

        Args:
            directory_path: The full directory path to create.
            perm_bits: The permission bits as set by `chmod`.

        Returns:
            The newly created FakeDirectory object.

        Raises:
            OSError: if the directory already exists.
        """
        directory_path = self.make_string_path(directory_path)
        directory_path = self.absnormpath(directory_path)
        self._auto_mount_drive_if_needed(directory_path)
        if self.exists(directory_path, check_link=True):
            self.raise_os_error(errno.EEXIST, directory_path)
        path_components = self._path_components(directory_path)
        current_dir = self.root

        new_dirs = []
        for component in path_components:
            directory = self._directory_content(current_dir, component)[1]
            if not directory:
                new_dir = FakeDirectory(component, filesystem=self)
                new_dirs.append(new_dir)
                current_dir.add_entry(new_dir)
                current_dir = new_dir
            else:
                if S_ISLNK(directory.st_mode):
                    directory = self.resolve(directory.contents)
                current_dir = directory
                if directory.st_mode & S_IFDIR != S_IFDIR:
                    self.raise_os_error(errno.ENOTDIR, current_dir.path)

        # set the permission after creating the directories
        # to allow directory creation inside a read-only directory
        for new_dir in new_dirs:
            new_dir.st_mode = S_IFDIR | perm_bits

        self._last_ino += 1
        current_dir.st_ino = self._last_ino
        return current_dir
def create_dir ( self , directory_path , perm_bits = PERM_DEF ) : directory_path = self . make_string_path ( directory_path ) directory_path = self . absnormpath ( directory_path ) self . _auto_mount_drive_if_needed ( directory_path ) if self . exists ( directory_path , check_link = True ) : self . raise_os_error ( errno . EEXIST , directory_path ) path_components = self . _path_components ( directory_path ) current_dir = self . root new_dirs = [ ] for component in path_components : directory = self . _directory_content ( current_dir , component ) [ 1 ] if not directory : new_dir = FakeDirectory ( component , filesystem = self ) new_dirs . append ( new_dir ) current_dir . add_entry ( new_dir ) current_dir = new_dir else : if S_ISLNK ( directory . st_mode ) : directory = self . resolve ( directory . contents ) current_dir = directory if directory . st_mode & S_IFDIR != S_IFDIR : self . raise_os_error ( errno . ENOTDIR , current_dir . path ) for new_dir in new_dirs : new_dir . st_mode = S_IFDIR | perm_bits self . _last_ino += 1 current_dir . st_ino = self . _last_ino return current_dir
Create `directory_path`, and all the parent directories.

        Helper method to set up your test faster.

        Args:
            directory_path: The full directory path to create.
            perm_bits: The permission bits as set by `chmod`.

        Returns:
            The newly created FakeDirectory object.

        Raises:
            OSError: if the directory already exists.