CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::FileInPath Class Reference

#include <FileInPath.h>

Public Types

enum  LocationCode { Unknown = 0, Local = 1, Release = 2, Data = 3 }
 

Public Member Functions

 FileInPath ()
 
 FileInPath (const std::string &r)
 We throw an exception is the referenced file is not found. More...
 
 FileInPath (const char *r)
 
 FileInPath (FileInPath const &other)
 
std::string fullPath () const
 
LocationCode location () const
 Where was the file found? More...
 
FileInPathoperator= (FileInPath const &other)
 
void read (std::istream &is)
 
void readFromParameterSetBlob (std::istream &is)
 
std::string relativePath () const
 
void swap (FileInPath &other)
 
void write (std::ostream &os) const
 
 ~FileInPath ()
 

Static Public Member Functions

static void disableFileLookup ()
 Should only be called while the edmWriteConfigs executable runs. More...
 

Private Member Functions

void getEnvironment ()
 
void initialize_ ()
 

Private Attributes

std::string canonicalFilename_
 
std::string dataTop_
 
std::string localTop_
 
LocationCode location_
 
std::string relativePath_
 
std::string releaseTop_
 
std::string searchPath_
 

Detailed Description

Definition at line 68 of file FileInPath.h.

Member Enumeration Documentation

Enumerator
Unknown 
Local 
Release 
Data 

Definition at line 72 of file FileInPath.h.

Constructor & Destructor Documentation

edm::FileInPath::FileInPath ( )

Default c'tor does no file-existence check; what file would it check for existence?

Definition at line 113 of file FileInPath.cc.

References getEnvironment().

113  :
114  relativePath_(),
117  {
118  if (s_fileLookupDisabled) {
119  return;
120  }
121  getEnvironment();
122  }
std::string canonicalFilename_
Definition: FileInPath.h:125
void getEnvironment()
Definition: FileInPath.cc:406
LocationCode location_
Definition: FileInPath.h:126
std::string relativePath_
Definition: FileInPath.h:124
edm::FileInPath::FileInPath ( const std::string &  r)
explicit

We throw an exception is the referenced file is not found.

Definition at line 124 of file FileInPath.cc.

References getEnvironment(), and initialize_().

124  :
125  relativePath_(r),
128  {
129  if (s_fileLookupDisabled) {
130  return;
131  }
132  getEnvironment();
133  initialize_();
134  }
std::string canonicalFilename_
Definition: FileInPath.h:125
void getEnvironment()
Definition: FileInPath.cc:406
LocationCode location_
Definition: FileInPath.h:126
void initialize_()
Definition: FileInPath.cc:440
std::string relativePath_
Definition: FileInPath.h:124
edm::FileInPath::FileInPath ( const char *  r)
explicit

Definition at line 136 of file FileInPath.cc.

References Exception, edm::errors::FileInPathError, getEnvironment(), and initialize_().

136  :
137  relativePath_(r ? r : ""),
140  {
141  if (s_fileLookupDisabled) {
142  return;
143  }
144  if(r == nullptr) {
145  throw edm::Exception(edm::errors::FileInPathError) << "Relative path must not be null\n";
146  }
147  getEnvironment();
148  initialize_();
149  }
std::string canonicalFilename_
Definition: FileInPath.h:125
void getEnvironment()
Definition: FileInPath.cc:406
LocationCode location_
Definition: FileInPath.h:126
void initialize_()
Definition: FileInPath.cc:440
std::string relativePath_
Definition: FileInPath.h:124
edm::FileInPath::FileInPath ( FileInPath const &  other)

Definition at line 151 of file FileInPath.cc.

151  :
152  relativePath_(other.relativePath_),
153  canonicalFilename_(other.canonicalFilename_),
154  location_(other.location_),
155  localTop_(other.localTop_),
156  releaseTop_(other.releaseTop_),
157  dataTop_(other.dataTop_),
158  searchPath_(other.searchPath_)
159  {}
std::string canonicalFilename_
Definition: FileInPath.h:125
std::string dataTop_
Definition: FileInPath.h:129
std::string searchPath_
Definition: FileInPath.h:130
std::string releaseTop_
Definition: FileInPath.h:128
LocationCode location_
Definition: FileInPath.h:126
std::string relativePath_
Definition: FileInPath.h:124
std::string localTop_
Definition: FileInPath.h:127
edm::FileInPath::~FileInPath ( )

