From: THAKUR PRASHANT SINGH on 25 Feb 2010 07:07 I am creating zip file using ruby zip there are two versions of creating the zip file 1st version part of class and in 2nd version running it alone. The kmz file created with 1st version doesn't contain complete text of LOC_0.kml Whereas the 2nd version does contain the complete file contents.. I.e. if LOC_0.kml has 100 lines then 1st version kmz file contains only 95 lines while 2nd version contains complete 100 lines. Can you please suggest what can be the reason ? ====================Class function====================== require 'zip/zip' class ZipUtils attr :filename def initialize(filename) @filename=filename end def createkmzfile kml_name=(a)filename puts kml_name kmz_file = kml_name.sub(".kml",".kmz") File.delete(kmz_file) if File.exists?(kmz_file) Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) { |zf| zf.add(kml_name, "kml/#{kml_name}") zf.mkdir("images") imglist=Dir.glob("images/*.png") puts imglist for i in 0..imglist.size-1 zf.add(imglist[i], imglist[i]) end } end end ==========================external file=========================== require 'zip/zip' class ZipUtils attr :filename def initialize(filename) @filename=filename end def createkmzfile end end kml_name="LOC_0.kml" kmz_file = kml_name.sub(".kml",".kmz") puts kml_name File.delete(kmz_file) if File.exists?(kmz_file) Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) { |zf| zf.add(kml_name, "kml/#{kml_name}") zf.mkdir("images") imglist=Dir.glob("images/*.png") puts imglist for i in 0..imglist.size-1 zf.add(imglist[i], imglist[i]) end }
From: Roger Pack on 26 Feb 2010 11:20 > Whereas the 2nd version does contain the complete file contents.. > I.e. if LOC_0.kml has 100 lines then 1st version kmz file contains only > 95 lines while 2nd version contains complete 100 lines. > Can you please suggest what can be the reason ? Did you try different versions of ruby? What platform? -r -- Posted via http://www.ruby-forum.com/.
|
Pages: 1 Prev: Help on algorithm to calculate combinations Next: Ruby class |