summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-21 15:21:32 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-08-21 15:22:01 +0200
commitb5d6fe8f20aed1304bb7531d35c6866563de078f (patch)
tree2a20093a64efe87bbc317478d21eee481968c909
parent28a0007be711c18b4949689026845b46025aa566 (diff)
Also extract files in sqfsdiff that only exist in one of the two sources
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--difftool/compare_dir.c20
-rw-r--r--difftool/node_compare.c2
-rw-r--r--difftool/sqfsdiff.h2
3 files changed, 21 insertions, 3 deletions
diff --git a/difftool/compare_dir.c b/difftool/compare_dir.c
index 7f4d00f..9ef2ba5 100644
--- a/difftool/compare_dir.c
+++ b/difftool/compare_dir.c
@@ -6,7 +6,7 @@
*/
#include "sqfsdiff.h"
-int compare_dir_entries(tree_node_t *old, tree_node_t *new)
+int compare_dir_entries(sqfsdiff_t *sd, tree_node_t *old, tree_node_t *new)
{
tree_node_t *old_it = old->data.dir->children, *old_prev = NULL;
tree_node_t *new_it = new->data.dir->children, *new_prev = NULL;
@@ -27,6 +27,15 @@ int compare_dir_entries(tree_node_t *old, tree_node_t *new)
path = node_path(old_it);
if (path == NULL)
return -1;
+
+ if ((sd->compare_flags & COMPARE_EXTRACT_FILES) &&
+ S_ISREG(old_it->mode)) {
+ if (extract_files(sd, old_it->data.file,
+ NULL, path)) {
+ return -1;
+ }
+ }
+
fprintf(stdout, "< %s\n", path);
free(path);
@@ -44,6 +53,15 @@ int compare_dir_entries(tree_node_t *old, tree_node_t *new)
path = node_path(new_it);
if (path == NULL)
return -1;
+
+ if ((sd->compare_flags & COMPARE_EXTRACT_FILES) &&
+ S_ISREG(new_it->mode)) {
+ if (extract_files(sd, NULL, new_it->data.file,
+ path)) {
+ return -1;
+ }
+ }
+
fprintf(stdout, "> %s\n", path);
free(path);
diff --git a/difftool/node_compare.c b/difftool/node_compare.c
index 35fd07b..504c9cf 100644
--- a/difftool/node_compare.c
+++ b/difftool/node_compare.c
@@ -70,7 +70,7 @@ int node_compare(sqfsdiff_t *sd, tree_node_t *a, tree_node_t *b)
}
break;
case S_IFDIR:
- ret = compare_dir_entries(a, b);
+ ret = compare_dir_entries(sd, a, b);
if (ret < 0) {
status = -1;
break;
diff --git a/difftool/sqfsdiff.h b/difftool/sqfsdiff.h
index 836b499..36b97b6 100644
--- a/difftool/sqfsdiff.h
+++ b/difftool/sqfsdiff.h
@@ -48,7 +48,7 @@ enum {
COMPARE_EXTRACT_FILES = 0x20,
};
-int compare_dir_entries(tree_node_t *a, tree_node_t *b);
+int compare_dir_entries(sqfsdiff_t *sd, tree_node_t *a, tree_node_t *b);
char *node_path(tree_node_t *n);