1 |
/* |
/* |
2 |
instrument.c - file and directory instrumentation routines |
instrument.c - file and directory instrumentation routines |
3 |
Copyright (C) 2007, 2008 siliconforks.com |
Copyright (C) 2007, 2008, 2009 siliconforks.com |
4 |
|
|
5 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
6 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
162 |
fatal("not a directory: %s", destination); |
fatal("not a directory: %s", destination); |
163 |
} |
} |
164 |
if (! directory_is_empty(destination)) { |
if (! directory_is_empty(destination)) { |
165 |
char * jscoverage_html = make_path(destination, "jscoverage.html"); |
char * expected_file = NULL; |
166 |
if (stat(jscoverage_html, &buf) == -1) { |
if (jscoverage_mode == JSCOVERAGE_MOZILLA) { |
167 |
|
char * modules_directory = make_path(destination, "modules"); |
168 |
|
expected_file = make_path(modules_directory, "jscoverage.jsm"); |
169 |
|
free(modules_directory); |
170 |
|
} |
171 |
|
else { |
172 |
|
expected_file = make_path(destination, "jscoverage.html"); |
173 |
|
} |
174 |
|
if (stat(expected_file, &buf) == -1) { |
175 |
fatal("refusing to overwrite directory: %s", destination); |
fatal("refusing to overwrite directory: %s", destination); |
176 |
} |
} |
177 |
free(jscoverage_html); |
free(expected_file); |
178 |
} |
} |
179 |
} |
} |
180 |
else if (errno == ENOENT) { |
else if (errno == ENOENT) { |
185 |
} |
} |
186 |
|
|
187 |
/* copy the resources */ |
/* copy the resources */ |
188 |
jscoverage_copy_resources(destination); |
if (jscoverage_mode == JSCOVERAGE_MOZILLA) { |
189 |
|
char * chrome_directory = make_path(destination, "chrome"); |
190 |
|
char * jscoverage_chrome_directory = make_path(chrome_directory, "jscoverage"); |
191 |
|
mkdirs(jscoverage_chrome_directory); |
192 |
|
copy_resource("jscoverage.manifest", chrome_directory); |
193 |
|
copy_resource("jscoverage.html", jscoverage_chrome_directory); |
194 |
|
copy_resource("jscoverage.css", jscoverage_chrome_directory); |
195 |
|
copy_resource("jscoverage.js", jscoverage_chrome_directory); |
196 |
|
copy_resource("jscoverage-throbber.gif", jscoverage_chrome_directory); |
197 |
|
copy_resource("jscoverage-highlight.css", jscoverage_chrome_directory); |
198 |
|
copy_resource("jscoverage.xul", jscoverage_chrome_directory); |
199 |
|
copy_resource("jscoverage-overlay.js", jscoverage_chrome_directory); |
200 |
|
free(jscoverage_chrome_directory); |
201 |
|
free(chrome_directory); |
202 |
|
|
203 |
|
char * modules_directory = make_path(destination, "modules"); |
204 |
|
mkdirs(modules_directory); |
205 |
|
copy_resource("jscoverage.jsm", modules_directory); |
206 |
|
free(modules_directory); |
207 |
|
} |
208 |
|
else { |
209 |
|
jscoverage_copy_resources(destination); |
210 |
|
} |
211 |
|
|
212 |
/* finally: copy the directory */ |
/* finally: copy the directory */ |
213 |
struct DirListEntry * list = make_recursive_dir_list(source); |
struct DirListEntry * list = make_recursive_dir_list(source); |
246 |
free(s); |
free(s); |
247 |
free(d); |
free(d); |
248 |
} |
} |
249 |
|
|
250 |
free_dir_list(list); |
free_dir_list(list); |
251 |
} |
} |