T
THAKUR PRASHANT SINGH
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 ?
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DClass =
function=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
require
'zip/zip'
class ZipUtils
attr :filename
def initialize(filename)
@filename=3Dfilename
end
def createkmzfile
kml_name=3D@filename
puts kml_name
kmz_file =3D kml_name.sub(".kml",".kmz")
=20
File.delete(kmz_file) if File.exists?(kmz_file)
=20
Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) {
|zf|
zf.add(kml_name, "kml/#{kml_name}")
zf.mkdir("images")
imglist=3DDir.glob("images/*.png")
puts imglist=20
for i in 0..imglist.size-1
zf.add(imglist, imglist)
end =20
}
=20
end
end
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3Dexternal =
file=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
require 'zip/zip'
class ZipUtils
attr :filename
def initialize(filename)
@filename=3Dfilename
end
def createkmzfile
=20
end
end
kml_name=3D"LOC_0.kml"
kmz_file =3D kml_name.sub(".kml",".kmz")
puts kml_name
File.delete(kmz_file) if File.exists?(kmz_file)
=20
Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) {
|zf|
zf.add(kml_name, "kml/#{kml_name}")
zf.mkdir("images")
imglist=3DDir.glob("images/*.png")
puts imglist=20
for i in 0..imglist.size-1
zf.add(imglist, imglist)
end
}
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 ?
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DClass =
function=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
require
'zip/zip'
class ZipUtils
attr :filename
def initialize(filename)
@filename=3Dfilename
end
def createkmzfile
kml_name=3D@filename
puts kml_name
kmz_file =3D kml_name.sub(".kml",".kmz")
=20
File.delete(kmz_file) if File.exists?(kmz_file)
=20
Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) {
|zf|
zf.add(kml_name, "kml/#{kml_name}")
zf.mkdir("images")
imglist=3DDir.glob("images/*.png")
puts imglist=20
for i in 0..imglist.size-1
zf.add(imglist, imglist)
end =20
}
=20
end
end
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3Dexternal =
file=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
require 'zip/zip'
class ZipUtils
attr :filename
def initialize(filename)
@filename=3Dfilename
end
def createkmzfile
=20
end
end
kml_name=3D"LOC_0.kml"
kmz_file =3D kml_name.sub(".kml",".kmz")
puts kml_name
File.delete(kmz_file) if File.exists?(kmz_file)
=20
Zip::ZipFile.open(kmz_file, Zip::ZipFile::CREATE) {
|zf|
zf.add(kml_name, "kml/#{kml_name}")
zf.mkdir("images")
imglist=3DDir.glob("images/*.png")
puts imglist=20
for i in 0..imglist.size-1
zf.add(imglist, imglist)
end
}