def dir(name, mode = 16877, &block)
      name_parts = name.split(::File::SEPARATOR)

      innermost_child_name = name_parts.pop

      if name_parts.empty?
        Directory.new(name, mode).tap do |directory|
          add_directory(directory)

          block.call(directory) if block
        end
      else
        innermost_parent = name_parts.reduce(self) do |parent, child_name|
          parent.dir(child_name)
        end

        innermost_parent.dir(innermost_child_name, &block)
      end
    end
def dir(name, mode = 16877, &block)
      name_parts = name.split(::File::SEPARATOR)

      innermost_child_name = name_parts.pop

      if name_parts.empty?
        Directory.new(name, mode).tap do |directory|
          add_directory(directory)

          block.call(directory) if block
        end
      else
        innermost_parent = name_parts.reduce(self) do |parent, child_name|
          parent.dir(child_name)
        end

        innermost_parent.dir(innermost_child_name, &block)
      end
    end
Add a +Directory+ named +name+ to this entity's list of children. The
 +name+ may simply be the name of the directory, or may be a path to the
 directory.

 In the case of the latter, +dir+ will create the +Directory+ tree
 specified by the path. The block parameter yielded in this case will be
 the innermost directory.

 @example
   archive = Directory.new
   archive.dir('app') do |app|
     app.name == 'app'
     app.path == './app'
   end

 @example
   archive.dir('app/controllers/concerns') do |concerns|
     concerns.name == 'concerns'
     concerns.path == './app/controllers/concerns'
   end

 @param name [String] the directory name
 @param mode [Fixnum] the directory mode

 @yieldparam directory [AndFeathers::Directory] the newly-created
   +Directory+