Definition at line 161 of file FileInPath.cc.

161 {}

Member Function Documentation

void edm::FileInPath::disableFileLookup ( )
static

Should only be called while the edmWriteConfigs executable runs.

Definition at line 524 of file FileInPath.cc.

524  {
525  s_fileLookupDisabled = true;
526  }
std::string edm::FileInPath::fullPath ( ) const

Return a string that can be used to open the referenced file.

Note that operations on this file may fail, including testing for existence. This is because the state of a filesystem is global; other threads, processes, etc., may have removed the file since we checked on its existence at the time of construction of the FileInPath object.

Definition at line 197 of file FileInPath.cc.

References canonicalFilename_.

Referenced by MillePedeAlignmentAlgorithm::addPxbSurvey(), SiStripBadFiberBuilder::algoAnalyze(), SiStripBadChannelBuilder::algoAnalyze(), PileupJetIdAlgo::AlgoGBRForestsAndConstants::AlgoGBRForestsAndConstants(), SiStripNoisesBuilder::analyze(), SiStripThresholdBuilder::analyze(), SiStripApvGainBuilder::analyze(), SiStripPedestalsBuilder::analyze(), JetCorrectorDemo::analyze(), MuonGeometrySVGTemplate::analyze(), HcalLutAnalyzer::analyze(), DetIdSelectorTest::analyze(), BeamSpotFakeConditions::BeamSpotFakeConditions(), AntiElectronIDMVA5::beginEvent(), AntiElectronIDMVA6::beginEvent(), JetCorrectorDBWriter::beginJob(), ProtonTaggerFilter::beginJob(), omtf::OmtfPacker::beginRun(), omtf::OmtfUnpacker::beginRun(), GoodSeedProducer::beginRun(), BOOST_PYTHON_MODULE(), BTagSFProducer::BTagSFProducer(), HcalTPGCoderULUT::buildCoder(), SiStripDetVOffBuilder::BuildDetVOffObj(), MagGeoBuilderFromDDD::buildInterpolator(), MaterialBudgetCategorizer::buildMaps(), CaloMiscalibTools::CaloMiscalibTools(), CaloMiscalibToolsMC::CaloMiscalibToolsMC(), CastorTextCalibrations::CastorTextCalibrations(), GBRForestWriter::categoryEntryType::categoryEntryType(), CTPPSPixelDAQMappingESSourceXML::CompleteFileName(), TotemDAQMappingESSourceXML::CompleteFileName(), GBRForestTools::createGBRForest(), createGBRForest(), CSCMonitorModule::CSCMonitorModule(), CSCTFPtLUT::CSCTFPtLUT(), DatabasePDG::DatabasePDG(), HcalTPGCoderULUT::dbRecordCallback(), DDCMSDetector::DDCMSDetector(), SiStripPopConNoisesHandlerFromDQM::dqmEndJob(), SiStripPopConPedestalsHandlerFromDQM::dqmEndJob(), SiStripPopConBadComponentsHandlerFromDQM::dqmEndJob(), SiStripPopConFEDErrorsHandlerFromDQM::dqmEndJob(), DTOccupancyTestML::dqmEndLuminosityBlock(), dtCalibration::DTTTrigResidualCorrection::DTTTrigResidualCorrection(), EcalDQMonitorClient::EcalDQMonitorClient(), ElectronIdMVAProducer::ElectronIdMVAProducer(), ElectronPATIdMVAProducer::ElectronPATIdMVAProducer(), EmulateCPPF::EmulateCPPF(), OccupancyPlots::endRun(), ESDataFormatterV4::ESDataFormatterV4(), ESDigiToRaw::ESDigiToRaw(), ESElectronicsMapper::ESElectronicsMapper(), ESIntegrityClient::ESIntegrityClient(), ESPedestalClient::ESPedestalClient(), MultipleScatteringX0Data::fileName(), CSCReadoutMappingFromFile::fill(), HGCalTriggerGeometryHexImp1::fillMaps(), HGCalTriggerGeometryHexImp2::fillMaps(), HGCalTriggerGeometryHexLayerBasedImp1::fillMaps(), HGCalTriggerGeometryHexImp2::fillNeighborMaps(), HGCalTriggerGeometryHexLayerBasedImp1::fillNeighborMaps(), SiStripGain::fillNewGain(), popcon::SiStripPopConHandlerUnitTestNoise< T >::fillObject(), popcon::SiStripPopConHandlerUnitTest< T >::fillObject(), popcon::SiStripPopConHandlerUnitTestGain< T >::fillObject(), SiStripPI::fillTotalComponents(), muonisolation::IsolatorByNominalEfficiency::findPath(), G4ProcessHelper::G4ProcessHelper(), gen::BaseHadronizer::generateLHE(), GeometryConfiguration::GeometryConfiguration(), ESTrivialConditionRetriever::getChannelStatusFromConfiguration(), EcalTrivialConditionRetriever::getChannelStatusFromConfiguration(), getfullpathfromfip_(), EcalTrivialConditionRetriever::getMappingFromConfiguration(), SiStripGainFromAsciiFile::getNewObject(), SiStripBadStripFromASCIIFile::getNewObject(), SiStripNoisesFromDBMiscalibrator::getNewObject_withDefaults(), EcalMappingElectronicsHandler::getNewObjects(), EcalTrivialConditionRetriever::getTrgChannelStatusFromConfiguration(), ESTrivialConditionRetriever::getWeightsFromConfiguration(), EcalTrivialConditionRetriever::getWeightsFromConfiguration(), HcalHardcodeCalibrations::HcalHardcodeCalibrations(), HcalLaserEventFilter2012::HcalLaserEventFilter2012(), HcalTextCalibrations::HcalTextCalibrations(), pfEGHelpers::HeavyObjectCache::HeavyObjectCache(), HGCalTriggerTowerGeometryHelper::HGCalTriggerTowerGeometryHelper(), PDFWeightsHelper::Init(), MVAVariableManager< reco::GsfElectron >::init(), gen::EvtGenInterface::init(), CandidateBoostedDoubleSecondaryVertexComputer::initialize(), HGCalTriggerGeometryImp1::initialize(), CombinedMVAV2JetTagComputer::initialize(), MuonTagger::initialize(), CandidateChargeBTagComputer::initialize(), ElectronTagger::initialize(), CharmTagger::initialize(), ApeSettingAlgorithm::initialize(), deep_tau::DeepTauBase::initializeGlobalCache(), PileupJetIdProducer::initJetEnergyCorrector(), JetCalibrationParameterSetTauJet::JetCalibrationParameterSetTauJet(), JetPartonNamespace::JetPartonCalibrationParameterSet::JetPartonCalibrationParameterSet(), L1GtTriggerMenuXmlProducer::L1GtTriggerMenuXmlProducer(), L1TCaloParamsESProducer::L1TCaloParamsESProducer(), L1TCaloStage2ParamsESProducer::L1TCaloStage2ParamsESProducer(), L1TGlobalPrescalesVetosESProducer::L1TGlobalPrescalesVetosESProducer(), l1t::L1TGlobalUtil::L1TGlobalUtil(), L1TMuonBarrelKalmanLUTs::L1TMuonBarrelKalmanLUTs(), L1TMuonBarrelParamsESProducer::L1TMuonBarrelParamsESProducer(), L1TMuonGlobalParamsESProducer::L1TMuonGlobalParamsESProducer(), L1TMuonOverlapParamsESProducer::L1TMuonOverlapParamsESProducer(), CovarianceParameterization::load(), L1MuDTPhiLut::load(), L1MuDTPtaLut::load(), L1MuDTEtaPatternLut::load(), L1MuBMTEtaPatternLut::load(), L1MuDTQualPatternLut::load(), L1MuBMTQualPatternLut::load(), L1MuDTExtLut::load(), L1TMuonBarrelParamsHelper::load_ext(), EcalDeadChannelRecoveryNN< DetIdT >::load_file(), L1TMuonBarrelParamsHelper::load_phi(), L1TMuonBarrelParamsHelper::load_pt(), PFMETAlgorithmMVA::loadMVAfromFile(), ClusterShapeHitFilter::loadStripLimits(), SiStripFedCablingFakeESSource::make(), jpt::Map::Map(), MultiEventFilter::MultiEventFilter(), MuonErrorMatrix::MuonErrorMatrix(), PhysicsTools::MVAComputerESSourceBase::MVAComputerESSourceBase(), MVAJetPuId::MVAJetPuId(), PhysicsTools::MVATrainer::MVATrainer(), fastsim::NuclearInteraction::NuclearInteraction(), NuclearInteractionSimulator::NuclearInteractionSimulator(), gen::Herwig6Instance::openParticleSpecFile(), l1t::L1TGlobalUtil::OverridePrescalesAndMasks(), HcalTBObjectUnpacker::parseCalib(), cond::persistency::parseFipConnectionString(), DDLParser::parseOneFile(), EcalTrigPrimESProducer::parseTextFile(), EcalTrigTowerConstituentsMapBuilder::parseTextMap(), CaloTowerConstituentsMapBuilder::parseTextMap(), cms::PileupJPTJetIdAlgo::PileupJPTJetIdAlgo(), PixelTemplateSmearerBase::PixelTemplateSmearerBase(), SiPixelFakeCPEGenericErrorParmESSource::produce(), SiPixelFakeTemplateDBObjectESSource::produce(), SiPixelFakeGenErrorDBObjectESSource::produce(), HBHEDarkeningEP::produce(), HepPDTESSource::produce(), SiPixelFakeGainForHLTESSource::produce(), SiPixelFakeGainOfflineESSource::produce(), SiPixelFakeGainESSource::produce(), SiPixelFakeLorentzAngleESSource::produce(), MaskedRctInputDigiProducer::produce(), CaloTPGTranscoderULUTs::produce(), JetCorrectionESSource< Corrector >::produce(), gen::PtYDistributor::PtYDistributor(), SiPixelTemplate2D::pushfile(), SiPixelTemplate::pushfile(), gen::Py8InterfaceBase::Py8InterfaceBase(), FIPConfiguration::readConfig(), CSCTFPtLUT::readLUT(), CSCSectorReceiverLUT::readLUTsFromFile(), GsfBetheHeitlerUpdator::readParameters(), gen::ReggeGribovPartonMCHadronizer::ReggeGribovPartonMCHadronizer(), RPCCalibSetUp::RPCCalibSetUp(), RPCDBSimSetUp::RPCDBSimSetUp(), RPCRecHitProducer::RPCRecHitProducer(), gen::Pythia6Service::setPYUPDAParams(), gen::Pythia6Service::setSLHAParams(), PhiSymmetryCalibration::setUp(), ShiftedJetProducerT< T, Textractor >::ShiftedJetProducerT(), ShiftedPFCandidateProducerForNoPileUpPFMEt::ShiftedPFCandidateProducerForNoPileUpPFMEt(), ShiftedPFCandidateProducerForPFNoPUMEt::ShiftedPFCandidateProducerForPFNoPUMEt(), SiStripBadModuleByHandBuilder::SiStripBadModuleByHandBuilder(), SiStripDetInfoFileReader::SiStripDetInfoFileReader(), SiStripDigitizerAlgorithm::SiStripDigitizerAlgorithm(), SiStripHitEffFromCalibTree::SiStripHitEffFromCalibTree(), SiStripQuality::SiStripQuality(), SiStripQualityHotStripIdentifier::SiStripQualityHotStripIdentifier(), SiStripQualityHotStripIdentifierRoot::SiStripQualityHotStripIdentifierRoot(), SiStripQualityStatistics::SiStripQualityStatistics(), PhysicsTools::MVATrainerLooper::Trainer::Trainer(), TtSemiLepHitFitProducer< LeptonCollection >::TtSemiLepHitFitProducer(), FWRecoGeometryESProducer::writeTrackerParametersXML(), and ZSPJPTJetCorrector::ZSPJPTJetCorrector().

