file comparing
I wrote this little program a little while back, because I needed
something that worked like the old DOS program, compare. This works
great, until you try to compare two large files (I assume because the
program runs out of memory). Is there any way I can avoid this?
I know I could use getc(), but wouldn't that also be really slow, for
large files?
Also, I know I could use getc() to maybe return the exact bytes that are
different, but how would I go about that?
---------------includex.e-----------------
include get.e
sequence input_data1, input_data2, cmd, path
integer file1, file2
cmd = command_line()
if length(cmd) < 3 then
puts( 1, "Usage: comparex filename1 filename2\n")
abort(0)
end if
puts( 1, "\nComparing the following files:\n")
path = {}
for i = 3 to length(cmd) do
path = append( path, cmd[i] )
printf( 1, "File %d: %s\n", { i-2, path[i-2]})
end for
file1 = open(cmd[3], "rb")
file2 = open(cmd[4], "rb")
if file1 = -1 and file2 = -1 then
puts(1,"\nError opening files\n\n")
end if
input_data1 = gets(file1)
input_data2 = gets(file2)
if compare(input_data1,input_data2) = 0 then
puts(1, "\n These files are the same\n")
else
puts(1, "\n These files are not the same\n")
end if
close(file1)
close(file2)
--
Greg Phillips
i.shoot at rednecks.com
http://euphoria.server101.com
--
Useless fact of the day:
If you keep a Goldfish in a dark room it will eventually turn white
|
Not Categorized, Please Help
|
|