pw_transfer API reference#

Note

This API reference is a work-in-progress. The full pw_transfer API is not yet documented on this page.

namespace transfer#
class AtomicFileTransferHandler : public ReadWriteHandler#

AtomicFileTransferHandler is intended to be used as a transfer handler for files. It ensures that the target file of the transfer is always in a correct state. In particular, the transfer is first done to a temporary file and once complete, the original targeted file is updated.

Public Functions

inline AtomicFileTransferHandler(uint32_t resource_id, std::string_view file_path)#
Parameters:
  • resource_id[in] An ID for the resource that’s being transferred.

  • file_path[in] The target file to update.

Status PrepareRead() override#

Prepares AtomicFileTransferHandler for a read transfer.

Pre:

The read transfer has not been initialized before the call to this method.

Returns:

Code

Description

OK

AtomicFileTransferHandler is ready for the transfer.

void FinalizeRead(Status) override#

Handler function that is called by the transfer thread after a read transfer completes.

Parameters:

Status – A pw::Status object provided by the transfer thread indicating whether the transfer succeeded.

Pre:

The read transfer is done before the call to this method.

Status PrepareWrite() override#

Prepares AtomicFileTransferHandler for a write transfer.

Pre:

The write transfer has not been initialized before the call to this method.

Returns:

Code

Description

OK

AtomicFileTransferHandler is ready for the transfer.

Status FinalizeWrite(Status) override#

Indicates whether the write transfer was successful.

Pre:

The write transfer is done.

Returns:

Code

Description

OK

The transfer data was successfully written.