198  {
199  return canonicalFilename_;
200  }
std::string canonicalFilename_
Definition: FileInPath.h:125
void edm::FileInPath::getEnvironment ( void  )
private

Definition at line 406 of file FileInPath.cc.

References dataTop_, Exception, edm::errors::FileInPathError, localTop_, releaseTop_, searchPath_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by FileInPath().

406  {
407  static std::string const searchPath = removeSymLinksTokens(PathVariableName);
408  if (searchPath.empty()) {
410  << PathVariableName
411  << " must be defined\n";
412  }
413  searchPath_ = searchPath;
414 
415  static std::string const releaseTop = removeSymLinksSrc(RELEASETOP);
416  releaseTop_ = releaseTop;
417 
418  static std::string const localTop = removeSymLinksSrc(LOCALTOP);
419  localTop_ = localTop;
420 
421  static std::string const dataTop = removeSymLinks(DATATOP);
422  dataTop_ = dataTop;
423 
424  if (releaseTop_.empty()) {
425  // RELEASETOP was not set. This means that the environment is set
426  // for the base release itself. So LOCALTOP actually contains the
427  // location of the base release.
429  localTop_.clear();
430  }
431  if (releaseTop_ == localTop_) {
432  // RELEASETOP is the same as LOCALTOP. This means that the environment is set
433  // for the base release itself. So LOCALTOP actually contains the
434  // location of the base release.
435  localTop_.clear();
436  }
437  }
std::string dataTop_
Definition: FileInPath.h:129
std::string searchPath_
Definition: FileInPath.h:130
std::string releaseTop_
Definition: FileInPath.h:128
std::string localTop_
Definition: FileInPath.h:127
void edm::FileInPath::initialize_ ( )
private

