ID:138726
 
Code:
proc/Log(l,a=1)
if( !log ) log = file( LOG_NAME )
if( length(log) >= 50 )
var/zipfile/z = new("log.zip")
z.Import("[LOG_NAME]","//log_[z.contents.len].txt")
z.Close()
fdel( LOG_NAME )
log = file( LOG_NAME )

l = "\[[time2text(world.realtime)]] [l]"
log << l

if( DREAMDAEMON )
if( _host.len )
for( var/c in _host )
if(a) c << "[l]"

if(a) world.log << "[l]"


Problem description:
The piece of code is meant to automatically archive log files that grow over a certain size and put them in a zip file (using dantom.zipfile). I've been testing it and so far it seems to silently fail upon importing any files other than the first log into the zipfile. Any ideas?
How are you calling the logs and where?
According to hub://Dantom.Zipfile, "you cannot modify existing zip archives."
In response to Nickr5
ah, thank you.
In response to Metamorphman
Right, due to a limitation with the implementation of libzip you have to remove the zip first before trying to modify it. (making a new one)
In response to Nadrew
Woah! Didn't see you replied. And yeah, got it working now :)
Do you reckon we could have something like 7zip support in the future?
In response to Metamorphman
You can if you use
shell(7zip.exe commands file etc)
make sure the 7zip exe is in the same folder as the game...

Not too hard just play around with it.

[EDIT] although to do this you would have the save the log file first then insert it into a 7zip, then you can delete the log file and start a new once saved.

IMO you should save the log file name as a Date then you can easily navigate it. you can also unzip and read the files. up to you how you solve this. I would make a quick library for you later on.

http://www.dotnetperls.com/7-zip-examples
In response to A.T.H.K
That would require distributing the 7zip exe with your game, which is against their EULA. It would also fail if the game was being hosted on Linux.
In response to Nadrew
Nadrew wrote:
That would require distributing the 7zip exe with your game, which is against their EULA. It would also fail if the game was being hosted on Linux.

Sorry didn't check the EULA, also true thanks!