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 const std::string &tmpdir)
00016 {
00017 std::string fullpath(proto + ":" + path);
00018 return new XrdFile (fullpath, mode);
00019 }
00020
00021 virtual bool check (const std::string &proto,
00022 const std::string &path,
00023 IOOffset *size = 0)
00024 {
00025 std::string fullpath(proto + ":" + path);
00026 XrdClientAdmin admin(fullpath.c_str());
00027 if (! admin.Connect())
00028 return false;
00029
00030 long id;
00031 long flags;
00032 long modtime;
00033 long long xrdsize;
00034
00035 XrdOucString str(fullpath.c_str());
00036 XrdClientUrlSet url(str);
00037
00038 if (! admin.Stat(url.GetFile().c_str(), id, xrdsize, flags, modtime))
00039 return false;
00040
00041 *size = xrdsize;
00042 return true;
00043 }
00044 };
00045
00046 DEFINE_EDM_PLUGIN (StorageMakerFactory, XrdStorageMaker, "root");