ReplicaNet and RNLobby  1
Classes | Public Member Functions | Static Public Member Functions | List of all members
ScanPath Class Reference

This scans a supplied path and stores the results. More...

#include <ScanPath.h>

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

Classes

struct  Entry
 An entry in the list updated by ScanPath::Start() More...
 
struct  FileChecksum
 

Public Member Functions

bool Start (const char *path, std::list< Entry > &result, const bool recurse=false, const bool justFiles=true, const bool multiThread=false)
 
bool Stop (void)
 
bool GetCompleted (void)
 
virtual bool CallbackUpdate (const size_t numFiles, const size_t numFolders)
 
virtual void CallbackComplete (void)
 A virtual callback that is triggered when the scanning is complete.
 

Static Public Member Functions

static bool Write (const char *path, const std::list< Entry > &entries)
 A utility function to write the entries to a file.
 
static bool Read (const char *path, std::list< Entry > &entries)
 A utility function to read the entries from a file.
 

Detailed Description

This scans a supplied path and stores the results.

Member Function Documentation

virtual bool CallbackUpdate ( const size_t  numFiles,
const size_t  numFolders 
)
virtual

A virtual callback that is triggered when the scanning status is updated.

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

Tests the completion state of the last scan.

Returns
A completed scan returns true, a pending scan returns false.
bool Start ( const char *  path,
std::list< Entry > &  result,
const bool  recurse = false,
const bool  justFiles = true,
const bool  multiThread = false 
)

Starts scanning a path using an optional new thread. If a scan is already running the previous scan is stopped.

Parameters
pathThe path to start scanning from.
resultThe std::list<RNReplicaNet::RNLobby::ScanPath::Entry> to use for storing results of the scan. The result is not cleared when the scan starts allowing results on other scans to be appended to the std::list. To access the result before the scan is finished use pairs of ScanPath::Lock()/UnLock() to lock access to the result variable using the thread mutex.
recurseBy default recursive scanning of the input path is disabled.
justFilesBy default only file names are added to the results of the scan.
multiThreadBy default the scan does not use an extra thread. Using true will start a thread to start scanning and Start() will return immediately.
Returns
Success returns true, failure returns false.
bool Stop ( void  )

Stops the current scan if it is running.

Returns
Success returns true, failure returns false.