New feature to calculate action statistics
This commit is contained in:
339
filenodecmp.c
339
filenodecmp.c
@@ -136,71 +136,73 @@ void AccionFileNode_CompareChilds(AccionFileNode *actionFileNodeRoot,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccionFileNode_DeletePair(FileNode *fnIzq, FileNode *fnDer,
|
void AccionFileNode_DeletePair(FileNode *fileNodeLeft, FileNode *fileNodeRight,
|
||||||
AccionFileNode **afnCola) {
|
AccionFileNode **actionFileNodeQueue) {
|
||||||
AccionFileNode *afnNew = AccionFileNode_CreateNormal(fnIzq, fnDer);
|
AccionFileNode *afnNew = AccionFileNode_CreateNormal(fileNodeLeft,
|
||||||
|
fileNodeRight);
|
||||||
|
|
||||||
if (!fnIzq && !fnDer) {
|
if (!fileNodeLeft && !fileNodeRight) {
|
||||||
AccionFileNode_Destroy(afnNew);
|
AccionFileNode_Destroy(afnNew);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!fnIzq && fnDer) {
|
if (!fileNodeLeft && fileNodeRight) {
|
||||||
if (fnDer->flags & FileFlag_Directory) {
|
if (fileNodeRight->flags & FileFlag_Directory) {
|
||||||
// Iterar hijos para borrarlos
|
// Iterar hijos para borrarlos
|
||||||
AccionFileNode_CompareChilds(afnNew, afnCola,
|
AccionFileNode_CompareChilds(afnNew, actionFileNodeQueue,
|
||||||
AccionFileNode_DeletePair);
|
AccionFileNode_DeletePair);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fnDer->estado != FileStatus_Deleted) {
|
if (fileNodeRight->estado != FileStatus_Deleted) {
|
||||||
// Accion de borrado para el nodo
|
// Accion de borrado para el nodo
|
||||||
afnNew->action = AccionFileCmp_DeleteRight;
|
afnNew->action = AccionFileCmp_DeleteRight;
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = afnNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = afnNew;
|
||||||
} else {
|
} else {
|
||||||
AccionFileNode_Destroy(afnNew);
|
AccionFileNode_Destroy(afnNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fnIzq && !fnDer) {
|
if (fileNodeLeft && !fileNodeRight) {
|
||||||
if (fnIzq->flags & FileFlag_Directory) {
|
if (fileNodeLeft->flags & FileFlag_Directory) {
|
||||||
// Iterar hijos para borrarlos
|
// Iterar hijos para borrarlos
|
||||||
AccionFileNode_CompareChilds(afnNew, afnCola,
|
AccionFileNode_CompareChilds(afnNew, actionFileNodeQueue,
|
||||||
AccionFileNode_DeletePair);
|
AccionFileNode_DeletePair);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fnIzq->estado != FileStatus_Deleted) {
|
if (fileNodeLeft->estado != FileStatus_Deleted) {
|
||||||
// Accion de borrado para el nodo
|
// Accion de borrado para el nodo
|
||||||
afnNew->action = AccionFileCmp_DeleteLeft;
|
afnNew->action = AccionFileCmp_DeleteLeft;
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = afnNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = afnNew;
|
||||||
} else {
|
} else {
|
||||||
AccionFileNode_Destroy(afnNew);
|
AccionFileNode_Destroy(afnNew);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fnIzq && fnDer) {
|
if (fileNodeLeft && fileNodeRight) {
|
||||||
if ((fnIzq->flags & FileFlag_Directory)
|
if ((fileNodeLeft->flags & FileFlag_Directory)
|
||||||
|| (fnDer->flags & FileFlag_Directory)) {
|
|| (fileNodeRight->flags & FileFlag_Directory)) {
|
||||||
// Alguno es directorio
|
// Alguno es directorio
|
||||||
|
|
||||||
// Iterar hijos para borrarlos
|
// Iterar hijos para borrarlos
|
||||||
AccionFileNode_CompareChilds(afnNew, afnCola,
|
AccionFileNode_CompareChilds(afnNew, actionFileNodeQueue,
|
||||||
AccionFileNode_DeletePair);
|
AccionFileNode_DeletePair);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fnIzq->estado != FileStatus_Deleted) {
|
if (fileNodeLeft->estado != FileStatus_Deleted) {
|
||||||
// Accion de borrado para el nodo izquierdo
|
// Accion de borrado para el nodo izquierdo
|
||||||
afnNew->action = AccionFileCmp_DeleteLeft;
|
afnNew->action = AccionFileCmp_DeleteLeft;
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = afnNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = afnNew;
|
||||||
afnNew = NULL;
|
afnNew = NULL;
|
||||||
}
|
}
|
||||||
if (fnDer->estado != FileStatus_Deleted) {
|
if (fileNodeRight->estado != FileStatus_Deleted) {
|
||||||
if (!afnNew) {
|
if (!afnNew) {
|
||||||
afnNew = AccionFileNode_CreateNormal(fnIzq, fnDer);
|
afnNew = AccionFileNode_CreateNormal(fileNodeLeft,
|
||||||
|
fileNodeRight);
|
||||||
}
|
}
|
||||||
// Accion de borrado para el nodo derecho
|
// Accion de borrado para el nodo derecho
|
||||||
afnNew->action = AccionFileCmp_DeleteRight;
|
afnNew->action = AccionFileCmp_DeleteRight;
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = afnNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = afnNew;
|
||||||
afnNew = NULL;
|
afnNew = NULL;
|
||||||
}
|
}
|
||||||
if (afnNew) {
|
if (afnNew) {
|
||||||
@@ -209,191 +211,196 @@ void AccionFileNode_DeletePair(FileNode *fnIzq, FileNode *fnDer,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AccionFileNode_CheckPair(FileNode *fnIzq, FileNode *fnDer,
|
void AccionFileNode_CheckPair(FileNode *fileNodeLeft, FileNode *fileNodeRight,
|
||||||
AccionFileNode **afnCola) {
|
AccionFileNode **actionFileNodeQueue) {
|
||||||
AccionFileNode *afnNew = AccionFileNode_CreateNormal(fnIzq, fnDer);
|
AccionFileNode *actionFileNodeNew = AccionFileNode_CreateNormal(
|
||||||
|
fileNodeLeft, fileNodeRight);
|
||||||
|
|
||||||
if (!fnIzq && !fnDer) {
|
if (!fileNodeLeft && !fileNodeRight) {
|
||||||
AccionFileNode_Destroy(afnNew);
|
AccionFileNode_Destroy(actionFileNodeNew);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!fnIzq && fnDer) {
|
if (!fileNodeLeft && fileNodeRight) {
|
||||||
if (fnDer->flags & FileFlag_Directory) {
|
if (fileNodeRight->flags & FileFlag_Directory) {
|
||||||
// Directory
|
// Directory
|
||||||
if (fnDer->estado == FileStatus_Deleted) {
|
if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
|
|
||||||
// Anhadir a la lista de acciones
|
// Anhadir a la lista de acciones
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
afnNew->action = AccionFileCmp_MakeLeftDirectory;
|
actionFileNodeNew->action = AccionFileCmp_MakeLeftDirectory;
|
||||||
|
|
||||||
// Anhadir a la lista de acciones
|
// Anhadir a la lista de acciones
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
|
|
||||||
// Iterar hijos
|
// Iterar hijos
|
||||||
AccionFileNode_CompareChilds(afnNew, afnCola,
|
AccionFileNode_CompareChilds(actionFileNodeNew,
|
||||||
AccionFileNode_CheckPair);
|
actionFileNodeQueue, AccionFileNode_CheckPair);
|
||||||
|
|
||||||
// Crear nueva accion para copiar la fecha
|
// Crear nueva accion para copiar la fecha
|
||||||
afnNew = AccionFileNode_CreateNormal(fnIzq, fnDer);
|
actionFileNodeNew = AccionFileNode_CreateNormal(fileNodeLeft,
|
||||||
afnNew->action = AccionFileCmp_DateRightToLeft;
|
fileNodeRight);
|
||||||
(*afnCola)->next = afnNew;
|
actionFileNodeNew->action = AccionFileCmp_DateRightToLeft;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// File
|
// File
|
||||||
if (fnDer->estado == FileStatus_Deleted) {
|
if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
} else {
|
} else {
|
||||||
afnNew->action = AccionFileCmp_RightToLeft;
|
actionFileNodeNew->action = AccionFileCmp_RightToLeft;
|
||||||
}
|
}
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fnIzq && !fnDer) {
|
if (fileNodeLeft && !fileNodeRight) {
|
||||||
if (fnIzq->flags & FileFlag_Directory) {
|
if (fileNodeLeft->flags & FileFlag_Directory) {
|
||||||
// Directory
|
// Directory
|
||||||
if (fnIzq->estado == FileStatus_Deleted) {
|
if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
|
|
||||||
// Anhadir a la lista de acciones
|
// Anhadir a la lista de acciones
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
afnNew->action = AccionFileCmp_MakeRightDirectory;
|
actionFileNodeNew->action = AccionFileCmp_MakeRightDirectory;
|
||||||
|
|
||||||
// Anhadir a la lista de acciones
|
// Anhadir a la lista de acciones
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
|
|
||||||
// Iterar hijos
|
// Iterar hijos
|
||||||
AccionFileNode_CompareChilds(afnNew, afnCola,
|
AccionFileNode_CompareChilds(actionFileNodeNew,
|
||||||
AccionFileNode_CheckPair);
|
actionFileNodeQueue, AccionFileNode_CheckPair);
|
||||||
|
|
||||||
// Crear nueva accion para copiar la fecha
|
// Crear nueva accion para copiar la fecha
|
||||||
afnNew = AccionFileNode_CreateNormal(fnIzq, fnDer);
|
actionFileNodeNew = AccionFileNode_CreateNormal(fileNodeLeft,
|
||||||
afnNew->action = AccionFileCmp_DateLeftToRight;
|
fileNodeRight);
|
||||||
(*afnCola)->next = afnNew;
|
actionFileNodeNew->action = AccionFileCmp_DateLeftToRight;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// File
|
// File
|
||||||
if (fnIzq->estado == FileStatus_Deleted) {
|
if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
} else {
|
} else {
|
||||||
afnNew->action = AccionFileCmp_LeftToRight;
|
actionFileNodeNew->action = AccionFileCmp_LeftToRight;
|
||||||
}
|
}
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fnIzq && fnDer) {
|
if (fileNodeLeft && fileNodeRight) {
|
||||||
if ((fnIzq->flags & FileFlag_Directory)
|
if ((fileNodeLeft->flags & FileFlag_Directory)
|
||||||
&& (fnDer->flags & FileFlag_Directory)) {
|
&& (fileNodeRight->flags & FileFlag_Directory)) {
|
||||||
// Directorios
|
// Directorios
|
||||||
|
|
||||||
// Preparar accion para el par de directorios
|
// Preparar accion para el par de directorios
|
||||||
if (abs(fnIzq->fileTime - fnDer->fileTime) <= 1) { // appoximadamente iguales
|
if (abs(fileNodeLeft->fileTime - fileNodeRight->fileTime) <= 1) { // appoximadamente iguales
|
||||||
if (fnDer->estado == FileStatus_Deleted
|
if (fileNodeRight->estado == FileStatus_Deleted
|
||||||
&& fnIzq->estado == FileStatus_Deleted) {
|
&& fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
} else if (fnDer->estado == FileStatus_Deleted) {
|
} else if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_DeleteLeft;
|
actionFileNodeNew->action = AccionFileCmp_DeleteLeft;
|
||||||
if (fnIzq->estado == FileStatus_Deleted) {
|
if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
} else if (fnIzq->estado == FileStatus_Deleted) {
|
} else if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_DeleteRight;
|
actionFileNodeNew->action = AccionFileCmp_DeleteRight;
|
||||||
if (fnDer->estado == FileStatus_Deleted) {
|
if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
} else if (fnIzq->fileTime < fnDer->fileTime) {
|
} else if (fileNodeLeft->fileTime < fileNodeRight->fileTime) {
|
||||||
afnNew->action = AccionFileCmp_DateRightToLeft;
|
actionFileNodeNew->action = AccionFileCmp_DateRightToLeft;
|
||||||
if (fnDer->estado == FileStatus_Deleted) {
|
if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_DeleteLeft;
|
actionFileNodeNew->action = AccionFileCmp_DeleteLeft;
|
||||||
if (fnIzq->estado == FileStatus_Deleted) {
|
if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fnIzq->fileTime > fnDer->fileTime) {
|
} else if (fileNodeLeft->fileTime > fileNodeRight->fileTime) {
|
||||||
afnNew->action = AccionFileCmp_DateLeftToRight;
|
actionFileNodeNew->action = AccionFileCmp_DateLeftToRight;
|
||||||
if (fnIzq->estado == FileStatus_Deleted) {
|
if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_DeleteRight;
|
actionFileNodeNew->action = AccionFileCmp_DeleteRight;
|
||||||
if (fnDer->estado == FileStatus_Deleted) {
|
if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Procesar nodos hijos
|
// Procesar nodos hijos
|
||||||
if (afnNew->action == AccionFileCmp_DeleteRight
|
if (actionFileNodeNew->action == AccionFileCmp_DeleteRight
|
||||||
|| afnNew->action == AccionFileCmp_DeleteLeft
|
|| actionFileNodeNew->action == AccionFileCmp_DeleteLeft
|
||||||
|| (fnIzq->estado == FileStatus_Deleted
|
|| (fileNodeLeft->estado == FileStatus_Deleted
|
||||||
&& fnDer->estado == FileStatus_Deleted)) {
|
&& fileNodeRight->estado == FileStatus_Deleted)) {
|
||||||
// Iterar nodos hijos para borrarlos
|
// Iterar nodos hijos para borrarlos
|
||||||
AccionFileNode_CompareChilds(afnNew, afnCola,
|
AccionFileNode_CompareChilds(actionFileNodeNew,
|
||||||
AccionFileNode_DeletePair);
|
actionFileNodeQueue, AccionFileNode_DeletePair);
|
||||||
} else {
|
} else {
|
||||||
AccionFileNode_CompareChilds(afnNew, afnCola,
|
AccionFileNode_CompareChilds(actionFileNodeNew,
|
||||||
AccionFileNode_CheckPair);
|
actionFileNodeQueue, AccionFileNode_CheckPair);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encolar accion para el directorio padre
|
// Encolar accion para el directorio padre
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
|
|
||||||
} else if ((fnIzq->flags & FileFlag_Normal)
|
} else if ((fileNodeLeft->flags & FileFlag_Normal)
|
||||||
&& (fnDer->flags & FileFlag_Normal)) {
|
&& (fileNodeRight->flags & FileFlag_Normal)) {
|
||||||
// Ficheros
|
// Ficheros
|
||||||
|
|
||||||
// Preparar accion para el par de ficheros
|
// Preparar accion para el par de ficheros
|
||||||
if (abs(fnIzq->fileTime - fnDer->fileTime) <= 1) { // appoximadamente iguales
|
if (abs(fileNodeLeft->fileTime - fileNodeRight->fileTime) <= 1) { // appoximadamente iguales
|
||||||
if (fnDer->estado == FileStatus_Deleted
|
if (fileNodeRight->estado == FileStatus_Deleted
|
||||||
&& fnIzq->estado == FileStatus_Deleted) {
|
&& fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
} else if (fnDer->estado == FileStatus_Deleted) {
|
} else if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_DeleteLeft;
|
actionFileNodeNew->action = AccionFileCmp_DeleteLeft;
|
||||||
if (fnIzq->estado == FileStatus_Deleted) {
|
if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
} else if (fnIzq->estado == FileStatus_Deleted) {
|
} else if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_DeleteRight;
|
actionFileNodeNew->action = AccionFileCmp_DeleteRight;
|
||||||
if (fnDer->estado == FileStatus_Deleted) {
|
if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
} else if (fnIzq->fileTime < fnDer->fileTime) {
|
} else if (fileNodeLeft->fileTime < fileNodeRight->fileTime) {
|
||||||
afnNew->action = AccionFileCmp_RightToLeft;
|
// FIXME: Check size to determine y further checks are necessary
|
||||||
if (fnDer->estado == FileStatus_Deleted) {
|
actionFileNodeNew->action = AccionFileCmp_RightToLeft;
|
||||||
afnNew->action = AccionFileCmp_DeleteLeft;
|
if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
if (fnIzq->estado == FileStatus_Deleted) {
|
actionFileNodeNew->action = AccionFileCmp_DeleteLeft;
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (fnIzq->fileTime > fnDer->fileTime) {
|
} else if (fileNodeLeft->fileTime > fileNodeRight->fileTime) {
|
||||||
afnNew->action = AccionFileCmp_LeftToRight;
|
// FIXME: Check size to determine y further checks are necessary
|
||||||
if (fnIzq->estado == FileStatus_Deleted) {
|
actionFileNodeNew->action = AccionFileCmp_LeftToRight;
|
||||||
afnNew->action = AccionFileCmp_DeleteRight;
|
if (fileNodeLeft->estado == FileStatus_Deleted) {
|
||||||
if (fnDer->estado == FileStatus_Deleted) {
|
actionFileNodeNew->action = AccionFileCmp_DeleteRight;
|
||||||
afnNew->action = AccionFileCmp_Nothing;
|
if (fileNodeRight->estado == FileStatus_Deleted) {
|
||||||
|
actionFileNodeNew->action = AccionFileCmp_Nothing;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encolar accion para el fichero
|
// Encolar accion para el fichero
|
||||||
(*afnCola)->next = afnNew;
|
(*actionFileNodeQueue)->next = actionFileNodeNew;
|
||||||
(*afnCola) = afnNew;
|
(*actionFileNodeQueue) = actionFileNodeNew;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// FIXME: !!!!!
|
// FIXME: !!!!!
|
||||||
@@ -499,6 +506,60 @@ AccionFileNode *AccionFileNode_BuildCopy(FileNode *fileNodeLeft,
|
|||||||
return actionFileNodeRoot;
|
return actionFileNodeRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AccionFileNode_Statistics(AccionFileNode *actionFileNode,
|
||||||
|
ActionQueueStatistics *statistics) {
|
||||||
|
statistics->readLeft = 0;
|
||||||
|
statistics->writeLeft = 0;
|
||||||
|
statistics->readRight = 0;
|
||||||
|
statistics->writeRight = 0;
|
||||||
|
statistics->fullCopyCount = 0;
|
||||||
|
statistics->dateCopyCount = 0;
|
||||||
|
statistics->directoryCount = 0;
|
||||||
|
statistics->deleteCount = 0;
|
||||||
|
statistics->deleteLeft = 0;
|
||||||
|
statistics->deleteRight = 0;
|
||||||
|
|
||||||
|
while (actionFileNode != NULL ) {
|
||||||
|
|
||||||
|
switch (actionFileNode->action) {
|
||||||
|
case AccionFileCmp_Nothing:
|
||||||
|
break;
|
||||||
|
case AccionFileCmp_LeftToRight:
|
||||||
|
statistics->fullCopyCount++;
|
||||||
|
statistics->readLeft += actionFileNode->left->size;
|
||||||
|
statistics->writeRight += actionFileNode->left->size;
|
||||||
|
break;
|
||||||
|
case AccionFileCmp_RightToLeft:
|
||||||
|
statistics->fullCopyCount++;
|
||||||
|
statistics->writeLeft += actionFileNode->right->size;
|
||||||
|
statistics->readRight += actionFileNode->right->size;
|
||||||
|
break;
|
||||||
|
case AccionFileCmp_DeleteLeft:
|
||||||
|
statistics->deleteCount++;
|
||||||
|
statistics->deleteLeft += actionFileNode->left->size;
|
||||||
|
break;
|
||||||
|
case AccionFileCmp_DeleteRight:
|
||||||
|
statistics->deleteCount++;
|
||||||
|
statistics->deleteRight += actionFileNode->right->size;
|
||||||
|
break;
|
||||||
|
case AccionFileCmp_DateLeftToRight:
|
||||||
|
statistics->dateCopyCount++;
|
||||||
|
break;
|
||||||
|
case AccionFileCmp_DateRightToLeft:
|
||||||
|
statistics->dateCopyCount++;
|
||||||
|
break;
|
||||||
|
case AccionFileCmp_MakeRightDirectory:
|
||||||
|
statistics->directoryCount++;
|
||||||
|
break;
|
||||||
|
case AccionFileCmp_MakeLeftDirectory:
|
||||||
|
statistics->directoryCount++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
actionFileNode = actionFileNode->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AccionFileNode_Print(AccionFileNode *actionFileNode) {
|
void AccionFileNode_Print(AccionFileNode *actionFileNode) {
|
||||||
char showPath[MaxPath];
|
char showPath[MaxPath];
|
||||||
while (actionFileNode != NULL ) {
|
while (actionFileNode != NULL ) {
|
||||||
|
|||||||
@@ -32,6 +32,22 @@ AccionFileNode *AccionFileNode_BuildSync(FileNode *fileNodeLeft,
|
|||||||
AccionFileNode *AccionFileNode_BuildCopy(FileNode *fileNodeLeft,
|
AccionFileNode *AccionFileNode_BuildCopy(FileNode *fileNodeLeft,
|
||||||
FileNode *fileNodeRight);
|
FileNode *fileNodeRight);
|
||||||
|
|
||||||
|
typedef struct SActionQueueStatistics {
|
||||||
|
long long readLeft;
|
||||||
|
long long writeLeft;
|
||||||
|
long long readRight;
|
||||||
|
long long writeRight;
|
||||||
|
int fullCopyCount;
|
||||||
|
int dateCopyCount;
|
||||||
|
int directoryCount;
|
||||||
|
int deleteCount;
|
||||||
|
long long deleteLeft;
|
||||||
|
long long deleteRight;
|
||||||
|
} ActionQueueStatistics;
|
||||||
|
|
||||||
|
void AccionFileNode_Statistics(AccionFileNode *actionFileNode,
|
||||||
|
ActionQueueStatistics *statistics);
|
||||||
|
|
||||||
void AccionFileNode_Print(AccionFileNode *actionFileNode);
|
void AccionFileNode_Print(AccionFileNode *actionFileNode);
|
||||||
|
|
||||||
void AccionFileNode_RunList(AccionFileNode *actionFileNode, char *pathLeft,
|
void AccionFileNode_RunList(AccionFileNode *actionFileNode, char *pathLeft,
|
||||||
|
|||||||
18
main.c
18
main.c
@@ -144,6 +144,22 @@ FileNode *CheckDir(char *path, int recheck) {
|
|||||||
return fileNode;
|
return fileNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintStatistics(AccionFileNode *actionFileNode) {
|
||||||
|
ActionQueueStatistics statistics;
|
||||||
|
AccionFileNode_Statistics(actionFileNode, &statistics);
|
||||||
|
printf("Statistics\n");
|
||||||
|
printf(" % 12s % 12s % 12s\n", "Read", "Write", "Delete");
|
||||||
|
printf("Left : % 12lld % 12lld % 12lld\n", statistics.readLeft,
|
||||||
|
statistics.writeLeft, statistics.deleteLeft);
|
||||||
|
printf("Right: % 12lld % 12lld % 12lld\n", statistics.readRight,
|
||||||
|
statistics.writeRight, statistics.deleteRight);
|
||||||
|
printf("\n");
|
||||||
|
printf("Copy count : % 10d\n", statistics.fullCopyCount);
|
||||||
|
printf("Date copy count: % 10d\n", statistics.dateCopyCount);
|
||||||
|
printf("Directory count: % 10d\n", statistics.directoryCount);
|
||||||
|
printf("Delete count : % 10d\n", statistics.deleteCount);
|
||||||
|
}
|
||||||
|
|
||||||
int Sync(char *pathLeft, char *pathRight, int recheck, int dryRun) {
|
int Sync(char *pathLeft, char *pathRight, int recheck, int dryRun) {
|
||||||
FileNode *fileNodeLeft, *fileNodeRight;
|
FileNode *fileNodeLeft, *fileNodeRight;
|
||||||
|
|
||||||
@@ -173,6 +189,7 @@ int Sync(char *pathLeft, char *pathRight, int recheck, int dryRun) {
|
|||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
// Mostrar lista de acciones
|
// Mostrar lista de acciones
|
||||||
AccionFileNode_Print(actionFileNode);
|
AccionFileNode_Print(actionFileNode);
|
||||||
|
PrintStatistics(actionFileNode);
|
||||||
} else {
|
} else {
|
||||||
// Ejecutar lista de acciones
|
// Ejecutar lista de acciones
|
||||||
AccionFileNode_RunList(actionFileNode, pathLeft, pathRight);
|
AccionFileNode_RunList(actionFileNode, pathLeft, pathRight);
|
||||||
@@ -210,6 +227,7 @@ int Copy(char *pathLeft, char *pathRight, int reCheck, int dryRun) {
|
|||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
// Mostrar lista de acciones
|
// Mostrar lista de acciones
|
||||||
AccionFileNode_Print(actionFileNode);
|
AccionFileNode_Print(actionFileNode);
|
||||||
|
PrintStatistics(actionFileNode);
|
||||||
} else {
|
} else {
|
||||||
// Ejecutar lista de acciones
|
// Ejecutar lista de acciones
|
||||||
AccionFileNode_RunList(actionFileNode, pathLeft, pathRight);
|
AccionFileNode_RunList(actionFileNode, pathLeft, pathRight);
|
||||||
|
|||||||
Reference in New Issue
Block a user