36static int there(
const char* path) {
37 FILE* f = fopen(path,
"rb");
45 const char* tmp = getenv(
"TMPDIR") ? getenv(
"TMPDIR") :
"/tmp";
46 char src[512], dst[512], part[520], other[512];
47 size_t copied = 0, i = 0;
51 snprintf(src,
sizeof(src),
"%s/ex_file_copy_%d.src", tmp, (
int)getpid());
52 snprintf(dst,
sizeof(dst),
"%s/ex_file_copy_%d.dst", tmp, (
int)getpid());
53 snprintf(part,
sizeof(part),
"%s.part", dst);
54 snprintf(other,
sizeof(other),
"%s/ex_file_copy_%d.other", tmp, (
int)getpid());
59 for (i = 0; i < 800000; i++) fputc((
int)((i * 7 + i / 13) & 0xff), f);
70 f = fopen(other,
"wb");
72 for (i = 0; i < 800000; i++) fputc(i == 500000 ? 0 : (
int)((i * 7 + i / 13) & 0xff), f);
static void expect_true(const char *label, int cond)
static int there(const char *path)
does a file exist
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL ).
#define LOG_NOTICE
normal but significant condition
int n_file_same_content(const char *a, const char *b)
Do two files hold the same bytes.
int n_file_copy_verified(const char *from, const char *to, size_t *copied)
Copy a file, check the copy against the original, and only then give it its name.
Common headers and low-level functions & define.
Files configuration header.