Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cSyncContext Class Reference

#include <cSyncDir.h>

Inheritance diagram for GrayLib::cSyncContext:
GrayLib::cManifestContext GrayLib::cManifestRoot

Public Member Functions

 cSyncContext (cStringF sDirRoot, const FILECHAR_t *pszManifestFileName=nullptr, cLogProcessor *pLog=nullptr, IStreamProgressCallback *pProgress=nullptr)
 
 cSyncContext (const cManifestContext &context)
 
 ~cSyncContext ()
 
HRESULT _cdecl LogFileOpf (LOG_ATTR_MASK_t uAttrMask, LOGLEV_TYPE eLogLevel, const FILECHAR_t *pszFile, const LOGCHAR_t *pszFormat,...)
 
HRESULT SendFile (cStringF sFilePathSrc, cStringF sRelPathDest, IStreamProgressCallback *pProgress1=nullptr, FILE_SIZE_t nOffset=0, FILE_SIZE_t nSize=(FILE_SIZE_t) -1)
 
HRESULT RequestFile (cStringF sRelPathSrc, cStringF sFilePathDest, IStreamProgressCallback *pProgress1=nullptr, FILE_SIZE_t nOffset=0, FILE_SIZE_t *pnSizeEst=nullptr)
 
cStringF GetManifestCacheName (cStringF sManRemoteDir) const
 
HRESULT FlushManifestCache (cStringF sManRemoteDir="")
 
HRESULT SyncManifestFromCache (cManifestDir &manRemote, cStringF sManRemoteDest)
 
HRESULT SyncManifestFromRemote2 (cManifestDir &manRemote, cStringF sManRemoteDir, cStringF sManifestCacheName)
 
HRESULT SyncManifestFromRemote (cManifestDir &manRemote, cStringF sManRemoteDir)
 
HRESULT SyncIfChanged (cManifestDir &manRemote, const FILECHAR_t *pszSrcName, const FILECHAR_t *pszLocalName=nullptr)
 
HRESULT SyncDirPackage (cStringF sPathLocalDir)
 
HRESULT SetLocalAttr (const FILECHAR_t *pszLocalPath, const cManifestElem *pFileDst, bool bSetName)
 
HRESULT SetLocalAttrAndCRC (const FILECHAR_t *pszLocalPath, const cManifestElem *pFileDst, bool bSetName)
 
HRESULT SetLocalAttr2 (const FILECHAR_t *pszLocalPath, const cManifestElem *pFileDst, bool bSetName)
 
- Public Member Functions inherited from GrayLib::cManifestContext
 cManifestContext (cStringF sDirRoot, const FILECHAR_t *pszManifestFileName=nullptr, cLogProcessor *pLog=nullptr, IStreamProgressCallback *pProgress=nullptr)
 
 ~cManifestContext ()
 
HRESULT UpdateProgress (const cStreamProgress &s)
 
- Public Member Functions inherited from GrayLib::cManifestRoot
 cManifestRoot (cStringF sRootDir, const FILECHAR_t *pszManifestFileName=nullptr)
 
 ~cManifestRoot ()
 
cStringF get_RootDir () const
 
void put_RootDir (cStringF sRootDir)
 
bool isRootDir (const FILECHAR_t *pszDirPath) const
 
bool isInRootPath (const FILECHAR_t *pszDirPath) const
 
cStringF makeFullPath (const FILECHAR_t *pszRelativePath) const
 
cStringF makeRelativePath (const FILECHAR_t *pszDirPath) const
 
HRESULT ReadSearchForTitle (cStringF &sPathRet, const FILECHAR_t *pszTitle, int iDescendLevels) const
 

Static Public Member Functions

static HRESULT GRAYCALL DoMoveLimboFiles (const FILECHAR_t *pszRootDir, cLogProcessor *pLog, IStreamProgressCallback *pProgress)
 

Public Attributes

IFileCopierm_pRemoteConnect
 transfer remote files via this connection to a remote file system. If we are CSYNC_Push then it must allow time stamp setting. More...
 
cSyncOpPtr m_pOpRoot
 full list/tree of operations to be performed on all dirs More...
 
TIMESECD_t m_nManifestCacheAge
 allow remote/server Manifest cache to be this old. (seconds), 0=no cache. More...
 
