[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Binary files comparision

Marcin Tyman

9/3/2008 9:12:00 AM

Hallo guys,
I've got 2 folders with content which I need to binary compare (file by
file). Is in ruby any library to help me with this?
Any other ideas?

Thanks in advance
--
Posted via http://www.ruby-....

4 Answers

ruud grosmann

9/3/2008 10:36:00 AM

0

something like:

cksum1 = `cksum #{file1}`
cksum1.sub!( /(\d+)\s.*/, '\1')
cksum2 = `cksum #{file2}`
cksum2.sub!( /(\d+)\s.*/, '\1')

cksum1 == chsum2

Or is this not what you're after?

regards, Ruud



On 03/09/2008, Marcin Tyman <m.tyman@interia.pl> wrote:
> Hallo guys,
> I've got 2 folders with content which I need to binary compare (file by
> file). Is in ruby any library to help me with this?
> Any other ideas?
>
> Thanks in advance
> --
> Posted via http://www.ruby-....
>
>

Robert Klemme

9/3/2008 10:55:00 AM

0

2008/9/3 ruud grosmann <r.grosmann@gmail.com>:
> something like:
>
> cksum1 = `cksum #{file1}`
> cksum1.sub!( /(\d+)\s.*/, '\1')
> cksum2 = `cksum #{file2}`
> cksum2.sub!( /(\d+)\s.*/, '\1')
>
> cksum1 == chsum2
>
> Or is this not what you're after?

In that case why not directly use cmp? I thought the OP wanted a Ruby version.

For small files this could be as easy as

File.read(f1) == File.read(f2)

Marcin, what kind of comparison do you need? Especially what output
do you expect?

Kind regards

robert

--
use.inject do |as, often| as.you_can - without end

Marcin Tyman

9/3/2008 11:01:00 AM

0

ruud grosmann wrote:
> something like:
>
> cksum1 = `cksum #{file1}`
> cksum1.sub!( /(\d+)\s.*/, '\1')
> cksum2 = `cksum #{file2}`
> cksum2.sub!( /(\d+)\s.*/, '\1')
>
> cksum1 == chsum2
>
> Or is this not what you're after?
>
> regards, Ruud

Not exactly. I run script on Windows.
--
Posted via http://www.ruby-....

Tim Hunter

9/3/2008 1:15:00 PM

0

Marcin Tyman wrote:
> Hallo guys,
> I've got 2 folders with content which I need to binary compare (file by
> file). Is in ruby any library to help me with this?
> Any other ideas?
>
> Thanks in advance

The FileUtils library includes compare_file(a, b).

ri FileUtils

--
RMagick: http://rmagick.ruby...