bin/gui/properties.rb in origami-1.2.3 vs bin/gui/properties.rb in origami-1.2.4
- old
+ new
@@ -2,26 +2,26 @@
= File
properties.rb
= Info
- This file is part of Origami, PDF manipulation framework for Ruby
+ This file is part of PDF Walker, a graphical PDF file browser
Copyright (C) 2010 Guillaume Delugré <guillaume@security-labs.org>
All right reserved.
- Origami is free software: you can redistribute it and/or modify
- it under the terms of the GNU Lesser General Public License as published by
+ PDF Walker is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
- Origami is distributed in the hope that it will be useful,
+ PDF Walker is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Lesser General Public License for more details.
+ GNU General Public License for more details.
- You should have received a copy of the GNU Lesser General Public License
- along with Origami. If not, see <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU General Public License
+ along with PDF Walker. If not, see <http://www.gnu.org/licenses/>.
=end
require 'iconv'
require 'digest/md5'
@@ -52,24 +52,37 @@
def initialize(parent, pdf)
super("Document properties", parent, Dialog::MODAL, [Stock::CLOSE, Dialog::RESPONSE_NONE])
docframe = Frame.new(" File properties ")
+ stat = File.stat(parent.filename)
- i = Iconv.new("UTF-8//IGNORE//TRANSLIT", "ISO-8859-1")
+ if RUBY_VERSION < '1.9'
+ require 'iconv'
+ i = Iconv.new("UTF-8//IGNORE//TRANSLIT", "ISO-8859-1")
+
+ creation_date = i.iconv(stat.ctime.to_s)
+ last_modified = i.iconv(stat.mtime.to_s)
+ fd = File.open(parent.filename, 'rb')
+ md5sum = Digest::MD5.hexdigest(fd.read)
+ fd.close
+ i.close
+ else
+ creation_date = stat.ctime.to_s.encode("utf-8", :invalid => :replace, :undef => :replace)
+ last_modified = stat.mtime.to_s.encode("utf-8", :invalid => :replace, :undef => :replace)
+ md5sum = Digest::MD5.hexdigest(File.binread(parent.filename))
+ end
- stat = File.stat(parent.filename)
labels =
[
[ "Filename:", parent.filename ],
[ "File size:", "#{File.size(parent.filename)} bytes" ],
- [ "MD5:", Digest::MD5.hexdigest(File.open(parent.filename).read) ],
+ [ "MD5:", md5sum ],
[ "Read-only:", "#{not stat.writable?}" ],
- [ "Creation date:", i.iconv("#{stat.ctime}") ],
- [ "Last modified:", i.iconv("#{stat.mtime}") ]
+ [ "Creation date:", creation_date ],
+ [ "Last modified:", last_modified ]
]
- i.close
-
+
doctable = Table.new(labels.size + 1, 3)
row = 0
labels.each do |name, value|