From b59529b25a639465489888861f739c5a8ef9d4be Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Fri, 11 Nov 2011 00:08:44 -0500 Subject: v3: FileUtils, replace system calls --- data/doc/sisu/CHANGELOG_v3 | 1 + lib/sisu/v3/epub.rb | 4 ++-- lib/sisu/v3/html.rb | 6 ++---- lib/sisu/v3/hub.rb | 3 ++- lib/sisu/v3/odf.rb | 4 ++-- lib/sisu/v3/sisupod_make.rb | 4 ++-- lib/sisu/v3/sysenv.rb | 10 ++++------ lib/sisu/v3/texinfo.rb | 2 +- lib/sisu/v3/texpdf.rb | 12 ++++-------- 9 files changed, 20 insertions(+), 26 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 21cbfbc7..c0955475 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -23,6 +23,7 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.1.4.orig.tar.xz * FileUtils, make more consistent (and explicit) use of * explicit calls (more verbose, easier to find) + * replace system calls %% 3.1.3.orig.tar.xz (2011-11-05:44/6) http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/sisu_3.1.3 diff --git a/lib/sisu/v3/epub.rb b/lib/sisu/v3/epub.rb index 80482984..a5c3f3b4 100644 --- a/lib/sisu/v3/epub.rb +++ b/lib/sisu/v3/epub.rb @@ -676,11 +676,11 @@ module SiSU_EPUB Dir.chdir(@md.env.processing_path.epub) system(" zip -qXr9D #{@epub_doc} * - mv #{@epub_doc} #{@md.file.place_file.epub.dir} ") + FileUtils::mv(@epub_doc, @md.file.place_file.epub.dir) Dir.chdir(pwd) unless @md.opt.cmd.inspect =~/M/ - system("rm -r #{@md.env.processing_path.epub}") + FileUtils::rm_r(@md.env.processing_path.epub) end end end diff --git a/lib/sisu/v3/html.rb b/lib/sisu/v3/html.rb index 000efc2e..3f867215 100644 --- a/lib/sisu/v3/html.rb +++ b/lib/sisu/v3/html.rb @@ -655,10 +655,8 @@ WOK idx_lnk=@file.base_filename.html_segtoc mlnk='index.html' Dir.chdir(@file.output_path.html.dir) - system(" - rm #{mlnk} - ln -s #{idx_lnk} #{mlnk} - ") + FileUtils::rm_f(mlnk) + FileUtils::ln_s(idx_lnk, mlnk) Dir.chdir(pwd_set) end end diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index a0f3f3d6..efba0f91 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -589,7 +589,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ and @@env.processing_path.processing =~/#{@@env.user}$/ #clean temporary processing directory of content as is located in public area FileUtils::cd(@@env.processing_path.processing_base_tmp) do FileUtils::rm_rf(@@env.user) unless @opt.cmd =~/M/ - end end + end + end elsif @opt.mod.inspect =~/--query/ require_relative 'sst_identify_markup' # sst_identify_markup.rb puts SiSU_Markup::Markup_history.new(@opt).query diff --git a/lib/sisu/v3/odf.rb b/lib/sisu/v3/odf.rb index 4cb6664b..5a095ba9 100644 --- a/lib/sisu/v3/odf.rb +++ b/lib/sisu/v3/odf.rb @@ -120,7 +120,7 @@ module SiSU_ODF unless @md.opt.cmd =~/[MV]/ #check maintenance flag if @env.processing_path.odt =~/od[ft]/ #p "rm -r #{@env.processing_path.odt}" if @md.opt.cmd =~/v/ - system("rm -r #{@env.processing_path.odf_pth}") + FileUtils::rm_r(@env.processing_path.odf_pth) #system("rm -r #{@env.processing_path.odt}") end end @@ -748,8 +748,8 @@ WOK Dir.chdir(@env.processing_path.odt) system(" zip -qr #{opendoc} * - mv #{opendoc} #{@md.file.place_file.odt.dir} ") + FileUtils::mv(opendoc, @md.file.place_file.odt.dir) Dir.chdir(pwd) end end diff --git a/lib/sisu/v3/sisupod_make.rb b/lib/sisu/v3/sisupod_make.rb index 698d5ae1..b154bc1d 100644 --- a/lib/sisu/v3/sisupod_make.rb +++ b/lib/sisu/v3/sisupod_make.rb @@ -292,9 +292,9 @@ module SiSU_Doc #{tree} tar -cJf #{@zipfile}.txz sisupod #echo "#{@file.place_file.sisupod.dir}" - mv #{@zipfile}.txz #{@file.place_file.sisupod.dir} & - rm -r sisupod/* }) + FileUtils::mv("#{@zipfile}.txz", @file.place_file.sisupod.dir) + FileUtils::rm_r(Dir.glob("sisupod/*")) Dir.chdir(@env.path.pwd) SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab unless @opt.cmd =~/q/ else diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index dd17b41e..0584d85f 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -1137,11 +1137,9 @@ module SiSU_Env if FileTest.directory?(sppc) pwd=Dir.pwd Dir.chdir(sppc) - system(" - ln -s ../../image - #ln -s ../../audio - #ln -s ../../video - ") + FileUtils::ln_s('../../image', 'image') + #FileUtils::ln_s('../../audio', 'audio') + #FileUtils::ln_s('../../video', 'video') Dir.chdir(pwd) end end @@ -3273,7 +3271,7 @@ WOK end def touch_file(path,filename) if File.writable?("#{path}/."); - system("touch #{path}/#{filename}") + FileUtils::touch("#{path}/#{filename}") else SiSU_Screen::Ansi.new('',"is the file or directory writable?, could not create #{filename}").warn end end diff --git a/lib/sisu/v3/texinfo.rb b/lib/sisu/v3/texinfo.rb index 06a921be..2004b435 100644 --- a/lib/sisu/v3/texinfo.rb +++ b/lib/sisu/v3/texinfo.rb @@ -390,7 +390,7 @@ module SiSU_TexInfo FileUtils::mkdir_p(@f.output_path.texinfo.dir) end info_src=%{#{@env.processing_path.texi}/#{@md.fnb}.info} - system("cp #{info_src} #{@f.place_file.info.dir}") + FileUtils::cp(info_src, @f.place_file.info.dir) end end end diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index 5f6674e5..96e51ed9 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -239,10 +239,8 @@ module SiSU_TeX if FileTest.directory?(@md.file.output_path.pdf.dir) pwd=Dir.pwd Dir.chdir(@md.file.output_path.pdf.dir) - system(" - rm #{mklnk} - ln -s #{pdf_p} #{mklnk} - ") + FileUtils::rm_f(mklnk) + FileUtils::ln_s(pdf_p, mklnk) Dir.chdir(pwd) end end @@ -254,10 +252,8 @@ module SiSU_TeX end pwd_set=Dir.pwd Dir.chdir(@md.file.output_path.pdf.dir) - system(" - rm #{mklnk} - ln -s #{pdf_l} #{mklnk} - ") + FileUtils::rm_f(mklnk) + FileUtils::ln_s(pdf_l, mklnk) Dir.chdir(pwd_set) end else -- cgit v1.2.3