Definition at line 440 of file FileInPath.cc.

References beamvalidation::br, canonicalFilename_, Data, dataTop_, Exception, edm::errors::FileInPathError, Local, localTop_, location_, callgraph::path, relativePath_, Release, releaseTop_, searchPath_, and edm::tokenize().

Referenced by FileInPath().

440  {
441  if (relativePath_.empty()) {
443  << "Relative path must not be empty\n";
444  }
445 
446  // Find the file, based on the value of path variable.
447  typedef std::vector<std::string> stringvec_t;
448  stringvec_t pathElements = tokenize(searchPath_, ":");
449  for(auto const& element : pathElements) {
450  // Set the boost::fs path to the current element of
451  // CMSSW_SEARCH_PATH:
452  bf::path pathPrefix(element);
453 
454  // Does the a file exist? locateFile throws is it finds
455  // something goofy.
456  if (locateFile(pathPrefix, relativePath_)) {
457  // Convert relative path to canonical form, and save it.
458  relativePath_ = bf::path(relativePath_).normalize().string();
459 
460  // Save the absolute path.
461  canonicalFilename_ = bf::absolute(relativePath_, pathPrefix).string();
462  if (canonicalFilename_.empty()) {
464  << "fullPath is empty"
465  << "\nrelativePath() is: " << relativePath_
466  << "\npath prefix is: " << pathPrefix.string()
467  << '\n';
468  }
469 
470  // From the current path element, find the branch path (basically the path minus the
471  // last directory, e.g. /src or /share):
472  for (bf::path br = pathPrefix.branch_path(); !br.normalize().string().empty(); br = br.branch_path()) {
473 
474  if (!localTop_.empty()) {
475  // Create a path object for our local path LOCALTOP:
476  bf::path local_(localTop_);
477  // If the branch path matches the local path, the file was found locally:
478  if (br == local_) {
479  location_ = Local;
480  return;
481  }
482  }
483 
484  if (!releaseTop_.empty()) {
485  // Create a path object for our release path RELEASETOP:
486  bf::path release_(releaseTop_);
487  // If the branch path matches the release path, the file was found in the release:
488  if (br == release_) {
489  location_ = Release;
490  return;
491  }
492  }
493 
494  if (!dataTop_.empty()) {
495  // Create a path object for our data path DATATOP:
496  bf::path data_(dataTop_);
497  // If the branch path matches the data path, the file was found in the data area:
498  if (br == data_) {
499  location_ = Data;
500  return;
501  }
502  }
503  }
504  }
505  }
506 
507  // If we got here, we ran out of path elements without finding
508  // what we're looking found.
510  << "edm::FileInPath unable to find file "
511  << relativePath_
512  << " anywhere in the search path."
513  << "\nThe search path is defined by: "
514  << PathVariableName
515  << "\n${"
516  << PathVariableName
517  << "} is: "
518  << getenv(PathVariableName.c_str())
519  << "\nCurrent directory is: "
520  << bf::initial_path().string()
521  << "\n";
522  }
std::string canonicalFilename_
Definition: FileInPath.h:125
std::string dataTop_
Definition: FileInPath.h:129
std::string searchPath_
Definition: FileInPath.h:130
std::string releaseTop_
Definition: FileInPath.h:128
LocationCode location_
Definition: FileInPath.h:126
std::string relativePath_
Definition: FileInPath.h:124
std::string localTop_
Definition: FileInPath.h:127
std::vector< std::string > tokenize(std::string const &input, std::string const &separator)
breaks the input string into tokens, delimited by the separator
FileInPath::LocationCode edm::FileInPath::location ( ) const
FileInPath & edm::FileInPath::operator= ( FileInPath const &  other)

