Sha256: c545760a782664b05cfe2277cc428d188abad660d8831992cf5555a93859fcd9

Contents?: true

Size: 755 Bytes

Versions: 1

Compression:

Stored size: 755 Bytes

Contents

# Name::      Sysadmin::DirExtension
# Author::    774 <http://id774.net>
# Created::   Jul 17, 2012
# Updated::   Nov 22, 2013
# 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
        dir = sub_directory ? dir + "/**/" : dir = dir + "/"
        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

      array
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sysadmin-0.2.0 lib/sysadmin/dir_ext.rb