How to save stream file to specific path on Mac

Dec 31, 2014 at 3:01 AM
Edited Dec 31, 2014 at 6:49 AM
Hi,

I'm facing problem on Mac when try to get file from server and save to the specific path:
on Mac: std::string filePath ="Macintosh:Users:<username>:folder1:folder2:fileName.jpg";
on Win: std::string filePath ="C:\Users\<username>\folder1\folder2\fileName.jpg";
file_buffer<uint8_t>::open(filePath , std::ios::out).then([=](streambuf<uint8_t> outFile) -> pplx::task<http_response>
            {
                *fileBuffer = outFile; 

                // Create an HTTP request.
                // Encode the URI query since it could contain special characters like spaces.              
                web::http::client::http_client client(addrr);
                return client.request(request);
            }).......................
on Window it works fine.
but on Mac the fileName is auto changed to "Macintosh/Users/<username>/folder1/folder2/fileName.jpg" and saved to the path of running program. not save to the path "Macintosh:Users:<username>:folder1:folder2:"
I had a look at template of ::Open(...), and found that the filePath is understood fileName by Mac.

so how to save the file "fileName.jpg" to the specific path "Macintosh:Users:<username>:folder1:folder2:" directly on Mac?
currently I'm using moveFile function to do this.

thanks
Coordinator
Jan 2, 2015 at 9:09 PM
Hi coiphim2511,

I'd recommend not using the ':' colon character for file paths. Under the covers our library is using the POSIX APIs for file I/O, which work with slashes. I just did a test, if I write the file path as "/Users/<username>/folder1/folder2/fileName.jpg" it works exactly as expected.

Steve