Definition at line 164 of file FileInPath.cc.

References swap(), and groupFilesInBlocks::temp.

165  {
167  this->swap(temp);
168  return *this;
169  }
void swap(FileInPath &other)
Definition: FileInPath.cc:172
void edm::FileInPath::read ( std::istream &  is)

Read from the given istream, and set contents accordingly. Reading errors are reflected in the state of the stream.

Definition at line 266 of file FileInPath.cc.

References canonicalFilename_, Data, dataTop_, Exception, edm::errors::FileInPathError, create_public_lumi_plots::loc, DTRecHitClients_cfi::local, Local, localTop_, location_, relativePath_, Release, releaseTop_, AlCaHLTBitMon_QueryRunRegistry::string, Unknown, and jets_cff::version.

Referenced by edmIntegrityCheck.PublishToFileSystem::get(), and edm::operator>>().

267  {
268  std::string vsn;
269  std::string relname;
270  std::string canFilename;
271 #if 1
272  // This #if needed for backward compatibility
273  // for files written before CMSSW_1_5_0_pre3.
274  is >> vsn;
275  if (!is) return;
276  bool oldFormat = (version != vsn);
277  if (oldFormat) {
278  relname = vsn;
279  bool local;
280  is >> local;
281  location_ = (local ? Local : Release);
282  is >> canFilename;
283  } else {
284  // Current format
285  int loc;
286  is >> relname >> loc;
287  location_ = static_cast<FileInPath::LocationCode>(loc);
288  if (location_ != Unknown) is >> canFilename;
289  }
290 #else
291  is >> vsn >> relname >> loc >> canFilename;
292 #endif
293  if (!is) return;
294  relativePath_ = relname;
295  if (location_ == Local) {
296  if (localTop_.empty()) {
298  << "Environment Variable "
299  << LOCALTOP
300  << " is not set.\n"
301  << "Trying to read Local file: " << canFilename << ".\n";
302  }
303 #if 1
304  // This #if needed for backward compatibility
305  // for files written before CMSSW_1_5_0_pre3.
306  if (oldFormat) {
307  canonicalFilename_ = canFilename;
308  } else
309 #endif
310  canonicalFilename_ = localTop_ + canFilename;
311  } else if (location_ == Release) {
312  if (releaseTop_.empty()) {
314  << "Environment Variable "
315  << RELEASETOP
316  << " is not set.\n";
317  }
318 #if 1
319  // This #if needed for backward compatibility
320  // for files written before CMSSW_1_5_0_pre3.
321  if (oldFormat) {
322  std::string::size_type pos = canFilename.find(BASE);
323  if (pos == 0) {
324  // Replace the placehoder with the path to the base release (site dependent).
325  canonicalFilename_ = releaseTop_ + canFilename.substr(BASE.size());
326  } else {
327  // Needed for files written before CMSSW_1_2_0_pre2.
328  canonicalFilename_ = canFilename;
329  }
330  } else
331 #endif
332  canonicalFilename_ = releaseTop_ + canFilename;
333  } else if (location_ == Data) {
334  if (dataTop_.empty()) {
336  << "Environment Variable "
337  << DATATOP
338  << " is not set.\n";
339  }
340  canonicalFilename_ = dataTop_ + canFilename;
341  }
342  }
std::string canonicalFilename_
Definition: FileInPath.h:125
std::string dataTop_
Definition: FileInPath.h:129
uint16_t size_type
std::string releaseTop_
Definition: FileInPath.h:128
LocationCode location_
Definition: FileInPath.h:126
std::string relativePath_
Definition: FileInPath.h:124
std::string localTop_
Definition: FileInPath.h:127
void edm::FileInPath::readFromParameterSetBlob ( std::istream &  is)

