open_memstream on non-linux?

Miika Turkia miika.turkia at gmail.com
Mon Mar 11 10:46:14 PDT 2013


On Mon, Mar 11, 2013 at 7:09 PM, Lubomir I. Ivanov <neolit123 at gmail.com> wrote:
> On 11 March 2013 18:19, Dirk Hohndel <dirk at hohndel.org> wrote:
>> There is some discussion and code on working around that here…
>>
>> http://stackoverflow.com/questions/10305095/can-i-replace-a-call-to-open-memstream-with-a-malloc-and-an-implicit-cast
>>
>> which looks way overkill to me.
>>
>> Miika - any way you could reimplement this differently? :-)
>>
>
> here is my attempt for miika's reference.
>
> it also now, uses ./ for the temp zip file, since obviously /tmp/
> isn't portable to non-UNIX OS. instead i would write the temp file in
> the home directory, which we should retrieve in a OS specific way
> using e.g. subsurface_get_home_path().
>
> i don't think libzip supports API for working with memory buffers.
> but on the other hand temp files can be bad...

I need sys/io.h instead of plain io.h for this to compile. Otherwise
it seems to work fine on my Linux box.

The temporary files might be quite problematic as there is no
guarantees that CWD is writable. Maybe just using the same location
where the logs are saved? Also we need to remember to unlink the temp
files once we have the real upload code in place.

miika


More information about the subsurface mailing list