#include <Poco/File.h>
#include <Poco/Timestamp.h>
#include <boost/shared_ptr.hpp>
+#include <boost/flyweight.hpp>
/**
* @brief Class for fileflags.
Poco::Timestamp ctime; /**< time of creation */
Poco::Timestamp mtime; /**< time of last modify */
Poco::File::FileSize size; /**< file size in bytes, -1 means file does not exist*/
- boost::shared_ptr<const String> filename; /**< filename for this item */
- boost::shared_ptr<const String> path; /**< full path (excluding filename) for the item */
+ boost::flyweight<String> filename; /**< filename for this item */
+ boost::flyweight<String> path; /**< full path (excluding filename) for the item */
FileVersion version; /**< string of fixed file version, eg, 1.2.3.4 */
FileFlags flags; /**< file attributes */
DirItem() : ctime(0), mtime(0), size(-1) { }
void SetFile(const String &fullPath);
String GetFile() const;
- const String& GetPath() const { return *path; };
- void SetPath(const String& newpath) { path.reset(new String(newpath)); }
- const String& GetFileName() const { return *filename; };
- void SetFileName(const String& newfilename) { filename.reset(new String(newfilename)); }
+ const String& GetPath() const { return path.get(); };
+ void SetPath(const String& newpath) { path = newpath; }
+ const String& GetFileName() const { return filename.get(); };
+ void SetFileName(const String& newfilename) { filename = newfilename; }
bool Update(const String &sFilePath);
void ClearPartial();
};
void CompareDiffItem(DIFFITEM &di, CDiffContext * pCtxt);
static void StoreDiffData(DIFFITEM &di, CDiffContext * pCtxt,
const FolderCmp * pCmpData);
-static DIFFITEM *AddToList(const shared_ptr<String> sLeftDir, const shared_ptr<String> sRightDir, const DirItem * lent, const DirItem * rent,
+static DIFFITEM *AddToList(const String& sLeftDir, const String& sRightDir, const DirItem * lent, const DirItem * rent,
unsigned code, DiffFuncStruct *myStruct, DIFFITEM *parent);
-static DIFFITEM *AddToList(const shared_ptr<String> sLeftDir, const shared_ptr<String> sMiddleDir, const shared_ptr<String> sRightDir, const DirItem * lent, const DirItem * ment, const DirItem * rent,
+static DIFFITEM *AddToList(const String& sLeftDir, const String& sMiddleDir, const String& sRightDir, const DirItem * lent, const DirItem * ment, const DirItem * rent,
unsigned code, DiffFuncStruct *myStruct, DIFFITEM *parent);
static void UpdateDiffItem(DIFFITEM & di, bool & bExists, CDiffContext *pCtxt);
static int CompareItems(NotificationQueue& queue, DiffFuncStruct *myStruct, UIntPtr parentdiffpos);
* @param [in] bUniques If true, walk into unique folders.
* @return 1 normally, -1 if compare was aborted
*/
-int DirScan_GetItems(const PathContext &paths, const shared_ptr<String> subdir[],
+int DirScan_GetItems(const PathContext &paths, const String subdir[],
DiffFuncStruct *myStruct,
bool casesensitive, int depth, DIFFITEM *parent,
bool bUniques)
for (nIndex = 0; nIndex < nDirs; nIndex++)
sDir[nIndex] = paths.GetPath(nIndex);
- if (!subdir[0]->empty())
+ if (!subdir[0].empty())
{
for (nIndex = 0; nIndex < paths.GetSize(); nIndex++)
{
- sDir[nIndex] = paths_ConcatPath(sDir[nIndex], *subdir[nIndex]);
- subprefix[nIndex] = *subdir[nIndex] + backslash;
+ sDir[nIndex] = paths_ConcatPath(sDir[nIndex], subdir[nIndex]);
+ subprefix[nIndex] = subdir[nIndex] + backslash;
}
}
nDiffCode & DIFFCODE::SECOND ? &dirs[1][j] : NULL,
nDiffCode, myStruct, parent);
// Scan recursively all subdirectories too, we are not adding folders
- shared_ptr<String> newsubdir[3];
- newsubdir[0].reset(new String(leftnewsub));
- if (leftnewsub == rightnewsub)
- newsubdir[1] = newsubdir[0];
- else
- newsubdir[1].reset(new String(rightnewsub));
+ String newsubdir[3] = {leftnewsub, rightnewsub};
int result = DirScan_GetItems(paths, newsubdir, myStruct, casesensitive,
depth - 1, me, bUniques);
if (result == -1)
nDiffCode & DIFFCODE::THIRD ? &dirs[2][k] : NULL,
nDiffCode, myStruct, parent);
// Scan recursively all subdirectories too, we are not adding folders
- shared_ptr<String> newsubdir[3];
- newsubdir[0].reset(new String(leftnewsub));
- if (leftnewsub == middlenewsub)
- newsubdir[1] = newsubdir[0];
- else
- newsubdir[1].reset(new String(middlenewsub));
- if (leftnewsub == rightnewsub)
- newsubdir[2] = newsubdir[0];
- else
- newsubdir[2].reset(new String(rightnewsub));
+ String newsubdir[3] = {leftnewsub, middlenewsub, rightnewsub};
int result = DirScan_GetItems(paths, newsubdir, myStruct, casesensitive,
depth - 1, me, bUniques);
if (result == -1)
* @param [in] pCtxt Compare context.
* @param [in] parent Parent of item to be added
*/
-static DIFFITEM *AddToList(const shared_ptr<String> sLeftDir, const shared_ptr<String> sRightDir,
+static DIFFITEM *AddToList(const String& sLeftDir, const String& sRightDir,
const DirItem * lent, const DirItem * rent,
unsigned code, DiffFuncStruct *myStruct, DIFFITEM *parent)
{
/**
* @brief Add one compare item to list.
*/
-static DIFFITEM *AddToList(const shared_ptr<String> sLeftDir, const shared_ptr<String> sMiddleDir, const shared_ptr<String> sRightDir,
+static DIFFITEM *AddToList(const String& sLeftDir, const String& sMiddleDir, const String& sRightDir,
const DirItem * lent, const DirItem * ment, const DirItem * rent,
unsigned code, DiffFuncStruct *myStruct, DIFFITEM *parent)
{
if (ment)
{
- di->diffFileInfo[1].filename =
- (*di->diffFileInfo[0].filename == *ment->filename) ? di->diffFileInfo[0].filename : ment->filename;
+ di->diffFileInfo[1].filename = ment->filename;
di->diffFileInfo[1].mtime = ment->mtime;
di->diffFileInfo[1].ctime = ment->ctime;
di->diffFileInfo[1].size = ment->size;
if (rent)
{
- di->diffFileInfo[2].filename =
- (*di->diffFileInfo[0].filename == *rent->filename) ? di->diffFileInfo[0].filename : rent->filename;
+ di->diffFileInfo[2].filename = rent->filename;
di->diffFileInfo[2].mtime = rent->mtime;
di->diffFileInfo[2].ctime = rent->ctime;
di->diffFileInfo[2].size = rent->size;