Definition at line 345 of file FileInPath.cc.

References canonicalFilename_, Data, dataTop_, Exception, edm::errors::FileInPathError, create_public_lumi_plots::loc, DTRecHitClients_cfi::local, Local, localTop_, location_, relativePath_, Release, releaseTop_, AlCaHLTBitMon_QueryRunRegistry::string, Unknown, and jets_cff::version.

Referenced by edm::decode().

346  {
347  std::string vsn;
348  std::string relname;
349  std::string canFilename;
350  is >> vsn;
351  if (!is) return;
352  bool oldFormat = (version != vsn);
353  if (oldFormat) {
354  relname = vsn;
355  bool local;
356  is >> local;
357  location_ = (local ? Local : Release);
358  is >> canFilename;
359  } else {
360  // Current format
361  int loc;
362  is >> relname >> loc;
363  location_ = static_cast<FileInPath::LocationCode>(loc);
364  if (location_ != Unknown) is >> canFilename;
365  }
366  if (!is) return;
367  relativePath_ = relname;
368  if (location_ == Local) {
369  if (localTop_.empty()) {
370  localTop_ = "@LOCAL";
371  }
372  if (oldFormat) {
373  canonicalFilename_ = canFilename;
374  } else
375  canonicalFilename_ = localTop_ + canFilename;
376  } else if (location_ == Release) {
377  if (releaseTop_.empty()) {
378  releaseTop_="@RELEASE";
379  }
380  if (oldFormat) {
381  std::string::size_type pos = canFilename.find(BASE);
382  if (pos == 0) {
383  // Replace the placehoder with the path to the base release (site dependent).
384  canonicalFilename_ = releaseTop_ + canFilename.substr(BASE.size());
385  } else {
386  // Needed for files written before CMSSW_1_2_0_pre2.
387  canonicalFilename_ = canFilename;
388  }
389  } else
390  canonicalFilename_ = releaseTop_ + canFilename;
391  } else if (location_ == Data) {
392  if (dataTop_.empty()) {
394  << "Environment Variable "
395  << DATATOP
396  << " is not set.\n";
397  }
398  canonicalFilename_ = dataTop_ + canFilename;
399  }
400  }
std::string canonicalFilename_
Definition: FileInPath.h:125
std::string dataTop_
Definition: FileInPath.h:129
uint16_t size_type
std::string releaseTop_
Definition: FileInPath.h:128
LocationCode location_
Definition: FileInPath.h:126
std::string relativePath_
Definition: FileInPath.h:124
std::string localTop_
Definition: FileInPath.h:127
std::string edm::FileInPath::relativePath ( ) const

