You are not logged in.
I have written a server program in C which reads and saves a large file send by a web browser chunk by chunk. While file transfer is done I see unwanted carriage returns ^M in the transferred file.
My server programs runs on the Linux and file is transferred by a web browser installed in windows using HTTP POST over the network. On server I am using named pipe for receiving
and writing chunks to a file in Linux. Is there any way to remove ^M while file transfer is in progress? I can not wait till the whole file is transferred and then running a dos2unix like utility. I am using
O_RDWR flag while opening named pipe sender end in server.
Thanks in advance.
Sure, just have your receiver strip the CRs before writing to the file... Use strchr() or just scan through the data looking for the CRs, then memmove() the rest of the string down over them to overwrite them... This assumes the file data doesn't contain spurious CRs which appear in the middle of lines which you need to retain... If it does, you'll have to use strstr() or something to look for "\r\n" together, then just overwrite the CR... And, of course, this will only ever work for text files; if you try stripping CRs from a binary, you're going to end up with a corrupted binary file!