code/superant.com.gutenberg/loadbookrecord.rb in rwdgutenberg-0.09 vs code/superant.com.gutenberg/loadbookrecord.rb in rwdgutenberg-0.12

- old
+ new

@@ -1,31 +1,69 @@ # this method views an existing record def rwdgutenloadbookrecord require 'fileutils' - @a_gutenbergdatapath = "" - @a_gutenbergdatainfo = "" - @a_gutenbergdatalocation = "" - @a_gutenbergdatalines = "" - @a_gutenbergdataspeed = "" - @a_gutenbergdatacomments = "" + @a_gutenbergdatapath = "" + @a_gutenbergdatainfo = "" + @a_gutenbergdatalocation = "" + @a_gutenbergdatalines = "" + @a_gutenbergdataspeed = "" + @a_gutenbergdatacomments = "" begin # exception trapped block - - tmpfileName = @a_viewgutenberg + ".gut" + if File.extname(@a_viewgutenberg) == ".lnk" + tmpfileName = @a_viewgutenberg + else + tmpdirname = File.dirname(@a_viewgutenberg) + tmpext = File.extname(@a_viewgutenberg) + tmpfilename = File.basename(@a_viewgutenberg,"#{tmpext}") + tmpfileName = tmpfilename.to_s + ".lnk" + + end fileName = File.join($rwdgutenberg_directory,tmpfileName) fd = File.open(fileName,"r") - @a_gutenbergdatapath = fd.readline.chomp - @a_gutenbergdatainfo = fd.readline.chomp - @a_gutenbergdatalocation = fd.readline.chomp - @a_gutenbergdatalines = fd.readline.chomp - @a_gutenbergdataspeed = fd.readline.chomp - @a_gutenbergdatacomments = fd.readline.chomp + @a_gutenbergdatapath = fd.readline.chomp + @a_gutenbergdatainfo = fd.readline.chomp + @a_gutenbergdatalocation = fd.readline.chomp + @a_gutenbergdatalines = fd.readline.chomp + @a_gutenbergdataspeed = fd.readline.chomp + @a_gutenbergdatacomments = fd.readline.chomp - fd.close + fd.close rescue SystemCallError, StandardError - $stderr.print "system call error: " + $! + $rwdtinkerlog.error "rwdgutenloadbookrecord: system call error #{$!}" + + end # exception rescue + + end + def rwdgutenloadbookrecord2 + + require 'fileutils' + @a_gutenbergdata = "" + + + + begin # exception trapped block + + if File.extname(@a_viewgutenberg) == ".lnk" + tmpfilename = File.basename(@a_viewgutenberg,".lnk") + tmpfileName = tmpfilename.to_s + ".txt" + + else + tmpfileName = @a_viewgutenberg + + + end + fileName = File.join($rwdgutenberg_directory,tmpfileName) + fd = File.open(fileName,"r") + @a_gutenbergdata = fd.read + + fd.close + rescue SystemCallError, StandardError + + $rwdtinkerlog.error "rwdgutenloadbookrecord2: system call error " + end # exception rescue end