Return a string containing the canonical form of the relative path. DO NOT USE THIS AS THE FILENAME for any file operations; use fullPath() for that purpose.

Definition at line 184 of file FileInPath.cc.

References relativePath_.

Referenced by BOOST_PYTHON_MODULE(), FWPSetTableManager::handleEntry(), PDFWeightsHelper::Init(), and edm::operator==().

185  {
186  return relativePath_;
187  }
std::string relativePath_
Definition: FileInPath.h:124
void edm::FileInPath::swap ( FileInPath other)

Definition at line 172 of file FileInPath.cc.

References canonicalFilename_, dataTop_, localTop_, location_, relativePath_, releaseTop_, searchPath_, AlCaHLTBitMon_QueryRunRegistry::string, and std::swap().

Referenced by operator=(), and edm::swap().

173  {
174  relativePath_.swap(other.relativePath_);
175  canonicalFilename_.swap(other.canonicalFilename_);
176  std::swap(location_, other.location_);
177  localTop_.swap(other.localTop_);
178  releaseTop_.swap(other.releaseTop_);
179  dataTop_.swap(other.dataTop_);
180  searchPath_.swap(other.searchPath_);
181  }
std::string canonicalFilename_
Definition: FileInPath.h:125
std::string dataTop_
Definition: FileInPath.h:129
std::string searchPath_
Definition: FileInPath.h:130
std::string releaseTop_
Definition: FileInPath.h:128
LocationCode location_
Definition: FileInPath.h:126
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::string relativePath_
Definition: FileInPath.h:124
std::string localTop_
Definition: FileInPath.h:127
void edm::FileInPath::write ( std::ostream &  os) const

