void FaustgenFactory::removeSVG()
{
  if (fDrawPath != File::nonexistent)
  {
    getSVGFile().getParentDirectory().deleteRecursively();
  }
}
String FaustgenFactory::getHTMLURI()
{
  File svgPathForThisInstance(fDrawPath.getChildFile(getSVGFolderName()));

  String URI;
#if 0
  URI << "file://" << svgPathForThisInstance.getChildFile("index.html").getFullPathName(); //TODO: will this work on windows?
#else
  URI << "file://" << getSVGFile().getFullPathName(); //TODO: will this work on windows?
#endif
  return URI;
}
void FaustgenFactory::generateSVG()
{
  // To be sure we get a correct SVG diagram...
  removeSVG();
 
  // Prepare compile options
  std::string error;
  const char* argv[64];
  memset(argv, 0, 64 * sizeof(char*));
  
  jassert(fCompileOptions.size() < 64);
  
  auto opt = 0;
  
  for (opt = 0; opt < fCompileOptions.size(); opt++)
  {
    argv[opt] = (char*) fCompileOptions.getReference(opt).toRawUTF8();
  }
  
  argv[opt++] = "-svg";
  argv[opt++] = "-sn";
  argv[opt++] = "-sd";

  if (fDrawPath != File::nonexistent)
  {
    // Generate SVG file
    if (!generateAuxFilesFromString(getTMPName().toStdString(), fSourceCode.toStdString(), fCompileOptions.size() + 3, argv, error))
    {
      //TODO: if there is an error here STOP
      LOG("Generate SVG error : " + error);
    }

    File svgFile = getSVGFile();

    if (svgFile.exists())
    {
    #if 0
      File htmlFile(fDrawPath.getFullPathName() + "/" + getSVGFolderName() + "/index.html");
      htmlFile.appendText(HTML_WRAPPER);  
    #else
      XmlDocument svgXML(svgFile);
      ScopedPointer<XmlElement> mainElement (svgXML.getDocumentElement());
      mainElement->setAttribute("width", "100%");
      mainElement->setAttribute("height", "100%");
      mainElement->writeToFile(svgFile, String::empty);
    #endif
    }
  }
}