I am using curl to download files from the internet and it is working fine. The problem is that I am trying to check if the file exists before downloading it. I was thinking that if the file doesn't exist, then I would receive a CURLcode with and error, but instead of that, I am always receiving CURLE_OK.

Is there a way to check if the file exists with curl? If not, which is the best way to do it in c++?

Thank you in advance.

Is the file hosted behind an HTTP server? An HTTP HEAD request should result in a 404 if it's missing, but if it's there, it won't send the body (i.e., the file contents). cURL can do that.

Thank you for your answer.

I tried that at first, but then I needed to parse the 404 error to a string and then search for the error, so some extra code to implement.
I finally realized that I can get the RESPONSE CODE after trying to open the file and I think that's enough for the purpose I had, unless someone thinks that there is a better way to do it.