コード例 #1
0
ファイル: IntegrationTests.c プロジェクト: nano-bot/MrsWatson
static int _testLoadPluginWithAbsolutePath(const char *testName,
                                           const CharString applicationPath,
                                           const CharString resourcesPath) {
  File resourcesFile = newFileWithPath(resourcesPath);
  CharString vstDirName = newCharStringWithCString("vst");
  File vstFile = newFileWithParent(resourcesFile, vstDirName);
  freeFile(resourcesFile);
  freeCharString(vstDirName);

  PlatformInfo platformInfo = newPlatformInfo();
  CharString platformDirName =
      newCharStringWithCString(_getPlatformVstDirName(platformInfo));
  File vstPlatformFile = newFileWithParent(vstFile, platformDirName);
  freeCharString(platformDirName);
  freePlatformInfo(platformInfo);
  freeFile(vstFile);

  CharString vstPluginName = newCharStringWithCString("again");
  charStringAppendCString(vstPluginName, _getVst2xPlatformExtension());
  File pluginFile = newFileWithParent(vstPlatformFile, vstPluginName);
  freeCharString(vstPluginName);
  freeFile(vstPlatformFile);

  CharString inputPath = getDefaultInputPath(resourcesPath);
  int result = runIntegrationTest(
      testName,
      buildTestArgumentString("--plugin \"%s\" --input \"%s\"",
                              pluginFile->absolutePath->data, inputPath->data),
      RETURN_CODE_SUCCESS, kTestOutputPcm, applicationPath, resourcesPath);
  freeCharString(inputPath);
  freeFile(pluginFile);
  return result;
}
コード例 #2
0
ファイル: ErrorReporter.c プロジェクト: nano-bot/MrsWatson
void errorReporterRemapPath(ErrorReporter self, CharString path) {
  File pathAsFile = newFileWithPath(path);
  CharString basename = fileGetBasename(pathAsFile);
  File parent = newFileWithPath(self->reportDirPath);
  File remappedPath = newFileWithParent(parent, basename);

  charStringCopy(path, remappedPath->absolutePath);

  freeCharString(basename);
  freeFile(parent);
  freeFile(pathAsFile);
  freeFile(remappedPath);
}
コード例 #3
0
ファイル: ErrorReporter.c プロジェクト: JC-Morph/MrsWatson
void errorReporterInitialize(ErrorReporter self)
{
    CharString infoText = newCharStringWithCString(kErrorReportInfoText);
    CharString wrappedInfoText;
    time_t now;
    size_t length;
    size_t i;

    printf("=== Starting error report ===\n");
    wrappedInfoText = charStringWrap(infoText, 0);
    // The second newline here is intentional
    printf("%s\n", wrappedInfoText->data);

    time(&now);
    self->started = true;

    snprintf(self->reportName->data, self->reportName->capacity,
             "MrsWatson Report %s", ctime(&now));
    // Trim the final newline character from this string if it exists
    length = strlen(self->reportName->data);

    if (self->reportName->data[length - 1] == '\n') {
        self->reportName->data[length - 1] = '\0';
        length--;
    }

    for (i = 0; i < length; i++) {
        if (!(charStringIsLetter(self->reportName, i) ||
                charStringIsNumber(self->reportName, i))) {
            self->reportName->data[i] = '-';
        }
    }

#if UNIX
    snprintf(self->desktopPath->data, self->desktopPath->capacity,
             "%s/Desktop", getenv("HOME"));
#elif WINDOWS
    SHGetFolderPathA(NULL, CSIDL_DESKTOPDIRECTORY, NULL, 0, self->desktopPath->data);
#endif

    // Try to place the report on the user's desktop. However, if we cannot find
    // the desktop (which may occur with localized Linux installations, for instance),
    // then just dump it in the current directory instead.
    File desktopPath = newFileWithPath(self->desktopPath);
    File reportPath;

    if (!fileExists(desktopPath)) {
        logWarn("Could not find desktop location, placing error report in current directory instead");
        CharString currentDirString = fileGetCurrentDirectory();
        File currentDir = newFileWithPath(currentDirString);
        reportPath = newFileWithParent(currentDir, self->reportName);
        freeFile(currentDir);
        freeCharString(currentDirString);
    } else {
        reportPath = newFileWithParent(desktopPath, self->reportName);
        freeFile(desktopPath);
    }

    if (fileExists(reportPath)) {
        logCritical("The path '%s' already contains a previous error report. Please remove the report data and try again.");
    } else {
        fileCreate(reportPath, kFileTypeDirectory);
    }

    // Now we should have a real error report path
    charStringCopy(self->reportDirPath, reportPath->absolutePath);

    freeFile(reportPath);
    freeCharString(wrappedInfoText);
    freeCharString(infoText);
}