Creating a zip file without storing relative paths of file folders

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating a zip file without storing relative paths of file folders

Offray Vladimir Luna Cárdenas-2
Hi :-),

I'm creating a Grafoscopio interactive notebook for learning Lua and
making a small video game with the LÖVE 2D game engine, following the
excellent SheepPollution video series[1]. My first video game is now
working (the old classic Pong) and the notebook contains actionable web
links, text notes and code playgrounds for making clerical work
(creating the initial empty .lua files, downloading the libraries,
packaging all as zip files).

[1]
https://www.youtube.com/watch?v=TUPbSJ5wF0k&list=PLM5EvDHhpyTcThnWfeP1459KelemQOBdG&index=1

Precisely, while trying to package the game as a zip file I'm having the
problem that files are archived with their relative path, and so,
they're in a zip with a lot of nested folders (like in my hard disk)
instead of being just zipped in the root of the zip file. The script I'm
using for that is at [2]. There is any way to tell ZipArchive or
ZipNewFileMember that members are not stored with their full path?

[2] http://ws.stfx.eu/OOW0539JDHH2

Thanks,

Offray

Ps: Learning Lua has been a pleasant experience now that I have the
Pharo/Smalltalk foundation and interactive notebooks, powered by it, and
the Lua language is pretty neat also.


Reply | Threaded
Open this post in threaded view
|

Re: Creating a zip file without storing relative paths of file folders

Nicolai Hess-3-2


2017-01-04 4:44 GMT+01:00 Offray Vladimir Luna Cárdenas <[hidden email]>:
Hi :-),

I'm creating a Grafoscopio interactive notebook for learning Lua and making a small video game with the LÖVE 2D game engine, following the excellent SheepPollution video series[1]. My first video game is now working (the old classic Pong) and the notebook contains actionable web links, text notes and code playgrounds for making clerical work (creating the initial empty .lua files, downloading the libraries, packaging all as zip files).

[1] https://www.youtube.com/watch?v=TUPbSJ5wF0k&list=PLM5EvDHhpyTcThnWfeP1459KelemQOBdG&index=1

Precisely, while trying to package the game as a zip file I'm having the problem that files are archived with their relative path, and so, they're in a zip with a lot of nested folders (like in my hard disk) instead of being just zipped in the root of the zip file. The script I'm using for that is at [2]. There is any way to tell ZipArchive or ZipNewFileMember that members are not stored with their full path?

I don't know if this is the supposed way to do  this, but can you try to use addFile:as: instead of addMember:
(gameFolder childrenMatching: '*.lua') 
	do: [:luaFile | zip addFile: luaFile pathString as: luaFile basename)]. 

 

[2] http://ws.stfx.eu/OOW0539JDHH2

Thanks,

Offray

Ps: Learning Lua has been a pleasant experience now that I have the Pharo/Smalltalk foundation and interactive notebooks, powered by it, and the Lua language is pretty neat also.



Reply | Threaded
Open this post in threaded view
|

Re: Creating a zip file without storing relative paths of file folders

Offray Vladimir Luna Cárdenas-2

Thanks Nicolai,

What I was trying to do was to package all the *.lua files as a .zip file, with the .love extension, to package the video game. This one did the trick:

(gameFolder childrenMatching: '*.lua')
    do: [:luaFile | zip addFile: luaFile as: luaFile basename].

Cheers,

Offray

On 04/01/17 04:52, Nicolai Hess wrote:


2017-01-04 4:44 GMT+01:00 Offray Vladimir Luna Cárdenas <[hidden email]>:
Hi :-),

I'm creating a Grafoscopio interactive notebook for learning Lua and making a small video game with the LÖVE 2D game engine, following the excellent SheepPollution video series[1]. My first video game is now working (the old classic Pong) and the notebook contains actionable web links, text notes and code playgrounds for making clerical work (creating the initial empty .lua files, downloading the libraries, packaging all as zip files).

[1] https://www.youtube.com/watch?v=TUPbSJ5wF0k&list=PLM5EvDHhpyTcThnWfeP1459KelemQOBdG&index=1

Precisely, while trying to package the game as a zip file I'm having the problem that files are archived with their relative path, and so, they're in a zip with a lot of nested folders (like in my hard disk) instead of being just zipped in the root of the zip file. The script I'm using for that is at [2]. There is any way to tell ZipArchive or ZipNewFileMember that members are not stored with their full path?

I don't know if this is the supposed way to do  this, but can you try to use addFile:as: instead of addMember:
(gameFolder childrenMatching: '*.lua') 
	do: [:luaFile | zip addFile: luaFile pathString as: luaFile basename)]. 

 

[2] http://ws.stfx.eu/OOW0539JDHH2

Thanks,

Offray

Ps: Learning Lua has been a pleasant experience now that I have the Pharo/Smalltalk foundation and interactive notebooks, powered by it, and the Lua language is pretty neat also.