コード例 #1
0
ファイル: FileUtilities.c プロジェクト: ZECTBynmo/MrsWatson
boolByte copyFileToDirectory(const CharString fileAbsolutePath, const CharString directoryAbsolutePath) {
  boolByte result = false;
  CharString fileOutPath = newCharStringWithCapacity(kCharStringLengthLong);
  CharString fileBasename = NULL;
  FILE *input = NULL;
  FILE *output = NULL;
  char ch;

  fileBasename = newCharStringWithCString(getFileBasename(fileAbsolutePath->data));
  buildAbsolutePath(directoryAbsolutePath, fileBasename, NULL, fileOutPath);
  input = fopen(fileAbsolutePath->data, "rb");
  if(input != NULL) {
    output = fopen(fileOutPath->data, "wb");
    if(output != NULL) {
      while(fread(&ch, 1, 1, input) == 1) {
        fwrite(&ch, 1, 1, output);
      }
      result = true;
    }
  }

  if(input != NULL) {
    fclose(input);
  }
  if(output != NULL) {
    fclose(output);
  }
  freeCharString(fileOutPath);
  freeCharString(fileBasename);
  return result;
}
コード例 #2
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;
}
コード例 #3
0
ファイル: TaskTimer.c プロジェクト: denisfitz57/MrsWatson
void freeTaskTimer(TaskTimer self) {
  if(self != NULL) {
    freeCharString(self->component);
    freeCharString(self->subcomponent);
    free(self);
  }
}
コード例 #4
0
ファイル: ErrorReporter.c プロジェクト: nano-bot/MrsWatson
void freeErrorReporter(ErrorReporter errorReporter) {
  if (errorReporter != NULL) {
    freeCharString(errorReporter->reportName);
    freeCharString(errorReporter->reportDirPath);
    freeCharString(errorReporter->desktopPath);
    free(errorReporter);
  }
}
コード例 #5
0
ファイル: ErrorReporter.c プロジェクト: Notalib/MrsWatson
void errorReporterRemapPath(ErrorReporter self, CharString path) {
  CharString basename = newCharString();
  CharString outString = newCharStringWithCapacity(path->capacity);

  charStringCopyCString(basename, getFileBasename(path->data));
  buildAbsolutePath(self->reportDirPath, basename, NULL, outString);
  charStringCopy(path, outString);

  freeCharString(basename);
  freeCharString(outString);
}
コード例 #6
0
ファイル: FileUtilitiesTest.c プロジェクト: Notalib/MrsWatson
static int _testBuildAbsolutePathNullFile(void) {
  CharString d = getCurrentDirectory();
  CharString out = newCharString();

  buildAbsolutePath(d, NULL, NULL, out);
  assert(charStringIsEmpty(out));

  freeCharString(d);
  freeCharString(out);
  return 0;
}
コード例 #7
0
ファイル: FileUtilitiesTest.c プロジェクト: Notalib/MrsWatson
static int _testBuildAbsolutePathNullPath(void) {
  CharString f = newCharString();
  CharString out = newCharString();

  buildAbsolutePath(NULL, f, NULL, out);
  assert(charStringIsEmpty(out));

  freeCharString(f);
  freeCharString(out);
  return 0;
}
コード例 #8
0
ファイル: PluginTest.c プロジェクト: JC-Morph/MrsWatson
static int _testPluginFactoryEmptyPluginName(void)
{
    CharString invalid = newCharString();
    CharString pluginRoot = newCharString();
    Plugin p = pluginFactory(invalid, pluginRoot);

    assertIsNull(p);

    freeCharString(invalid);
    freeCharString(pluginRoot);
    freePlugin(p);
    return 0;
}
コード例 #9
0
ファイル: PluginTest.c プロジェクト: JC-Morph/MrsWatson
static int _testPluginFactoryInvalidPlugin(void)
{
    CharString invalid = newCharStringWithCString("invalid");
    CharString pluginRoot = newCharString();
    Plugin p = pluginFactory(invalid, pluginRoot);

    assertIsNull(p);

    freeCharString(invalid);
    freeCharString(pluginRoot);
    freePlugin(p);
    return 0;
}
コード例 #10
0
ファイル: FileUtilitiesTest.c プロジェクト: Notalib/MrsWatson
static int _testBuildAbsolutePathEmptyPath(void) {
  CharString d = newCharString();
  CharString f = newCharStringWithCString(TEST_FILENAME);
  CharString out = newCharString();

  buildAbsolutePath(d, f, NULL, out);
  assert(charStringIsEmpty(out));

  freeCharString(d);
  freeCharString(f);
  freeCharString(out);
  return 0;
}
コード例 #11
0
ファイル: ErrorReporter.c プロジェクト: Notalib/MrsWatson
boolByte errorReporterShouldCopyPlugins(void) {
  CharString promptText = newCharStringWithCString(kErrorReportCopyPluginsPromptText);
  CharString wrappedPromptText;
  char response;

  wrappedPromptText = charStringWrap(promptText, 0);
  printf("%s", wrappedPromptText->data);
  freeCharString(wrappedPromptText);
  freeCharString(promptText);

  response = getchar();
  return (response == 'y' || response == 'Y');
}
コード例 #12
0
ファイル: MrsWatson.c プロジェクト: Notalib/MrsWatson
static void printVersion(void) {
  CharString versionString = buildInfoGetVersionString();
  CharString wrappedLicenseInfo;
  CharString licenseString = newCharStringWithCString(LICENSE_STRING);

  printf("%s, build %ld\nCopyright (c) %ld, %s. All rights reserved.\n\n",
    versionString->data, buildInfoGetDatestamp(), buildInfoGetYear(), VENDOR_NAME);
  wrappedLicenseInfo = charStringWrap(licenseString, 0);
  printf("%s\n\n", wrappedLicenseInfo->data);

  freeCharString(licenseString);
  freeCharString(wrappedLicenseInfo);
  freeCharString(versionString);
}
コード例 #13
0
ファイル: FileUtilitiesTest.c プロジェクト: Notalib/MrsWatson
static int _testCopyInvalidFileToDirectory(void) {
  CharString tempDir = _fileUtilitiesMakeTempDir();
  CharString testFilename = newCharStringWithCString(TEST_FILENAME);
  CharString invalid = newCharStringWithCString("invalid");

  convertRelativePathToAbsolute(testFilename, invalid);
  assertFalse(copyFileToDirectory(invalid, tempDir));
  removeDirectory(tempDir);

  freeCharString(testFilename);
  freeCharString(tempDir);
  freeCharString(invalid);
  return 0;
}
コード例 #14
0
ファイル: IntegrationTests.c プロジェクト: nano-bot/MrsWatson
static int _testLoadFxpPresetInVst(const char *testName,
                                   const CharString applicationPath,
                                   const CharString resourcesPath) {
  CharString inputPath = getDefaultInputPath(resourcesPath);
  CharString presetPath =
      getTestResourcePath(resourcesPath, "presets", "again-test.fxp");
  int result = runIntegrationTest(
      testName, buildTestArgumentString("--plugin \"again,%s\" --input \"%s\"",
                                        presetPath->data, inputPath->data),
      RETURN_CODE_SUCCESS, kTestOutputPcm, applicationPath, resourcesPath);
  freeCharString(inputPath);
  freeCharString(presetPath);
  return result;
}
コード例 #15
0
ファイル: PluginTest.c プロジェクト: JC-Morph/MrsWatson
static int _testPluginFactory(void)
{
    CharString silence = newCharStringWithCString("mrs_silence");
    CharString pluginRoot = newCharString();
    Plugin p = pluginFactory(silence, pluginRoot);

    assertNotNull(p);
    assertIntEquals(PLUGIN_TYPE_INTERNAL, p->interfaceType);
    assertCharStringEquals(silence->data, p->pluginName);

    freeCharString(silence);
    freeCharString(pluginRoot);
    freePlugin(p);
    return 0;
}
コード例 #16
0
ファイル: FileTest.c プロジェクト: ZECTBynmo/MrsWatson
static int _testNewFileWithAbsolutePath(void) {
  CharString p = newCharString();
  sprintf(p->data, "%s%c%s", "test", PATH_DELIMITER, "file");
  freeCharString(c);
  
  return 0;
}
コード例 #17
0
ファイル: FileUtilities.c プロジェクト: ZECTBynmo/MrsWatson
boolByte removeDirectory(const CharString absolutePath) {
  boolByte result = false;

#if UNIX
  if(!fileExists(absolutePath->data)) {
    return false;
  }

  // This is a bit lazy, perhaps...
  CharString removeCommand = newCharString();
  snprintf(removeCommand->data, removeCommand->length, "/bin/rm -rf \"%s\"", absolutePath->data);
  result = system(removeCommand->data);
  freeCharString(removeCommand);
  return (result == 0);
#elif WINDOWS
  SHFILEOPSTRUCTA fileOperation = {0};
  fileOperation.wFunc = FO_DELETE;
  fileOperation.pFrom = absolutePath->data;
  fileOperation.fFlags = FOF_NO_UI;
  return (SHFileOperationA(&fileOperation) == 0);
#else
  logUnsupportedFeature("Copy directory recursively");
  return false;
#endif
}
コード例 #18
0
ファイル: ProgramOption.c プロジェクト: Notalib/MrsWatson
static ProgramOption _findProgramOption(ProgramOptions self, const char* name) {
  ProgramOption potentialMatchOption, optionMatch;
  CharString optionStringWithoutDashes;
  unsigned int i;

  if(_isStringShortOption(name)) {
    for(i = 0; i < self->numOptions; i++) {
      potentialMatchOption = self->options[i];
      if(potentialMatchOption->hasShortForm && potentialMatchOption->name->data[0] == name[1]) {
        return potentialMatchOption;
      }
    }
  }

  if(_isStringLongOption(name)) {
    optionMatch = NULL;
    optionStringWithoutDashes = newCharStringWithCapacity(kCharStringLengthShort);
    strncpy(optionStringWithoutDashes->data, name + 2, strlen(name) - 2);
    for(i = 0; i < self->numOptions; i++) {
      potentialMatchOption = self->options[i];
      if(charStringIsEqualTo(potentialMatchOption->name, optionStringWithoutDashes, false)) {
        optionMatch = potentialMatchOption;
        break;
      }
    }
    freeCharString(optionStringWithoutDashes);
    return optionMatch;
  }

  // If no option was found, then return null
  return NULL;
}
コード例 #19
0
ファイル: EventLogger.c プロジェクト: JC-Morph/MrsWatson
static void _logMessage(const LogLevel logLevel, const char *message, va_list arguments)
{
    long elapsedTimeInMs;
    EventLogger eventLogger = _getEventLoggerInstance();
#if WINDOWS
    ULONGLONG currentTime;
#else
    struct timeval currentTime;
#endif

    if (eventLogger != NULL && logLevel >= eventLogger->logLevel) {
        CharString formattedMessage = newCharStringWithCapacity(kCharStringLengthDefault * 2);
        vsnprintf(formattedMessage->data, formattedMessage->capacity, message, arguments);
#if WINDOWS
        currentTime = GetTickCount();
        elapsedTimeInMs = (unsigned long)(currentTime - eventLogger->startTimeInMs);
#else
        gettimeofday(&currentTime, NULL);
        elapsedTimeInMs = ((currentTime.tv_sec - (eventLogger->startTimeInSec + 1)) * 1000) +
                          (currentTime.tv_usec / 1000) + (1000 - eventLogger->startTimeInMs);
#endif
        _printMessage(logLevel, elapsedTimeInMs, getAudioClock()->currentFrame, formattedMessage->data, eventLogger);
        freeCharString(formattedMessage);
    }
}
コード例 #20
0
ファイル: LinkedListTest.c プロジェクト: ZECTBynmo/MrsWatson
static int _testAppendItemToNullList(void) {
  CharString c = newCharString();
  // The test here is not to crash
  linkedListAppend(NULL, c);
  freeCharString(c);
  return 0;
}
コード例 #21
0
ファイル: FileUtilitiesTest.c プロジェクト: Notalib/MrsWatson
static int _testBuildAbsolutePathWithFileExtensionTwice(void) {
  CharString d = newCharStringWithCString(ROOT_DIRECTORY);
  CharString out = newCharString();
  CharString f = newCharStringWithCString(TEST_FILENAME);
  CharString expected = newCharString();

  snprintf(expected->data, expected->capacity, "%s%c%s", ROOT_DIRECTORY, PATH_DELIMITER, TEST_FILENAME);
  buildAbsolutePath(d, f, "txt", out);
  assertCharStringEquals(out, expected->data);

  freeCharString(d);
  freeCharString(out);
  freeCharString(f);
  freeCharString(expected);
  return 0;
}
コード例 #22
0
ファイル: Plugin.c プロジェクト: denisfitz57/MrsWatson
static void _listAvailablePluginsInternal(void) {
  CharString internalLocation = newCharStringWithCString("(Internal)");
  _logPluginLocation(internalLocation);
  logInfo("  %s", kInternalPluginPassthruName);
  logInfo("  %s", kInternalPluginSilenceName);
  freeCharString(internalLocation);
}
コード例 #23
0
ファイル: FileTest.c プロジェクト: ZECTBynmo/MrsWatson
static int _testNewFileWithRelativePath(void) {
  CharString p = newCharString();
  sprintf(p->data, "%s%c%s", "test", PATH_DELIMITER, "file");
  CharString pAbs = newCharString();
  sprintf(p->data, "%s%s%c%s%c%s", ROOT_DIRECTORY, get);
  freeCharString(p);
  return 0;
}
コード例 #24
0
ファイル: FileUtilitiesTest.c プロジェクト: Notalib/MrsWatson
static int _testListInvalidDirectory(void) {
  CharString c = newCharStringWithCString("invalid");
  LinkedList l = listDirectory(c);
  assertIntEquals(linkedListLength(l), 0);
  freeLinkedList(l);
  freeCharString(c);
  return 0;
}
コード例 #25
0
ファイル: SampleSourceTest.c プロジェクト: nano-bot/MrsWatson
static int _testGuessSampleSourceTypeWrongCase(void) {
  CharString c = newCharStringWithCString("TEST.PCM");
  SampleSource s = sampleSourceFactory(c);
  assertIntEquals(SAMPLE_SOURCE_TYPE_PCM, s->sampleSourceType);
  freeSampleSource(s);
  freeCharString(c);
  return 0;
}
コード例 #26
0
ファイル: FileUtilitiesTest.c プロジェクト: Notalib/MrsWatson
static int _testRemoveDirectory(void) {
  CharString tempDir = _fileUtilitiesMakeTempDir();
  assert(_fileExists(tempDir->data));
  assert(removeDirectory(tempDir));
  assertFalse(_fileExists(tempDir->data));
  freeCharString(tempDir);
  return 0;
}
コード例 #27
0
ファイル: FileUtilitiesTest.c プロジェクト: Notalib/MrsWatson
static int _testCopyFileToInvalidDirectory(void) {
  CharString tempFile = newCharString();
  CharString testFilename = newCharStringWithCString(TEST_FILENAME);
  CharString invalid = newCharStringWithCString("invalid");
  FILE *fp = fopen(TEST_FILENAME, "w");

  assertNotNull(fp);
  fclose(fp);
  convertRelativePathToAbsolute(testFilename, tempFile);
  assertFalse(copyFileToDirectory(tempFile, invalid));

  unlink(TEST_FILENAME);
  freeCharString(tempFile);
  freeCharString(testFilename);
  freeCharString(invalid);
  return 0;
}
コード例 #28
0
ファイル: SampleSourceTest.c プロジェクト: nano-bot/MrsWatson
static int _testGuessSampleSourceTypePcm(void) {
  CharString c = newCharStringWithCString(TEST_SAMPLESOURCE_FILENAME);
  SampleSource s = sampleSourceFactory(c);
  assertIntEquals(SAMPLE_SOURCE_TYPE_PCM, s->sampleSourceType);
  freeSampleSource(s);
  freeCharString(c);
  return 0;
}
コード例 #29
0
ファイル: MrsWatson.c プロジェクト: Notalib/MrsWatson
static void _printTaskTime(void* item, void* userData) {
  TaskTimer taskTimer = (TaskTimer)item;
  TaskTimer totalTimer = (TaskTimer)userData;
  CharString prettyTimeString = taskTimerHumanReadbleString(taskTimer);
  double timePercentage = 100.0f * taskTimer->totalTaskTime / totalTimer->totalTaskTime;
  logInfo("  %s %s: %s (%2.1f%%)", taskTimer->component->data, taskTimer->subcomponent->data, prettyTimeString->data, timePercentage);
  freeCharString(prettyTimeString);
}
コード例 #30
0
ファイル: SampleSourceTest.c プロジェクト: nano-bot/MrsWatson
static int _testGuessSampleSourceTypeEmpty(void) {
  CharString empty = newCharString();
  SampleSource s = sampleSourceFactory(empty);
  assertIntEquals(SAMPLE_SOURCE_TYPE_SILENCE, s->sampleSourceType);
  freeSampleSource(s);
  freeCharString(empty);
  return 0;
}