LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::TrivialFileTransfer Class Reference

#include "TrivialFileTransfer.h"

Inheritance diagram for art::TrivialFileTransfer:
art::FileTransfer

Classes

struct  Config
 

Public Types

using Parameters = ServiceTable< Config >
 

Public Member Functions

 TrivialFileTransfer (Parameters const &pset)
 
int translateToLocalFilename (std::string const &uri, std::string &fileFQname)
 

Private Member Functions

int doTranslateToLocalFilename (std::string const &uri, std::string &fileFQname) override
 
int stripURI (std::string const &uri, std::string &inFileName) const
 
int copyFile (std::ifstream &in, std::ofstream &out) const
 

Detailed Description

Definition at line 26 of file TrivialFileTransfer.h.

Member Typedef Documentation

Constructor & Destructor Documentation

art::TrivialFileTransfer::TrivialFileTransfer ( TrivialFileTransfer::Parameters const &  pset)

Definition at line 18 of file TrivialFileTransfer_service.cc.

20 {}

Member Function Documentation

int art::TrivialFileTransfer::copyFile ( std::ifstream &  in,
std::ofstream &  out 
) const
private

Definition at line 72 of file TrivialFileTransfer_service.cc.

References DEFINE_ART_SERVICE_INTERFACE_IMPL.

73 {
74  std::copy(std::istream_iterator<char>{in},
75  std::istream_iterator<char>{},
76  std::ostream_iterator<char>{out});
77  return 0;
78 }
ifstream in
Definition: comparison.C:7
int art::TrivialFileTransfer::doTranslateToLocalFilename ( std::string const &  uri,
std::string &  fileFQname 
)
overrideprivatevirtual

Implements art::FileTransfer.

Definition at line 23 of file TrivialFileTransfer_service.cc.

References art::detail::FDS::BAD_REQUEST, art::detail::FDS::NOT_FOUND, art::PENDING, and art::SUCCESS.

25 {
26  if (uri.substr(0, 7) != fileURI) {
27  fileFQname = uri; // Unexpected protocol: pass through.
29  }
30 
32  fileFQname = "";
33  std::string inFileName;
34  if (stripURI(uri, inFileName) != 0) {
36  return stat;
37  }
38 
39  ifstream infile{inFileName.c_str()};
40  if (!infile) {
42  return stat;
43  }
44  fileFQname = inFileName;
46  return stat;
47  // Implementation plan details -- alternatives not chosen:
48  // x We could merely return the file name (the URI with file:// stripped off).
49  // Since the SAM developers may look at this file as a template for their
50  // real GeneralFileTransfer service, it is perhaps better to do the work of
51  // making a copy into a designated area.
52  // x We merely strip the file:// from the URI; this adhoc class is not beefed
53  // up to deal with genuine web access.
54  // x An alternative would be to embed the last part of the file FQname into
55  // the
56  // scratch file name, to try to maintain traceability in case things break.
57 }
int stripURI(std::string const &uri, std::string &inFileName) const
int art::TrivialFileTransfer::stripURI ( std::string const &  uri,
std::string &  inFileName 
) const
private

Definition at line 60 of file TrivialFileTransfer_service.cc.

62 {
63  if (uri.substr(0, 7) != fileURI) {
64  inFileName = "";
65  return 1;
66  }
67  inFileName = uri.substr(7);
68  return 0;
69 }
int art::FileTransfer::translateToLocalFilename ( std::string const &  uri,
std::string &  fileFQname 
)
inlineinherited

Definition at line 34 of file FileTransfer.h.

References DECLARE_ART_SERVICE_INTERFACE, art::FileTransfer::doTranslateToLocalFilename(), and art::LEGACY.

36 {
37  CET_ASSERT_ONLY_ONE_THREAD();
38  return doTranslateToLocalFilename(uri, fileFQname);
39 }
virtual int doTranslateToLocalFilename(std::string const &uri, std::string &fileFQname)=0

The documentation for this class was generated from the following files: