Sha256: 1d4d7b588302b20285ceca2a8080859148cc18db3c7be5df2d3860dfa2fe89e3
Contents?: true
Size: 491 Bytes
Versions: 10
Compression:
Stored size: 491 Bytes
Contents
module Eddy module Util # Delete all files from a folder; returns number of deleted files. # # Fails if the folder contains any symlinks. # # @param path [String] Path to the folder. # @return [Integer] def self.clean_folder(path) dir = File.expand_path(path) return 0 unless Dir.exist?(dir) children = Dir.entries(dir).select { |f| File.file?(File.join(dir, f)) } deleted = File.unlink(*children) return deleted end end end
Version data entries
10 entries across 10 versions & 1 rubygems