526 |
|
|
527 |
mkdir_if_necessary(report_directory); |
mkdir_if_necessary(report_directory); |
528 |
char * path = make_path(report_directory, "jscoverage.json"); |
char * path = make_path(report_directory, "jscoverage.json"); |
529 |
FILE * f = fopen(path, "r"); |
|
530 |
if (f != NULL) { |
/* check if the JSON file exists */ |
531 |
|
struct stat buf; |
532 |
|
if (stat(path, &buf) == 0) { |
533 |
/* it exists: merge */ |
/* it exists: merge */ |
534 |
result = merge(coverage, f); |
FILE * f = fopen(path, "r"); |
535 |
if (fclose(f) == EOF) { |
if (f == NULL) { |
536 |
result = 1; |
result = 1; |
537 |
} |
} |
538 |
|
else { |
539 |
|
result = merge(coverage, f); |
540 |
|
if (fclose(f) == EOF) { |
541 |
|
result = 1; |
542 |
|
} |
543 |
|
} |
544 |
if (result != 0) { |
if (result != 0) { |
545 |
free(path); |
free(path); |
546 |
Coverage_delete(coverage); |
Coverage_delete(coverage); |
560 |
/* copy other files */ |
/* copy other files */ |
561 |
jscoverage_copy_resources(report_directory); |
jscoverage_copy_resources(report_directory); |
562 |
path = make_path(report_directory, "jscoverage.js"); |
path = make_path(report_directory, "jscoverage.js"); |
563 |
f = fopen(path, "ab"); |
FILE * f = fopen(path, "ab"); |
564 |
free(path); |
free(path); |
565 |
if (f == NULL) { |
if (f == NULL) { |
566 |
send_response(exchange, 500, "Could not write to file: jscoverage.js\n"); |
send_response(exchange, 500, "Could not write to file: jscoverage.js\n"); |