_PUBLIC_ int fdprintf(int fd, const char *format, ...) PRINTF_ATTRIBUTE(2,3);
_PUBLIC_ bool large_file_support(const char *path);
+/*
+ compare two files, return true if the two files have the same content
+ */
+bool file_compare(const char *path1, const char *path2);
+
/* The following definitions come from lib/util/util.c */
}
+/*
+ compare two files, return true if the two files have the same content
+ */
+bool file_compare(const char *path1, const char *path2)
+{
+ size_t size1, size2;
+ char *p1, *p2;
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+
+ p1 = file_load(path1, &size1, 0, mem_ctx);
+ p2 = file_load(path2, &size2, 0, mem_ctx);
+ if (!p1 || !p2 || size1 != size2) {
+ talloc_free(mem_ctx);
+ return false;
+ }
+ if (memcmp(p1, p2, size1) != 0) {
+ talloc_free(mem_ctx);
+ return false;
+ }
+ talloc_free(mem_ctx);
+ return true;
+}