boolByte errorReportCopyFileToReport(ErrorReporter self, CharString path) { boolByte success = false; CharString destination = newCharString(); charStringCopy(destination, path); errorReporterRemapPath(self, destination); success = copyFileToDirectory(path, self->reportDirPath); freeCharString(destination); return success; }
static void _remapFileToErrorReport(ErrorReporter errorReporter, ProgramOption option, boolByte copyFile) { if(option->enabled) { if(copyFile) { // TODO: Slight abuse of private field, probably should avoid doing that... if(!errorReportCopyFileToReport(errorReporter, option->_data.string)) { logWarn("Failed copying '%s' to error report directory, please include this file manually", option->_data.string->data); } } errorReporterRemapPath(errorReporter, option->_data.string); } }
void errorReporterCreateLauncher(ErrorReporter self, int argc, char* argv[]) { CharString outScriptName = newCharString(); FILE *scriptFilePointer; int i; charStringCopyCString(outScriptName, "run.sh"); errorReporterRemapPath(self, outScriptName); scriptFilePointer = fopen(outScriptName->data, "w"); fprintf(scriptFilePointer, "#!/bin/sh\n"); fprintf(scriptFilePointer, "mrswatson"); for(i = 1; i < argc; i++) { // Don't run with the error report option again if(strcmp(argv[i], "--error-report")) { fprintf(scriptFilePointer, " %s", argv[i]); } } fprintf(scriptFilePointer, "\n"); fclose(scriptFilePointer); }
boolByte errorReportCopyFileToReport(ErrorReporter self, CharString path) { boolByte success; // Copy the destination path so that the original is not modified CharString destination = newCharString(); charStringCopy(destination, path); errorReporterRemapPath(self, destination); File reportDirPath = newFileWithPath(self->reportDirPath); File distinationPath = newFileWithPath(path); File result = fileCopyTo(distinationPath, reportDirPath); success = fileExists(result); freeCharString(destination); freeFile(reportDirPath); freeFile(distinationPath); freeFile(result); return success; }