File: files.rb

package info (click to toggle)
ruby-ox 2.14.22-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,500 kB
  • sloc: xml: 39,683; ansic: 9,615; ruby: 6,422; sh: 47; makefile: 2
file content (28 lines) | stat: -rwxr-xr-x 481 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby -wW2

if $0 == __FILE__
  $: << '.'
  $: << '..'
  $: << '../lib'
  $: << '../ext'
end

require 'sample/file'
require 'sample/dir'

def files(dir)
  d = Sample::Dir.new(dir)
  Dir.new(dir).each do |fn|
    next if fn.start_with?('.')

    filename = File.join(dir, fn)
    # filename = '.' == dir ? fn : File.join(dir, fn)
    if File.directory?(filename)
      d << files(filename)
    else
      d << Sample::File.new(filename)
    end
  end
  # pp d
  d
end