Example #1
0
void ReplayBuilder::copyReplayResource(const char *resource,
                                       const char *targetDir) {
  FileManager fileManager;
  char *localResource = new char[strlen(resource) + 1];
  strcpy(localResource, resource);
  fileManager.fixSlashes(localResource);
  char *filename = fileManager.parseFilename(localResource);
  delete localResource;
  char *targetPath = fileManager.getFilePath(targetDir, filename);
  delete filename;

  if (!fileManager.fileExists(targetPath)) {
    char *resourcePath = getResourcePath(resource);
    if (resourcePath != 0) {
      char *s = 0;
      try {
        s = fileManager.readFile(resourcePath);
      } catch (FileNotFoundException *e) {
        delete e;
      }
      
      if (s != 0) {
        fileManager.writeFile(targetPath, s);
        delete s;
      }
      delete resourcePath;
    }
  }
  delete targetPath;
}