Fixed automatic log conversion / plotting script

This commit is contained in:
Lorenz Meier
2012-10-25 18:53:03 +02:00
parent c71f2ea204
commit 5f01688490
2 changed files with 21 additions and 5 deletions
+7 -3
View File
@@ -567,6 +567,7 @@ int file_copy(const char* file_old, const char* file_new)
{
FILE *source, *target;
source = fopen(file_old, "r");
int ret = 0;
if( source == NULL )
{
@@ -580,21 +581,24 @@ int file_copy(const char* file_old, const char* file_new)
{
fclose(source);
warnx("failed to open output file to copy");
return 1;
}
char buf[128];
int nread;
while ((nread = fread(buf, sizeof(buf), 1, source)) > 0) {
int ret = fwrite(buf, sizeof(buf), 1, target);
while ((nread = fread(buf, 1, sizeof(buf), source)) > 0) {
int ret = fwrite(buf, 1, nread, target);
if (ret <= 0) {
warnx("error writing file");
ret = 1;
break;
}
}
fsync(fileno(target));
fclose(source);
fclose(target);
return 0;
return ret;
}