Write contents to the given ostream. Writing errors are reflected in the state of the stream.

Definition at line 203 of file FileInPath.cc.

References canonicalFilename_, Data, dataTop_, Exception, edm::errors::FileInPathError, Local, localTop_, location_, relativePath_, Release, releaseTop_, Unknown, and jets_cff::version.

Referenced by pkg.AbstractPkg::generate(), and edm::operator<<().

204  {
205  if (location_ == Unknown) {
206  os << version << ' ' << relativePath_ << ' ' << location_;
207  } else if (location_ == Local) {
208  // Guarantee a site independent value by stripping $LOCALTOP.
209  if (localTop_.empty()) {
211  << "Environment Variable "
212  << LOCALTOP
213  << " is not set.\n";
214  }
216  if (pos != 0) {
218  << "Path "
220  << " is not in the local release area "
221  << localTop_
222  << "\n";
223  }
224  os << version << ' ' << relativePath_ << ' ' << location_ << ' ' << canonicalFilename_.substr(localTop_.size());
225  } else if (location_ == Release) {
226  // Guarantee a site independent value by stripping $RELEASETOP.
227  if (releaseTop_.empty()) {
229  << "Environment Variable "
230  << RELEASETOP
231  << " is not set.\n";
232  }
234  if (pos != 0) {
236  << "Path "
238  << " is not in the base release area "
239  << releaseTop_
240  << "\n";
241  }
242  os << version << ' ' << relativePath_ << ' ' << location_ << ' ' << canonicalFilename_.substr(releaseTop_.size());
243  } else if (location_ == Data) {
244  // Guarantee a site independent value by stripping $DATATOP.
245  if (dataTop_.empty()) {
247  << "Environment Variable "
248  << DATATOP
249  << " is not set.\n";
250  }
252  if (pos != 0) {
254  << "Path "
256  << " is not in the data area "
257  << dataTop_
258  << "\n";
259  }
260  os << version << ' ' << relativePath_ << ' ' << location_ << ' ' << canonicalFilename_.substr(dataTop_.size());
261  }
262  }
std::string canonicalFilename_
Definition: FileInPath.h:125
std::string dataTop_
Definition: FileInPath.h:129
uint16_t size_type
std::string releaseTop_
Definition: FileInPath.h:128
LocationCode location_
Definition: FileInPath.h:126
std::string relativePath_
Definition: FileInPath.h:124
std::string localTop_
Definition: FileInPath.h:127

Member Data Documentation

std::string edm::FileInPath::canonicalFilename_
private

Definition at line 125 of file FileInPath.h.

Referenced by fullPath(), initialize_(), read(), readFromParameterSetBlob(), swap(), and write().

std::string edm::FileInPath::dataTop_
private

Definition at line 129 of file FileInPath.h.

Referenced by getEnvironment(), initialize_(), read(), readFromParameterSetBlob(), swap(), and write().

std::string edm::FileInPath::localTop_
private

Definition at line 127 of file FileInPath.h.

Referenced by getEnvironment(), initialize_(), read(), readFromParameterSetBlob(), swap(), and write().

LocationCode edm::FileInPath::location_
private

Definition at line 126 of file FileInPath.h.

Referenced by initialize_(), location(), read(), readFromParameterSetBlob(), swap(), and write().

std::string edm::FileInPath::relativePath_
private

Definition at line 124 of file FileInPath.h.

Referenced by initialize_(), read(), readFromParameterSetBlob(), relativePath(), swap(), and write().

std::string edm::FileInPath::releaseTop_
private

Definition at line 128 of file FileInPath.h.

Referenced by getEnvironment(), initialize_(), read(), readFromParameterSetBlob(), swap(), and write().

std::string edm::FileInPath::searchPath_
private

Definition at line 130 of file FileInPath.h.

Referenced by getEnvironment(), initialize_(), and swap().