Go to the documentation of this file.00001 #include "Utilities/StorageFactory/interface/StorageMaker.h"
00002 #include "Utilities/StorageFactory/interface/StorageMakerFactory.h"
00003 #include "Utilities/XrdAdaptor/src/XrdFile.h"
00004 #include "XrdClient/XrdClientAdmin.hh"
00005 #include "XrdClient/XrdClientUrlSet.hh"
00006
00007 class XrdStorageMaker : public StorageMaker
00008 {
00009 public:
00012 virtual Storage *open (const std::string &proto,
00013 const std::string &path,
00014 int mode)
00015 {
00016 std::string fullpath(proto + ":" + path);
00017 return new XrdFile (fullpath, mode);
00018 }
00019
00020 virtual void stagein (const std::string &proto, const std::string &path)
00021 {
00022 std::string fullpath(proto + ":" + path);
00023 XrdClientAdmin admin(fullpath.c_str());
00024 if (admin.Connect())
00025 {
00026 XrdOucString str(fullpath.c_str());
00027 XrdClientUrlSet url(str);
00028 admin.Prepare(url.GetFile().c_str(), kXR_stage | kXR_noerrs, 0);
00029 }
00030 }
00031
00032 virtual bool check (const std::string &proto,
00033 const std::string &path,
00034 IOOffset *size = 0)
00035 {
00036 std::string fullpath(proto + ":" + path);
00037 XrdClientAdmin admin(fullpath.c_str());
00038 if (! admin.Connect())
00039 return false;
00040
00041 long id;
00042 long flags;
00043 long modtime;
00044 long long xrdsize;
00045
00046 XrdOucString str(fullpath.c_str());
00047 XrdClientUrlSet url(str);
00048
00049 if (! admin.Stat(url.GetFile().c_str(), id, xrdsize, flags, modtime))
00050 return false;
00051
00052 *size = xrdsize;
00053 return true;
00054 }
00055 };
00056
00057 DEFINE_EDM_PLUGIN (StorageMakerFactory, XrdStorageMaker, "root");