Reading a file through http

Hi,

As far as I know (and I’m not a root developer), Root does not have this ability. You can use commands like wget to easily grab the files so that you can use them.

If you’re really gung-ho on not grabbing the file ahead of time, you could do something as wacky as this (although I can’t see a good reason for actually doing this :smiley: )

   string command = "curl http://some.web.page/somefile.txt";

   FILE *fpipe;
   if ( ! (fpipe = (FILE*) popen (command.c_str(), "r") ) )
   {  // If fpipe is NULL
      cerr << "Problems with pipe" << endl;
      exit(1);
   } // if problem

   const int kLongLine = 1001;
   char c_line[kLongLine+1]; // make sure this line is long enough
   while ( fgets( c_line, sizeof line, fpipe))
   {
      string line (c_line);
      // if this line is not long enough, let us know
      assert (line.length() < kLongLine - 1);
      // processLineHere
      cout << line;
   } // while next line
   cout.flush();
   pclose(fpipe);

Cheers,
Charles

p.s. there may be a more c++ friendly way of using pipes but I’m not familiar with it…