Module: UtilityPack::Win32::FileHelpers

Extended by:
FileHelpers
Includes:
FileUtils
Included in:
FileHelpers
Defined in:
lib/utility_pack/win32/file_helpers.rb

Constant Summary collapse

MAX_DELETE_FILE_RETRIES =
20

Instance Method Summary collapse

Instance Method Details

#delete(*args) ⇒ Object



23
24
25
26
27
28
# File 'lib/utility_pack/win32/file_helpers.rb', line 23

def delete(*args)
  args.flatten.each do |path|
    delete_file path unless File.directory?(path)
    delete_directory path if File.directory?(path)
  end
end

#delete_directory(path) ⇒ Object



18
19
20
21
# File 'lib/utility_pack/win32/file_helpers.rb', line 18

def delete_directory path
  puts "Deleting directory #{path}"
  rm_rf path if File.directory?(path)
end

#delete_file(path) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/utility_pack/win32/file_helpers.rb', line 9

def delete_file path
  count = 0
  while File.exist?(path) && count < MAX_DELETE_FILE_RETRIES do
    puts "Deleting file #{path}"
    rm_f path
    count = count + 1
  end
end