cStringF m_sManCachePrefix
 file path prefix (Destination directory) for caching manifests. More...
 
cStreamProgress m_Rx
 total file data to pull. More...
 
cStreamProgress m_Tx
 total file data to push. More...
 
- Public Attributes inherited from GrayLib::cManifestContext
cLogProcessorm_pLog
 Route status messages to this logger. More...
 
IStreamProgressCallbackm_pProgress
 Send progress info to some outside party on the action(s) we are taking. More...
 
- Public Attributes inherited from GrayLib::cManifestRoot
const FILECHAR_tm_pszManifestFileName
 "Manifest.scp" // name of the local manifest files. (one per dir) More...
 

Static Public Attributes

static const FILECHAR_t sm_szLimboDir [] = _FN("synclimbo")
 put files here that are locked when i try to sync them. More...
 
- Static Public Attributes inherited from GrayLib::cManifestRoot
static const FILECHAR_tk_pszManifestDefault = _FN("Manifest.scp")
 "Manifest.scp" More...
 

Additional Inherited Members

- Protected Attributes inherited from GrayLib::cManifestRoot
cStringF m_sRootDir
 full path to the (local system) root directory we are syncing or building manifests for. More...
 

Detailed Description

we are building a list of sync actions or we are actually performing those actions. Use IStreamProgressCallback to get the progress callback from a single action.

Constructor & Destructor Documentation

◆ cSyncContext() [1/2]

GrayLib::cSyncContext::cSyncContext ( cStringF  sDirRoot,
const FILECHAR_t pszManifestFileName = nullptr,
cLogProcessor pLog = nullptr,
IStreamProgressCallback pProgress = nullptr 
)

◆ cSyncContext() [2/2]

GrayLib::cSyncContext::cSyncContext ( const cManifestContext context)

◆ ~cSyncContext()

GrayLib::cSyncContext::~cSyncContext ( )

Member Function Documentation

◆ DoMoveLimboFiles()

HRESULT GRAYCALL GrayLib::cSyncContext::DoMoveLimboFiles ( const FILECHAR_t pszRootDir,
cLogProcessor pLog,
IStreamProgressCallback pProgress 
)
static

Move any limbo files before doing anything else.

Note
we need to regenerate manifests for these directories after doing this !
Returns
<0 or S_OK = nothing to do. Number of files moved.

◆ FlushManifestCache()

HRESULT GrayLib::cSyncContext::FlushManifestCache ( cStringF  sManRemoteDir = "")

Assume the server/remove side has changed. Cache is invalid!

◆ GetManifestCacheName()

cStringF GrayLib::cSyncContext::GetManifestCacheName ( cStringF  sManRemoteDir) const

Create a full local path name for a cached element. assume we check the date on the cache to age it out.

  • sManRemoteDir = makeRelativePath( manRemote.get_DirPath())
    Returns
    the path in the manifest local file cache.

◆ LogFileOpf()

HRESULT _cdecl GrayLib::cSyncContext::LogFileOpf ( LOG_ATTR_MASK_t  uAttrMask,
LOGLEV_TYPE  eLogLevel,
const FILECHAR_t pszFile,
const LOGCHAR_t pszFormat,
  ... 
)

Log that some operation occurred on the file.

◆ RequestFile()

HRESULT GrayLib::cSyncContext::RequestFile ( cStringF  sRelPathSrc,
cStringF  sFilePathDest,
IStreamProgressCallback pProgress1 = nullptr,
FILE_SIZE_t  nOffset = 0,
FILE_SIZE_t pnSizeEst = nullptr 
)

Request a file from the remote/server and receive response. Don't care why at this point. like IFileCopier

  • sFilePathDest = full path for local destination. nSizeEst = may or may not be the accurate file size. 0 = request size. pProgress1 = report the progress of this 1 file.

◆ SendFile()

HRESULT GrayLib::cSyncContext::SendFile ( cStringF  sFilePathSrc,
cStringF  sRelPathDest,
IStreamProgressCallback pProgress1 = nullptr,
FILE_SIZE_t  nOffset = 0,
FILE_SIZE_t  nSize = (FILE_SIZE_t)-1 
)

Send a local file to the remote. like IFileCopier

  • sFilePathSrc = "" = delete sRelPathDest.
  • pProgress1 = report the progress of this 1 file.

