MCPcopy Create free account
hub / github.com/SFML/SFML / upload

Method upload

src/SFML/Network/Ftp.cpp:338–366  ·  view source on GitHub ↗

///////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

336
337////////////////////////////////////////////////////////////
338Ftp::Response Ftp::upload(const std::filesystem::path& localFile,
339 const std::filesystem::path& remotePath,
340 TransferMode mode,
341 bool append)
342{
343 // Get the contents of the file to send
344 std::ifstream file(localFile, std::ios_base::binary);
345 if (!file)
346 return Response(Response::Status::InvalidFile);
347
348 // Open a data channel using the given transfer mode
349 DataChannel data(*this);
350 Response response = data.open(mode);
351 if (response.isOk())
352 {
353 // Tell the server to start the transfer
354 response = sendCommand(append ? "APPE" : "STOR", (remotePath / localFile.filename()).string());
355 if (response.isOk())
356 {
357 // Send the file data
358 data.send(file);
359
360 // Get the response from the server
361 response = getResponse();
362 }
363 }
364
365 return response;
366}
367
368
369////////////////////////////////////////////////////////////

Callers 2

mainFunction · 0.45
mainFunction · 0.45

Calls 3

openMethod · 0.45
isOkMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected