lib/ronin/formatting/extensions/binary/file.rb in ronin-support-0.4.1 vs lib/ronin/formatting/extensions/binary/file.rb in ronin-support-0.5.0.rc1
- old
+ new
@@ -15,30 +15,63 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with Ronin Support. If not, see <http://www.gnu.org/licenses/>.
#
-require 'ronin/formatting/extensions/binary/string'
+require 'ronin/binary/hexdump/parser'
class File
#
# Converts a hexdump file to it's original binary data.
#
# @param [Pathname, String] path
# The path of the hexdump file.
#
# @param [Hash] options
- # Hexdump options.
+ # Additional options.
#
- # @return [String]
- # The original binary data.
+ # @option options [Symbol] :format
+ # The expected format of the hexdump. Must be either `:od` or
+ # `:hexdump`.
#
- # @see String#unhexdump.
+ # @option options [Symbol] :encoding
+ # Denotes the encoding used for the bytes within the hexdump.
+ # Must be one of the following:
#
+ # * `:binary`
+ # * `:octal`
+ # * `:octal_bytes`
+ # * `:octal_shorts`
+ # * `:octal_ints`
+ # * `:octal_quads` (Ruby 1.9 only)
+ # * `:decimal`
+ # * `:decimal_bytes`
+ # * `:decimal_shorts`
+ # * `:decimal_ints`
+ # * `:decimal_quads` (Ruby 1.9 only)
+ # * `:hex`
+ # * `:hex_chars`
+ # * `:hex_bytes`
+ # * `:hex_shorts`
+ # * `:hex_ints`
+ # * `:hex_quads`
+ # * `:named_chars` (Ruby 1.9 only)
+ # * `:floats`
+ # * `:doubles`
+ #
+ # @option options [:little, :big, :network] :endian (:little)
+ # The endianness of the words.
+ #
+ # @option options [Integer] :segment (16)
+ # The length in bytes of each segment in the hexdump.
+ #
+ # @return [String]
+ # The raw-data from the hexdump.
+ #
# @api public
#
def File.unhexdump(path,options={})
- File.read(path).unhexdump(options)
+ Ronin::Binary::Hexdump::Parser.new(options).parse(File.new(path))
end
end