From: Daniel Schnell Date: 2002-11-08T23:12:00+09:00 Subject: File::read Performance Hi there, if I make the following implementation of the command "cp" with ruby, the read Performance is really bad. Can I improve it in any way ? Thx in advance, Daniel. # # copies source to destionation # def cp(source, dest) Dir[source].each {|f| if (File.directory?(dest)) then outfilename=dest+"/"+File.basename(f) else outfilename=dest end puts outfilename inF = File.new(f, "r") #p rescue "ERROR: #$!" if (!inF) then printf("%s: Could not open output file %s, maybe insufficient rights ?\n", PROGRAM_NAME, f) inF.close() next end outF = File.new(outfilename, "w+") if (!outF) then printf("%s: Could not open output file %s, maybe insufficient rights ?\n", PROGRAM_NAME, outfilename) inF.close() next end # now read outF.binmode inF.binmode while (! inF.eof() ) outF << inF.read(8192) end outF.close() inF.close() } end