def ctoxml(filePath, cilPath):
    logger = log.setup_custom_logger(__name__)
    logger.debug("Using CIL executable located at %s" % (cilPath))
    if os.path.isdir(filePath):
        for root, dirs, files in os.walk(filePath):
          #excludes files that don't end in .c
          files = [fi for fi in files if fi.endswith(".c")]
          for cfile in files:
            fileName = os.path.abspath(os.path.join(root,cfile))
            xmlName = "%s.xml" % (os.path.splitext(cfile)[0]) 
            #if the generated XML exists, do not re-run CIL on the C file
            if not exists(xmlName): 
              logger.info("Running CIL on %s" % (fileName))
              result, data = util.myrun([cilPath] +  [fileName] + cilArgs)
              if result:
                  logger.error("CIL processing of %s failed: %s" % (fileName, data))
                  break
              cXmlName= os.path.join(root,xmlName)
              logger.debug("Writing results of CIL processing to %s" % (cXmlName))
              util.writefile(cXmlName, data)
    else:
      result, data = util.myrun([cilPath] +  [filePath] + cilArgs)
      logger.debug("Writing results of CIL proceesing to %s" % (cXmlName))
      til.writefile(cXmlName, data)
 def extract(self, input, cilPath):
   """Extract metac objects from XML"""
   self.structs = []
   self.functions = []
   if os.path.isdir(input):
       for root, dirs, files in os.walk(input):
         #excludes files that don't end in .cilxml
         files = [fi for fi in files if fi.endswith(".cilxml")]
         for xmlfile in files:
             xmlPath = os.path.join(root,xmlfile)
             openFile = open(xmlPath)
             self.simple_parse_file(etree.parse(openFile), xmlPath)
   else:
     result, data = util.myrun([cilPath] +  [input] + ["--disallowDuplication", "--noLowerConstants", "--noInsertImplicitCasts", "--dowritexml"])
     name = '%s.xml' % (os.path.splitext(input)[0]) 
     self.simple_parse_file(etree.parse(open(name)), input)