Code cleanup
This commit is contained in:
@@ -4,7 +4,7 @@ Simple local filesystem file synchronization. For use with external devices (usb
|
||||
## Installation
|
||||
Copy the resulting executable to the desired location.
|
||||
|
||||
The executable is completelly portable, there are no dependencies.
|
||||
The executable is completelly portable, there are no dependencies.
|
||||
|
||||
## Usage
|
||||
Basic usage to syncronize two directories, dirA and dirB:
|
||||
@@ -39,7 +39,7 @@ The rest of options are listed with no parameters:
|
||||
## Building
|
||||
There is a GNU Make compatible Makefile usable on Linux and MingGW.
|
||||
|
||||
make
|
||||
make
|
||||
|
||||
A Visual Studio 2015 solution is also provided under `VisualStudio` subdirectory.
|
||||
|
||||
|
||||
@@ -58,7 +58,6 @@ ActionFileNode ActionFileNode_CreateNormal(FileNode fileNodeLeft,
|
||||
return actionFileNode;
|
||||
}
|
||||
|
||||
|
||||
void AccionFileNode_CompareChilds(
|
||||
ActionFileNode actionFileNodeRoot,
|
||||
ActionFileNode *actionFileNodeQueue,
|
||||
@@ -80,7 +79,6 @@ void AccionFileNode_CompareChilds(
|
||||
if (!actionFileNodeRoot->left) {
|
||||
fileNodeRight = actionFileNodeRoot->right->child;
|
||||
while (fileNodeRight) {
|
||||
|
||||
CheckPair(NULL, fileNodeRight, actionFileNodeQueue);
|
||||
|
||||
fileNodeRight = fileNodeRight->next;
|
||||
@@ -92,7 +90,6 @@ void AccionFileNode_CompareChilds(
|
||||
if (!actionFileNodeRoot->right) {
|
||||
fileNodeLeft = actionFileNodeRoot->left->child;
|
||||
while (fileNodeLeft) {
|
||||
|
||||
CheckPair(fileNodeLeft, NULL, actionFileNodeQueue);
|
||||
|
||||
fileNodeLeft = fileNodeLeft->next;
|
||||
@@ -146,7 +143,6 @@ void AccionFileNode_CompareChilds(
|
||||
fileNodeRightProcessed = fileNodeRightPrevious;
|
||||
}
|
||||
actionFileNodeRoot->right->child = fileNodeRightProcessed;
|
||||
|
||||
}
|
||||
|
||||
int ActionFileNode_Statistics(ActionFileNode actionFileNode,
|
||||
@@ -165,7 +161,6 @@ int ActionFileNode_Statistics(ActionFileNode actionFileNode,
|
||||
statistics->deleteCount = 0;
|
||||
|
||||
while (actionFileNode != NULL) {
|
||||
|
||||
switch (actionFileNode->action) {
|
||||
case ActionFileCmp_Nothing:
|
||||
break;
|
||||
@@ -348,7 +343,6 @@ int ActionFileNode_RunList(ActionFileNode actionFileNode, char *pathLeft,
|
||||
return numActions;
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Common utilities
|
||||
|
||||
@@ -426,4 +420,4 @@ void AccionFileNode_DeletePair(FileNode fileNodeLeft, FileNode fileNodeRight,
|
||||
AccionFileNode_Destroy(actionFileNodeNew);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,6 @@ void ActionFileNode_Print(ActionFileNode actionFileNode);
|
||||
int ActionFileNode_RunList(ActionFileNode actionFileNode, char *pathLeft,
|
||||
char *pathRight);
|
||||
|
||||
|
||||
// Common utilities
|
||||
|
||||
void AccionFileNode_DeletePair(FileNode fileNodeLeft, FileNode fileNodeRight,
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
|
||||
#define QueueNode(queue,node) (queue)->next = (node); (queue) = (node);
|
||||
|
||||
|
||||
void AccionFileNode_CopyPair(FileNode fileNodeLeft, FileNode fileNodeRight,
|
||||
ActionFileNode *actionFileNodeQueue)
|
||||
{
|
||||
@@ -111,5 +110,4 @@ ActionFileNode ActionFileNode_BuildCopy(FileNode fileNodeLeft,
|
||||
AccionFileNode_CompareChilds(actionFileNodeRoot, &actionFileNodeQueue,
|
||||
AccionFileNode_CopyPair);
|
||||
return actionFileNodeRoot;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -191,7 +191,6 @@ void AccionFileNode_SyncPair(FileNode fileNodeLeft, FileNode fileNodeRight,
|
||||
else {
|
||||
// FIXME: !!!!!
|
||||
// Directory vs File
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,4 +202,4 @@ ActionFileNode ActionFileNode_BuildSync(FileNode izquierda, FileNode derecha) {
|
||||
AccionFileNode_CompareChilds(actionFileNodeRoot, &actionFileNodeQueue,
|
||||
AccionFileNode_SyncPair);
|
||||
return actionFileNodeRoot;
|
||||
}
|
||||
}
|
||||
@@ -64,4 +64,4 @@ unsigned long CRC_File(FILE *file) {
|
||||
crc = CRC_BufferInternal(buffer, count, crc);
|
||||
}
|
||||
return (crc ^= 0xFFFFFFFFL);
|
||||
}
|
||||
}
|
||||
@@ -387,7 +387,6 @@ void FileNode_PrintNode(FileNode fileNode) {
|
||||
if (fileNode->flags&FileFlag_HasCRC) {
|
||||
Print("\\-CRC : [%08X]\n", fileNode->crc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FileNode_Print(FileNode fileNode) {
|
||||
@@ -395,7 +394,6 @@ void FileNode_Print(FileNode fileNode) {
|
||||
int end = 0;
|
||||
|
||||
while (fileNodeAux != NULL && !end) {
|
||||
|
||||
if (fileNodeAux->parent != NULL) {
|
||||
FileNode_PrintNode(fileNodeAux);
|
||||
}
|
||||
@@ -513,7 +511,7 @@ FileNode FileNode_Refresh(FileNode fileNode, char *filePath) {
|
||||
// Scan subdirectories
|
||||
File_IterateDir(filePath, FileNode_Refresh_Iterate, fileNode);
|
||||
|
||||
// Mark as deleted remaining files marked for review
|
||||
// Mark as deleted remaining files marked for review
|
||||
fileNodeChild = fileNode->child;
|
||||
while (fileNodeChild) {
|
||||
if (fileNodeChild->flags & FileFlag_MarkerForReview) {
|
||||
@@ -577,5 +575,4 @@ int FileNode_Refresh_Iterate(char *path, char *name, void *d) {
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -124,7 +124,6 @@ void FileTime_Print(FileTime fileTime) {
|
||||
tms->tm_sec);
|
||||
}
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
long long File_GetSize(char *fileName) {
|
||||
HANDLE hFile;
|
||||
@@ -143,7 +142,6 @@ long long File_GetSize(char *fileName) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
void File_GetSizeAndTime(char *fileName, long long *size, FileTime *time) {
|
||||
HANDLE hFile;
|
||||
@@ -260,10 +258,6 @@ int File_IsFile(char *fileName) {
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
int File_MakeDirectory(char *path) {
|
||||
return (CreateDirectory(path, NULL));
|
||||
@@ -321,7 +315,7 @@ void File_IterateDir(char *path,
|
||||
entidad_dir = readdir(directorio);
|
||||
if (entidad_dir != NULL) {
|
||||
if (strcmp(entidad_dir->d_name, ".")
|
||||
&& strcmp(entidad_dir->d_name, ".."))
|
||||
&& strcmp(entidad_dir->d_name, ".."))
|
||||
{
|
||||
// Each item
|
||||
snprintf(f_path, MaxPath, "%s/%s", path, entidad_dir->d_name);
|
||||
@@ -391,4 +385,4 @@ cleanup:
|
||||
if (fDest != NULL) { fclose(fDest); }
|
||||
if (buffer != NULL) { free(buffer); }
|
||||
return status;
|
||||
}
|
||||
}
|
||||
21
src/main.c
21
src/main.c
@@ -10,7 +10,6 @@
|
||||
#include "actionfilenodesync.h"
|
||||
#include "actionfilenodecopy.h"
|
||||
|
||||
|
||||
void Help(char *exe) {
|
||||
char exeFilename[MaxPath];
|
||||
File_GetName(exe, exeFilename);
|
||||
@@ -186,17 +185,17 @@ void PrintStatistics(ActionFileNode actionFileNode) {
|
||||
}
|
||||
Print("Statistics\n");
|
||||
|
||||
Print(" % 8s % 8s % 8s\n",
|
||||
Print(" % 8s % 8s % 8s\n",
|
||||
"Read", "Write", "Delete");
|
||||
Print("Left :");
|
||||
PrintDataSize(statistics.readLeft);
|
||||
PrintDataSize(statistics.writeLeft);
|
||||
PrintDataSize(statistics.deleteLeft);
|
||||
Print("Left :");
|
||||
PrintDataSize(statistics.readLeft);
|
||||
PrintDataSize(statistics.writeLeft);
|
||||
PrintDataSize(statistics.deleteLeft);
|
||||
Print("\n");
|
||||
Print("Right:");
|
||||
PrintDataSize(statistics.readRight);
|
||||
PrintDataSize(statistics.writeRight);
|
||||
PrintDataSize(statistics.deleteRight);
|
||||
Print("Right:");
|
||||
PrintDataSize(statistics.readRight);
|
||||
PrintDataSize(statistics.writeRight);
|
||||
PrintDataSize(statistics.deleteRight);
|
||||
Print("\n");
|
||||
|
||||
Print("\n");
|
||||
@@ -296,4 +295,4 @@ int Copy(char *pathLeft, char *pathRight, int reCheck, int dryRun) {
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
@@ -155,4 +155,4 @@ int Print(char *fmt, ...) {
|
||||
// Flush
|
||||
fflush(stdout);
|
||||
return(n);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ char *String_Copy(char *str);
|
||||
// Gets the current time in usecs.
|
||||
long long Time_GetTime();
|
||||
|
||||
|
||||
/////////////////////////////
|
||||
// Time_Pause
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user