octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pkg netlist


From: Bob Weigel
Subject: Re: pkg netlist
Date: Mon, 05 Mar 2007 08:58:55 -0500
User-agent: KMail/1.8.2

On Monday 05 March 2007 08:00, David Bateman wrote:
> Bob Weigel wrote:
> >>> | octave:1> md5sum("test string\n")
> >>> | ans = f299060e0383392ebeac64b714eca7e3
> >>> |
> >>> | % echo "test string" > foo; md5sum foo
> >>> | f299060e0383392ebeac64b714eca7e3  foo
> >>> |
> >>> | Shows that the code works.. The code is worked up as a patch against
> >>> | the CVS.
> >
> > Hi David,
> >
> > I think this is great addition.  I would like to suggest that the input
> > should be either a file name or a string.  If a filename is found in the
> > loadpath, the checksum for it is computed.
>
> How do you tell the difference between a filename and a string? Does
> this mean you want a "-file" option or something like that

I think file should be the default unless -string is given.  if 
file_in_loadpath returns empty, then assume it is a string.

> > Without a file name option, we'll be loading a file into memory (tar.gz)
> > and passing it to md5.  For large files, it will be much faster to use a
> > system call to a md5 binary (if it exists).
>
> I'm not sure that
>
> fid = fopen (file, "rb")
> buf = fread(fid)
> fclose(fid)
> md5 = md5sum(char(buf)')
>
> won't be as fast..

I suppose it depends on how this was implemented in your C/C++ code.   Even if 
it is the same speed, I think the file-as-default is better because the 
following is a more likely usage scenario

if (md5sum('package-with-executable-programs.tgz') != md5)
    error('Trouble')
end
or (admittedly less likely)
if (md5sum('ABC.iso') != md5)
   error('Trouble')   
end

Your case makes sense if you want to check the md5 of data that you will keep 
in memory.  However, I think md5 is overkill for verifying that a data file 
is not corrupt.  

Bob












reply via email to

[Prev in Thread] Current Thread [Next in Thread]