This zips the file but file has only first 163 bytes written (original file size ~100K)
What I am doing wrong?
You are using backslashes in the zip-file, which you shouldn't do, but I doubt that is the cause of the problem. Other than that your code works fine on my linux box. I'll try it in windows when I get home. I suspect it is a bug in rubyzip.
As for path separator I am using File::SEPARATOR if this is ok. e.g.
zipfile.file.open('bin' + File::SEPARATOR + 'eclipse.exe', 'w'){ |f|
It's only okay if File::SEPARATOR is a forward slash. The zip spec says that the path separator is a forward slash. Perhaps I should define Zip::SEPARATOR='/' or just make sure to substitute all copies of File::SEPARATOR with '/'.
As for path separator I am using File::SEPARATOR if this is ok. e.g.
zipfile.file.open('bin' + File::SEPARATOR + 'eclipse.exe', 'w'){ |f|
..
Dimitry
I may be wrong, but I believe you can just use forward slashes and ruby will handle it properly regardless of platform. Of course if you are generating paths for consumption outside of ruby then File::SEPARATOR is the ticket...
As for path separator I am using File::SEPARATOR if this is ok. e.g.
zipfile.file.open('bin' + File::SEPARATOR + 'eclipse.exe', 'w'){ |f|
..
Dimitry
I may be wrong, but I believe you can just use forward slashes and
ruby will handle it properly regardless of platform. Of course if you
are generating paths for consumption outside of ruby then
File::SEPARATOR is the ticket...
Even better: File.join("bin", "eclipse.exe")
(And with "eclipse.exe", you can as well hardcode the /...)