Module: Hike::FileUtils

Extended by:
FileUtils
Included in:
CachedTrail, FileUtils, Trail
Defined in:
lib/hike/fileutils.rb

Instance Method Summary collapse

Instance Method Details

#entries(path) ⇒ Object

A version of Dir.entries that filters out . files and ‘~` swap files. Returns an empty Array if the directory does not exist.



16
17
18
19
20
21
22
# File 'lib/hike/fileutils.rb', line 16

def entries(path)
  if File.directory?(path)
    Dir.entries(path).reject { |entry| entry =~ /^\.|~$|^\#.*\#$/ }.sort
  else
    []
  end
end

#stat(path) ⇒ Object

Like File.stat. Returns nil if the file does not exist.



6
7
8
9
10
11
12
# File 'lib/hike/fileutils.rb', line 6

def stat(path)
  if File.exist?(path)
    File.stat(path.to_s)
  else
    nil
  end
end