--- trunk/instrument.c 2007/08/11 17:41:23 7 +++ trunk/instrument.c 2008/05/07 04:21:22 92 @@ -1,6 +1,6 @@ /* instrument.c - file and directory instrumentation routines - Copyright (C) 2007 siliconforks.com + Copyright (C) 2007, 2008 siliconforks.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -81,10 +81,10 @@ fprintf(output, "%s\n", relative_path); fprintf(output, "\n", relative_path_to_ancestor); - fprintf(output, "\n", relative_path_to_ancestor); + fprintf(output, "\n", relative_path_to_ancestor); fprintf(output, "\n", relative_path_to_ancestor); - fprintf(output, "\n", relative_path_to_ancestor); - fprintf(output, "\n", relative_path_to_ancestor); + fprintf(output, "\n", relative_path_to_ancestor); + fprintf(output, "\n", relative_path_to_ancestor); fprintf(output, "\n"); @@ -162,14 +162,28 @@ copy_file(source_file, destination_file); break; case FILE_TYPE_JS: - highlight_file(source_file, destination_file, id); { FILE * input = xfopen(source_file, "r"); FILE * output = xfopen(destination_file, "w"); - jscoverage_instrument_js(id, input, output); + + Stream * input_stream = Stream_new(0); + Stream * output_stream = Stream_new(0); + + Stream_write_file_contents(input_stream, input); + + jscoverage_instrument_js(id, input_stream, output_stream); + + if (fwrite(output_stream->data, 1, output_stream->length, output) != output_stream->length) { + fatal("cannot write to file: %s", destination_file); + } + + Stream_delete(input_stream); + Stream_delete(output_stream); + fclose(input); fclose(output); } + highlight_file(source_file, destination_file, id); break; } } @@ -225,6 +239,9 @@ fatal("cannot stat directory: %s", destination); } + /* copy the resources */ + jscoverage_copy_resources(destination); + /* finally: copy the directory */ struct DirListEntry * list = make_recursive_dir_list(source); for (struct DirListEntry * p = list; p != NULL; p = p->next) { @@ -270,7 +287,7 @@ copy_resource("jscoverage.css", destination_directory); copy_resource("jscoverage.js", destination_directory); copy_resource("jscoverage-throbber.gif", destination_directory); - copy_resource("sh_main.js", destination_directory); - copy_resource("sh_javascript.min.js", destination_directory); - copy_resource("sh_nedit.css", destination_directory); + copy_resource("jscoverage-sh_main.js", destination_directory); + copy_resource("jscoverage-sh_javascript.js", destination_directory); + copy_resource("jscoverage-sh_nedit.css", destination_directory); }