◆ SetLocalAttr()

HRESULT GrayLib::cSyncContext::SetLocalAttr ( const FILECHAR_t pszLocalPath,
const cManifestElem pFileDst,
bool  bSetName 
)

the file contents are the same. Set (make sure) the local file has same attributes.

Returns
S_OK = no change. 1 = changed.

◆ SetLocalAttr2()

HRESULT GrayLib::cSyncContext::SetLocalAttr2 ( const FILECHAR_t pszLocalPath,
const cManifestElem pFileDst,
bool  bSetName 
)

Validate the CRC of the Rx file. If invalid then delete the file.

◆ SetLocalAttrAndCRC()

HRESULT GrayLib::cSyncContext::SetLocalAttrAndCRC ( const FILECHAR_t pszLocalPath,
const cManifestElem pFileDst,
bool  bSetName 
)

Double check all PE/EXE content for signing.

◆ SyncDirPackage()

HRESULT GrayLib::cSyncContext::SyncDirPackage ( cStringF  sPathLocalDir)

Ask for a directory/package as a zip file from the remote/server.

Todo:
fix this->m_pProgress

◆ SyncIfChanged()

HRESULT GrayLib::cSyncContext::SyncIfChanged ( cManifestDir manRemote,
const FILECHAR_t pszSrcName,
const FILECHAR_t pszLocalName = nullptr 
)

Special Check for a specific file in the manifest. (Not normal mechanism) if it has changed then get it from the remote/server.

Note
Just check date and size. Can't check CRC for this. pszSrcName = the source file name. (on remote/server) pszLocalName = the local file name.
Returns
S_FALSE = no change. S_OK = changed and updated. E_HANDLE = file is not in the manifest. error. <0 = some other error.

◆ SyncManifestFromCache()

HRESULT GrayLib::cSyncContext::SyncManifestFromCache ( cManifestDir manRemote,
cStringF  sManRemoteDest 
)

Get remote side manifest from cache?

Note
remember to check the date on the cache to age it out.

◆ SyncManifestFromRemote()

HRESULT GrayLib::cSyncContext::SyncManifestFromRemote ( cManifestDir manRemote,
cStringF  sManRemoteDir 
)

Request the Remote manifest list for this folder from the remote/server. The Remote/server manifest file is what it is supposed to be vs What we actually have locally. sManRemoteDir = makeRelativePath( manRemote.get_DirPath()) HRESULT_WIN32_C(ERROR_INVALID_TABLE) = corrupt file.

◆ SyncManifestFromRemote2()

HRESULT GrayLib::cSyncContext::SyncManifestFromRemote2 ( cManifestDir manRemote,
cStringF  sManRemoteDir,
cStringF  sManifestCacheName 
)

Request the Remote manifest list for this folder from the remote/server. The Remote/server manifest file is what it is supposed to be vs What we actually have locally. HRESULT_WIN32_C(ERROR_INVALID_TABLE) = corrupt file.

Member Data Documentation

◆ m_nManifestCacheAge

TIMESECD_t GrayLib::cSyncContext::m_nManifestCacheAge

allow remote/server Manifest cache to be this old. (seconds), 0=no cache.

◆ m_pOpRoot

cSyncOpPtr GrayLib::cSyncContext::m_pOpRoot

full list/tree of operations to be performed on all dirs

◆ m_pRemoteConnect

IFileCopier* GrayLib::cSyncContext::m_pRemoteConnect

transfer remote files via this connection to a remote file system. If we are CSYNC_Push then it must allow time stamp setting.

◆ m_Rx

cStreamProgress GrayLib::cSyncContext::m_Rx

total file data to pull.

◆ m_sManCachePrefix

cStringF GrayLib::cSyncContext::m_sManCachePrefix

file path prefix (Destination directory) for caching manifests.

◆ m_Tx

cStreamProgress GrayLib::cSyncContext::m_Tx

total file data to push.

◆ sm_szLimboDir

const FILECHAR_t GrayLib::cSyncContext::sm_szLimboDir = _FN("synclimbo")
static

put files here that are locked when i try to sync them.

put new files here that are locked when i try to sync (replace) them. So we can try again later?


The documentation for this class was generated from the following files: