Sha256: dd696f2600f546a916ce570f65572fc56002f2b2397cbf80f4559cadf85dc296

Contents?: true

Size: 804 Bytes

Versions: 6

Compression:

Stored size: 804 Bytes

Contents

# Name::      Sysadmin::DirExtension
# Author::    774 <http://id774.net>
# Created::   Jul 17, 2012
# Updated::   Jul 17, 2012
# Copyright:: 774 Copyright (c) 2012
# License::   Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.

module Sysadmin
  module DirExtension

    def Dir.filelist(dir, sub_directory = false)
      array = Array.new
      if (FileTest.file?(dir))
        array << dir
      else
        if sub_directory
          dir = dir + "/**/"
        else
          dir = dir + "/"
        end
        Dir::glob(dir).each do |d|
          if (FileTest.directory?(d))
            Dir::foreach(d) do |f|
              if (FileTest.file?(d+f))
                array << d+f
              end
            end
          end
        end
      end
      return array
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sysadmin-0.1.5 lib/sysadmin/dir_ext.rb
sysadmin-0.1.4 lib/sysadmin/dir_ext.rb
sysadmin-0.1.3 lib/sysadmin/dir_ext.rb
sysadmin-0.1.2 lib/sysadmin/dir_ext.rb
sysadmin-0.1.1 lib/sysadmin/dir_ext.rb
sysadmin-0.1.0 lib/sysadmin/dir_ext.rb