File indexing completed on 2024-04-06 12:31:46
0001 #include "Utilities/StorageFactory/interface/StorageMaker.h"
0002 #include "Utilities/StorageFactory/interface/StorageMakerFactory.h"
0003 #include "Utilities/StorageFactory/interface/StorageFactory.h"
0004 #include "Utilities/LStoreAdaptor/interface/LStoreFile.h"
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0007 #include <unistd.h>
0008 #include <iostream>
0009
0010 namespace edm::storage {
0011 class LStoreStorageMaker : public StorageMaker {
0012 public:
0013
0014
0015 std::unique_ptr<Storage> open(const std::string &proto,
0016 const std::string &path,
0017 int mode,
0018 const AuxSettings &) const override {
0019 std::string fullpath = proto + ":" + path;
0020 return std::make_unique<LStoreFile>(fullpath, mode);
0021 }
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 bool check(const std::string &proto,
0038 const std::string &path,
0039 const AuxSettings &,
0040 IOOffset *size = nullptr) const override {
0041 std::string fullpath = proto + ":" + path;
0042 try {
0043 LStoreFile fileObj(fullpath);
0044 *size = fileObj.position(0, Storage::END);
0045 } catch (cms::Exception &e) {
0046 return false;
0047 }
0048 return true;
0049 }
0050 };
0051 }
0052
0053 using namespace edm::storage;
0054 DEFINE_EDM_PLUGIN(StorageMakerFactory, LStoreStorageMaker, "lstore");