File indexing completed on 2024-04-06 12:31:53
0001 #include "FWCore/Utilities/interface/Exception.h"
0002 #include "Utilities/StorageFactory/test/Test.h"
0003 #include "Utilities/StorageFactory/interface/File.h"
0004 #include "Utilities/StorageFactory/interface/Storage.h"
0005 #include <string>
0006
0007 int main(int argc, char* argv[]) try {
0008 initTest();
0009
0010 std::string path("rfio:/castor/cern.ch/cms/test/IBTestFiles/rfiotestwrite");
0011 if (argc > 1) {
0012 path = std::string("rfio:") + argv[1];
0013 }
0014 std::cout << "copying /etc/profile to " << path << "\n";
0015
0016 using namespace edm::storage;
0017
0018 IOSize bytes;
0019 unsigned char buf[4096];
0020 File input("/etc/profile");
0021 auto s = StorageFactory::get()->open(path.c_str(), IOFlags::OpenWrite | IOFlags::OpenCreate | IOFlags::OpenTruncate);
0022
0023 while ((bytes = input.read(buf, sizeof(buf))))
0024 s->write(buf, bytes);
0025
0026 input.close();
0027 s->close();
0028
0029 std::cout << StorageAccount::summaryText(true) << std::endl;
0030 return EXIT_SUCCESS;
0031 } catch (cms::Exception const& e) {
0032 std::cerr << e.explainSelf() << std::endl;
0033 return EXIT_FAILURE;
0034 } catch (std::exception const& e) {
0035 std::cerr << e.what() << std::endl;
0036 return EXIT_FAILURE;
0037 }