Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:53

0001 #include "Utilities/StorageFactory/test/Test.h"
0002 #include "Utilities/StorageFactory/interface/Storage.h"
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 
0005 int main(int argc, char **argv) try {
0006   initTest();
0007 
0008   if (argc != 2) {
0009     std::cerr << "usage: " << argv[0] << " FILE\n";
0010     return EXIT_FAILURE;
0011   }
0012 
0013   using namespace edm::storage;
0014   IOOffset size = -1;
0015   bool exists = StorageFactory::get()->check(argv[1], &size);
0016 
0017   std::cout << "exists = " << exists << ", size = " << size << "\n";
0018   if (!exists)
0019     return EXIT_SUCCESS;
0020 
0021   static const int SIZE = 1048576;
0022   auto s = StorageFactory::get()->open(argv[1]);
0023   char *buf = (char *)malloc(SIZE);
0024   IOSize n;
0025 
0026   while ((n = s->read(buf, SIZE)))
0027     std::cout.write(buf, n);
0028 
0029   s->close();
0030   free(buf);
0031 
0032   std::cerr << StorageAccount::summaryText(true) << std::endl;
0033   return EXIT_SUCCESS;
0034 } catch (cms::Exception const &e) {
0035   std::cerr << e.explainSelf() << std::endl;
0036   return EXIT_FAILURE;
0037 } catch (std::exception const &e) {
0038   std::cerr << e.what() << std::endl;
0039   return EXIT_FAILURE;
0040 }