CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/Utilities/StorageFactory/plugins/HttpStorageMaker.cc

Go to the documentation of this file.
00001 #include "Utilities/StorageFactory/interface/StorageMaker.h"
00002 #include "Utilities/StorageFactory/interface/StorageMakerFactory.h"
00003 #include "Utilities/StorageFactory/interface/StorageFactory.h"
00004 #include "Utilities/StorageFactory/interface/RemoteFile.h"
00005 
00006 class HttpStorageMaker : public StorageMaker
00007 {
00008 public:
00009   virtual Storage *open (const std::string &proto,
00010                          const std::string &path,
00011                          int mode)
00012   {
00013     std::string    temp;
00014     StorageFactory *f = StorageFactory::get();
00015     int            localfd = RemoteFile::local (f->tempDir(), temp);
00016     std::string    newurl ((proto == "web" ? "https" : proto) + ":" + path);
00017     const char     *curlopts [] = {
00018       "curl", "-L", "-f", "-o", temp.c_str(), "-q", "-s", "--url",
00019       newurl.c_str (), 0
00020     };
00021 
00022     return RemoteFile::get (localfd, temp, (char **) curlopts, mode);
00023   }
00024 };
00025 
00026 DEFINE_EDM_PLUGIN (StorageMakerFactory, HttpStorageMaker, "https");
00027 DEFINE_EDM_PLUGIN (StorageMakerFactory, HttpStorageMaker, "ftp");
00028 DEFINE_EDM_PLUGIN (StorageMakerFactory, HttpStorageMaker, "web");