Conversation
MisterDA
left a comment
There was a problem hiding this comment.
Consider using NULL instead of 0. This is more consistent with the code.
lua_zip.c
Outdated
|
|
||
| if (!errmsg && path) { | ||
| FILE *fp = fopen(path, "rb"); | ||
| if (!fp) errmsg = strerror(errno); //FIXME: strerror() is not thread-safe |
There was a problem hiding this comment.
It should be fine to use strerror_r with a buffer of len 1024.
lua_zip.c
Outdated
| fseek(fp, 0, SEEK_END); | ||
| buf_sz = ftell(fp); | ||
| fseek(fp, 0, SEEK_SET); | ||
| //char *data = (char*)malloc(buf_sz); |
There was a problem hiding this comment.
Please don't leave commented code.
|
MisterDA, I followed your advice. Now I need create new PR? |
|
No, but you can rebase and force push if you want to, but that's not a big deal to me. |
|
Sorry for the delay, things are pretty busy for me, so I probably won't be able to give this a great deal of attention until the weekend. With that said, I did give a quick look at the code and I wonder if we could improve the API a bit. In particular, calling a method with a string that is either "file" or "string" argument seems a bit unexpected. Perhaps we could only have an API that takes the string argument, and avoid doing a file read? Users of the API should be able to use their own code to "slurp" the file into memory. So, the new API would only support this:
By removing support for a filename, it will make it easier to sandbox (in case a sandbox implementer wants to disable filesystem access and/or used in a non-blocking async context). It also slightly reduces the code we need to maintain. Also, instead of reusing the If you are open to this idea, I should be able to get some time over the weekend to flesh this idea out a bit more. Or, if you want to take a stab, that would be great! Thanks! |
|
I like the idea about new metatable. While feeling some inconvenience with "__source_memory" your idea is nicer to me.
Thanks! |
merge from origin
Routine lets create zip archive in memory. Then we can send zip over network for example without saving it to disk.