From 0fe8055bf32394a8366430a5a123237c4d442c21 Mon Sep 17 00:00:00 2001 From: gc Date: Sun, 24 Feb 2008 16:14:22 +0000 Subject: [PATCH] use more File.delete and File.join --- bin/booh | 18 +++++++++--------- bin/booh-backend | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/bin/booh b/bin/booh index 4796745..da56c1d 100755 --- a/bin/booh +++ b/bin/booh @@ -203,7 +203,7 @@ def write_config ios.close $tempfiles.each { |f| - system("rm -f #{f}") + File.delete(f) } end @@ -816,7 +816,7 @@ or too bright. Drag the slider below the image. end def gen_real_thumbnail_core(type, origfile, destfile, xmldir, size, infotype) - system("rm -f '#{destfile}'") + File.delete(destfile) #- type can be 'element' or 'subdir' if type == 'element' gen_thumbnails_element(origfile, xmldir, false, [ { 'filename' => destfile, 'size' => size } ]) @@ -1135,7 +1135,7 @@ def add_thumbnail(autotable, filename, type, thumbnail_img, caption) #- remove out of sync images dest_img_base = build_full_dest_filename(filename).sub(/\.[^\.]+$/, '') for sizeobj in $images_size - system("rm -f #{dest_img_base}-#{sizeobj['fullscreen']}.jpg #{dest_img_base}-#{sizeobj['thumbnails']}.jpg") + File.delete("#{dest_img_base}-#{sizeobj['fullscreen']}.jpg", "#{dest_img_base}-#{sizeobj['thumbnails']}.jpg") end } @@ -1797,7 +1797,7 @@ def save_current_file_user msg 3, "performing actual deletion of: " + $todelete.join(', ') $todelete.each { |f| - system("rm -f #{f}") + File.delete(f) } end @@ -2016,7 +2016,7 @@ def backend_wait_message(parent, msg, infopipe_path, mode) gtk_thread_flush #- needed because we're about to destroy widgets in w, for which they may be some pending gtk calls if infopipe_path infopipe.close - system("rm -f #{infopipe_path}") + File.delete(infopipe_path) end } w.window_position = Gtk::Window::POS_CENTER @@ -2370,13 +2370,13 @@ def change_dir } refresh = proc { - system("rm -f '#{thumbnail_file}'") + File.delete(thumbnail_file) my_gen_real_thumbnail.call } rotate_and_cleanup = proc { |angle| rotate(angle, thumbnail_file, img, xmldir, "#{infotype}-", $default_albums_thumbnails[:x], $default_albums_thumbnails[:y]) - system("rm -f '#{thumbnail_file}'") + File.delete(thumbnail_file) } move = proc { |direction| @@ -2469,7 +2469,7 @@ def change_dir change_whitebalance(xmldir, "#{infotype}-", val) recalc_whitebalance(val, captionfile, thumbnail_file, img, xmldir, "#{infotype}-", $default_albums_thumbnails[:x], $default_albums_thumbnails[:y], infotype) - system("rm -f '#{thumbnail_file}'") + File.delete(thumbnail_file) } perform_change_whitebalance_and_cleanup.call(values[:new]) @@ -2492,7 +2492,7 @@ def change_dir change_gammacorrect(xmldir, "#{infotype}-", val) recalc_gammacorrect(val, captionfile, thumbnail_file, img, xmldir, "#{infotype}-", $default_albums_thumbnails[:x], $default_albums_thumbnails[:y], infotype) - system("rm -f '#{thumbnail_file}'") + File.delete(thumbnail_file) } perform_change_gammacorrect_and_cleanup.call(values[:new]) diff --git a/bin/booh-backend b/bin/booh-backend index 14bdb9f..1412c84 100755 --- a/bin/booh-backend +++ b/bin/booh-backend @@ -805,15 +805,15 @@ def walk_source_dir subdir = make_dest_filename(from_utf8(File.basename(child.attributes['path']))) rightful_images << "thumbnails-#{subdir}.jpg" } - to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?("#{dest_dir}/#{e}") && !rightful_images.include?(e) } - themestuff - themestuff_root + to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?(File.join(dest_dir, e)) && !rightful_images.include?(e) } - themestuff - themestuff_root if to_del.size > 0 - system("rm -f " + to_del.collect { |e| "'#{dest_dir}/#{e}'" }.join(' ')) + File.delete(to_del.collect { |e| File.join(dest_dir, e) }) end end #- copy any resource file that goes with the theme (css, images..) themestuff.each { |entry| - if !File.exists?("#{dest_dir}/#{entry}") + if !File.exists?(File.join(dest_dir, entry)) psys("cp '#{$FPATH}/themes/#{$theme}/#{entry}' '#{dest_dir}'") end } @@ -821,7 +821,7 @@ def walk_source_dir #- copy any root-only resource file that goes with the theme (css, images..) if xmldir.parent.name != 'dir' themestuff_root.each { |entry| - if !File.exists?("#{dest_dir}/#{entry}") + if !File.exists?(File.join(dest_dir, entry)) psys("cp '#{$FPATH}/themes/#{$theme}/root/#{entry}' '#{dest_dir}'") end } @@ -934,15 +934,15 @@ def walk_source_dir concat(thumbnail_videos.collect { |e| e[1] }.flatten). concat(videos). push('.htaccess') - to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?("#{dest_dir}/#{e}") && !all_elements.include?(e) && e !~ /^thumbnails-\w+\.jpg/ } - themestuff - themestuff_root + to_del = Dir.entries(dest_dir).find_all { |e| !File.directory?(File.join(dest_dir, e)) && !all_elements.include?(e) && e !~ /^thumbnails-\w+\.jpg/ } - themestuff - themestuff_root if to_del.size > 0 msg 3, _("\tcleaning up: #{to_del.join(', ')}") - system("rm -f " + to_del.collect { |e| "#{dest_dir}/#{e}" }.join(' ')) + File.delete(to_del.collect { |e| File.join(dest_dir, e) }) end #- copy any resource file that goes with the theme (css, images..) themestuff.each { |entry| - if !File.exists?("#{dest_dir}/#{entry}") + if !File.exists?(File.join(dest_dir, entry)) psys("cp '#{$FPATH}/themes/#{$theme}/#{entry}' '#{dest_dir}'") end } @@ -950,7 +950,7 @@ def walk_source_dir #- copy any root-only resource file that goes with the theme (css, images..) if xmldir.parent.name != 'dir' themestuff_root.each { |entry| - if !File.exists?("#{dest_dir}/#{entry}") + if !File.exists?(File.join(dest_dir, entry)) psys("cp '#{$FPATH}/themes/#{$theme}/root/#{entry}' '#{dest_dir}'") end } -- 2.30.4