ReplicaNet and RNLobby  1
Public Types | Public Member Functions | Protected Member Functions | List of all members
ProductPatcher Class Reference

#include <ProductPatcher.h>

Inheritance diagram for ProductPatcher:
Inheritance graph
[legend]
Collaboration diagram for ProductPatcher:
Collaboration graph
[legend]

Public Types

enum  Status { kSuccess = 0, kErrorEncountered, kAborted }
 

Public Member Functions

bool Start (const char *productPath, const char *patchIndexURL, const char *patchDataURL, const bool multiThread=false, const size_t chunkSize=1024 *1024)
 
bool Stop (void)
 
bool GetCompleted (void)
 
virtual bool CallbackUpdateProgressProduct (const size_t fileIndex, const size_t maxFileIndex)
 
virtual bool CallbackUpdateDownloadPatch (const char *patchingFile, const size_t filePosition, const size_t fileLength)
 
virtual bool CallbackUpdateProgressFile (const char *patchingFile, const size_t filePosition, const size_t fileLength)
 
virtual void CallbackComplete (const Status status)
 A virtual callback that is triggered when the patching is complete.
 
virtual void CallbackFailedToReadFile (const char *file)
 A virtual callback that is triggered when there is an error.
 
virtual bool CallbackProcessFile (const char *file)
 
void GetDownloadAttemptsAndFailed (size_t &attempts, size_t &failed) const
 
void GetDownloadSpeed (size_t &totalBytes, float &overTime) const
 Gets information that can be used to calculate the download speed.
 

Protected Member Functions

void Tidy (void)
 

Detailed Description

This patches a product from patch data and if there are any missing product files these will be created. A file date stamp and checksum cache is used to speed up checking of existing unchanged files.

Member Function Documentation

virtual bool CallbackProcessFile ( const char *  file)
virtual

A virtual callback that is triggered to allow the client application to skip a file in the patch index during the patch process. The file only includes the entry as it is seen in the index and does not include any product path.

Returns
true The default implementation always returns true allowing the file to be patched. Returning false will skip the file during the patching process.
virtual bool CallbackUpdateDownloadPatch ( const char *  patchingFile,
const size_t  filePosition,
const size_t  fileLength 
)
virtual

A virtual callback that is triggered during the patching process.

Returns
True allows the patch to continue. False terminates the patch as quickly as possible.
virtual bool CallbackUpdateProgressFile ( const char *  patchingFile,
const size_t  filePosition,
const size_t  fileLength 
)
virtual

A virtual callback that is triggered during the patching process.

Returns
True allows the patch to continue. False terminates the patch as quickly as possible.
virtual bool CallbackUpdateProgressProduct ( const size_t  fileIndex,
const size_t  maxFileIndex 
)
virtual

A virtual callback that is triggered during the patching process.

Returns
True allows the patch to continue. False terminates the patch as quickly as possible.
bool GetCompleted ( void  )

Tests the completion state of the last patch.

Returns
A completed patch returns true, a patch that is in progress returns false.
void GetDownloadAttemptsAndFailed ( size_t &  attempts,
size_t &  failed 
) const

Gets the number of attempted downloads and the number of downloads that failed and were automatically tried again. This can be useful for giving an indication of the health of a network connection during patching.

bool Start ( const char *  productPath,
const char *  patchIndexURL,
const char *  patchDataURL,
const bool  multiThread = false,
const size_t  chunkSize = 1024 *1024 
)

Starts patching a product given patch data paths.

Parameters
productPathThe paths to the product to patch.
multiThreadBy default the scan does not use an extra thread. Using true will start a thread to start the patch process and Start() will return immediately.
chunkSizeThe number of bytes to use for a file buffer when accessing files. By default this uses a megabyte. The larger the buffer the quicker the download will be but the calls to CallbackUpdateDownloadPatch() will be less frequent.
Returns
Success returns true, failure returns false.
bool Stop ( void  )

Stops the current patch if it is running.

Returns
Success returns true, failure returns false.