Firstly I am looking for a way to generate a unique identifier from a folder and zip file separately. If the contents of the folder and the zip file match the same identifier should be returned. This will be used to ensure the server and clients have matching content and as such can play together.
Secondly I am looking for a way to zip a folders contents from within lua. If for example the servers 'content' folder is different from its 'content.zip' I would like to automatically generate a new one from the folder.
Semi-Unique id for folder/zip and zipping folder.
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Semi-Unique id for folder/zip and zipping folder.
Simply have the config file carry a version variable, and download and optionally unpack the archive from the server if it's different. Actual install validation is not necessary, it usually just won't work and worst case scenario it'll glitch, either way that is solved by doing new install.
ID-wise, what you're looking for is some sort of hash function, that you run over all of your files' contents. Naturally I don't recommend using cryptographic hashes because it'll take forever to hash all of your files. A simple checksum often would suffice, collisions should be rare if any, plus you can always produce a different hash by adding a dumbbell file with arbitrary contents.
ID-wise, what you're looking for is some sort of hash function, that you run over all of your files' contents. Naturally I don't recommend using cryptographic hashes because it'll take forever to hash all of your files. A simple checksum often would suffice, collisions should be rare if any, plus you can always produce a different hash by adding a dumbbell file with arbitrary contents.
Re: Semi-Unique id for folder/zip and zipping folder.
The config file method would not be the ideal solution since server to server content will vary greatly. Not only that but clients could just falsify there local data easily creating a method for cheating. The zip files which will be sent/received will ideally also be encrypted to decrease the average script kiddy from cheating.
Also I don't need something as complex as a hash, a crc or the like would suffice I'm just not familiar with performing such a thing from lua.
Also I don't need something as complex as a hash, a crc or the like would suffice I'm just not familiar with performing such a thing from lua.
Re: Semi-Unique id for folder/zip and zipping folder.
You read a file, run a hash function over its contents, close a file. Rinse and repeat. Checksum would take byte's value as integer and add it to accumulator variable, which is never reset and therefore keeps byte value sum of all files, which you trivially can check against.
Re: Semi-Unique id for folder/zip and zipping folder.
Ah so a checksum is just a sort of short number value which presumably iterates within a set range looping back around when it gets to large.
Re: Semi-Unique id for folder/zip and zipping folder.
It doesn't matter. It just have to have enough range not to cause collisions between versions.
Re: Semi-Unique id for folder/zip and zipping folder.
I see how I could implement such a thing and I can simply mount the zip file to a dummy path to check it. That's the more important thing resolves, now a way to automatically zip a folder through lua would certainly improve my project though isn't as important.
EDIT: I'll post a working script for whatever it is I decide on for others to use in the 'Libraries and Tools' forum.
EDIT: I'll post a working script for whatever it is I decide on for others to use in the 'Libraries and Tools' forum.
Re: Semi-Unique id for folder/zip and zipping folder.
Your best bet is to use a command line zipping tool. Hooking up compression dynamic link library is not easy nor straightforward.
Who is online
Users browsing this forum: No registered users and 78 guests