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"); |
883 |
|
|
884 |
const char * content_type = get_content_type(filesystem_path); |
const char * content_type = get_content_type(filesystem_path); |
885 |
HTTPExchange_set_response_header(exchange, HTTP_CONTENT_TYPE, content_type); |
HTTPExchange_set_response_header(exchange, HTTP_CONTENT_TYPE, content_type); |
886 |
const char * request_uri = HTTPExchange_get_request_uri(exchange); |
if (strcmp(content_type, "text/javascript") == 0 && ! is_no_instrument(abs_path)) { |
|
if (strcmp(content_type, "text/javascript") == 0 && ! is_no_instrument(request_uri)) { |
|
887 |
Stream * input_stream = Stream_new(0); |
Stream * input_stream = Stream_new(0); |
888 |
Stream * output_stream = Stream_new(0); |
Stream * output_stream = Stream_new(0); |
889 |
|
|
890 |
Stream_write_file_contents(input_stream, f); |
Stream_write_file_contents(input_stream, f); |
891 |
|
|
892 |
instrument_js(request_uri, input_stream, output_stream); |
instrument_js(abs_path, input_stream, output_stream); |
893 |
|
|
894 |
if (HTTPExchange_write_response(exchange, output_stream->data, output_stream->length) != 0) { |
if (HTTPExchange_write_response(exchange, output_stream->data, output_stream->length) != 0) { |
895 |
HTTPServer_log_err("Warning: error writing to client\n"); |
HTTPServer_log_err("Warning: error writing to client\n"); |
1041 |
#ifdef __MINGW32__ |
#ifdef __MINGW32__ |
1042 |
WSADATA data; |
WSADATA data; |
1043 |
if (WSAStartup(MAKEWORD(1, 1), &data) != 0) { |
if (WSAStartup(MAKEWORD(1, 1), &data) != 0) { |
1044 |
fatal("Could not start Winsock"); |
fatal("could not start Winsock"); |
1045 |
} |
} |
1046 |
#endif |
#endif |
1047 |
|
|