Logo Search packages:      
Sourcecode: libwfut version File versions  Download package

WFUTError WFUT::WFUTClient::getFileList ( const std::string &  url,
ChannelFileList &  files 
)

This function will download a channel file from the specified URL. This function will block until complete. This is the wfut.xml file.

Definition at line 115 of file WFUT.cpp.

                                                                              {
  assert (m_initialised == true);

  FILE *fp = os_create_tmpfile();
  if (!fp) {
    fprintf(stderr, "Unable to create temporary file\n");
     perror("");
    return WFUT_GENERAL_ERROR;
  }

  if (m_io->downloadFile(fp, url, 0)) {
    // error
    fprintf(stderr, "Error downloading file list\n");
    os_free_tmpfile(fp);
    return WFUT_DOWNLOAD_ERROR;
  }

  std::string xml;
  // Pre-allocate string memory
  xml.reserve(ftell(fp));
  rewind(fp);
  char buf[1024];
  size_t n;
  while ((n = fread(buf, sizeof(char), 1024, fp) ) > 0) {
    xml.append(buf, n);  
  }

  os_free_tmpfile(fp);

  if (parseFileListXML(xml, files)) {
    // Error
    fprintf(stderr, "Error parsing file list\n");
    return WFUT_PARSE_ERROR;
  }

  return WFUT_NO_ERROR;
}


Generated by  Doxygen 1.6.0   Back to index