I've been searching for an answer to this problem but haven't found a working solution. Our product has a built in webserver and uses the HTTP POST command to perform software updates. The update is a targz file with two files in it. In response to the POST command I am trying to do this:
part = ::popen("tar –xvz --overwrite -C /dev -f -", "w");
From what I understand, the "-f -" works on the command line when used with the "|" operator. The popen succeeds, but on the console, I see this:
tar: invalid option -- '�'
Try 'tar --help' or 'tar --usage' for more information.
I have tried without the "-C" and "--overwrite" switches without success. What I am expecting is that tar would wait on reading the pipe while our software streams the file contents with fwrite(), and call pclose() when all the data is transferred. But tar is closing its pipe and exiting on the popen(), and the first fwrite() fails.
Is there any way to make this work without saving to an intermediate file? The files are disk images so can be large, over 2GB.
I am running this on a Raspberry Pi 4 with the latest image, which is based on Debian.