CMS 3D CMS Logo

List of all members | Public Types | 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 ()
 

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

FileInPath::FileInPath ( )

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

Definition at line 109 of file FileInPath.cc.

References getEnvironment().

109  :
110  relativePath_(),
113  {
114  getEnvironment();
115  }
std::string canonicalFilename_
Definition: FileInPath.h:121
void getEnvironment()
Definition: FileInPath.cc:393
LocationCode location_
Definition: FileInPath.h:122
std::string relativePath_
Definition: FileInPath.h:120
FileInPath::FileInPath ( const std::string &  r)
explicit

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

Definition at line 117 of file FileInPath.cc.

References getEnvironment(), and initialize_().

117  :
118  relativePath_(r),
121  {
122  getEnvironment();
123  initialize_();
124  }
std::string canonicalFilename_
Definition: FileInPath.h:121
void getEnvironment()
Definition: FileInPath.cc:393
LocationCode location_
Definition: FileInPath.h:122
std::string relativePath_
Definition: FileInPath.h:120
void initialize_()
Definition: FileInPath.cc:427
FileInPath::FileInPath ( const char *  r)
explicit

Definition at line 126 of file FileInPath.cc.

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

126  :
127  relativePath_(r ? r : ""),
130  {
131  if(r == nullptr) {
132  throw edm::Exception(edm::errors::FileInPathError) << "Relative path must not be null\n";
133  }
134  getEnvironment();
135  initialize_();
136  }
std::string canonicalFilename_
Definition: FileInPath.h:121
void getEnvironment()
Definition: FileInPath.cc:393
LocationCode location_
Definition: FileInPath.h:122
std::string relativePath_
Definition: FileInPath.h:120
void initialize_()
Definition: FileInPath.cc:427
FileInPath::FileInPath ( FileInPath const &  other)

Definition at line 138 of file FileInPath.cc.

138  :
139  relativePath_(other.relativePath_),
140  canonicalFilename_(other.canonicalFilename_),
141  location_(other.location_),
142  localTop_(other.localTop_),
143  releaseTop_(other.releaseTop_),
144  dataTop_(other.dataTop_),
145  searchPath_(other.searchPath_)
146  {}
std::string canonicalFilename_
Definition: FileInPath.h:121
std::string dataTop_
Definition: FileInPath.h:125
std::string searchPath_
Definition: FileInPath.h:126
std::string releaseTop_
Definition: FileInPath.h:124
LocationCode location_
Definition: FileInPath.h:122
std::string relativePath_
Definition: FileInPath.h:120
std::string localTop_
Definition: FileInPath.h:123
FileInPath::~FileInPath ( )

Definition at line 148 of file FileInPath.cc.

148 {}

Member Function Documentation

std::string 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 184 of file FileInPath.cc.

References canonicalFilename_.

Referenced by MillePedeAlignmentAlgorithm::addPxbSurvey(), SiStripBadFiberBuilder::algoAnalyze(), SiStripBadChannelBuilder::algoAnalyze(), SiStripNoisesBuilder::analyze(), SiStripApvGainBuilder::analyze(), SiStripPedestalsBuilder::analyze(), SiStripThresholdBuilder::analyze(), SiStripNoiseNormalizedWithApvGainBuilder::analyze(), JetCorrectorDemo::analyze(), SiStripApvGainBuilderFromTag::analyze(), MuonGeometrySVGTemplate::analyze(), DetIdSelectorTest::analyze(), BeamSpotFakeConditions::BeamSpotFakeConditions(), AntiElectronIDMVA5::beginEvent(), AntiElectronIDMVA6::beginEvent(), JetCorrectorDBWriter::beginJob(), ProtonTaggerFilter::beginJob(), GoodSeedProducer::beginRun(), BOOST_PYTHON_MODULE(), HcalTPGCoderULUT::buildCoder(), SiStripDetVOffBuilder::BuildDetVOffObj(), MagGeoBuilderFromDDD::buildInterpolator(), MaterialBudgetCategorizer::buildMaps(), CaloMiscalibTools::CaloMiscalibTools(), CaloMiscalibToolsMC::CaloMiscalibToolsMC(), CastorTextCalibrations::CastorTextCalibrations(), GBRForestWriter::categoryEntryType::categoryEntryType(), CTPPSPixelDAQMappingESSourceXML::CompleteFileName(), TotemDAQMappingESSourceXML::CompleteFileName(), PhotonMVAEstimatorRun2Phys14NonTrig::createSingleReader(), PhotonMVAEstimatorRun2Spring15NonTrig::createSingleReader(), ElectronMVAEstimatorRun2Phys14NonTrig::createSingleReader(), ElectronMVAEstimatorRun2Spring15Trig::createSingleReader(), ElectronMVAEstimatorRun2Spring15NonTrig::createSingleReader(), ElectronMVAEstimatorRun2Spring16GeneralPurpose::createSingleReader(), ElectronMVAEstimatorRun2Spring16HZZ::createSingleReader(), CSCMonitorModule::CSCMonitorModule(), CSCTFPtLUT::CSCTFPtLUT(), CustomPhysicsListSS::CustomPhysicsListSS(), DatabasePDG::DatabasePDG(), HcalTPGCoderULUT::dbRecordCallback(), DeepFlavourJetTagsProducer::DeepFlavourJetTagsProducer(), dtCalibration::DTTTrigResidualCorrection::DTTTrigResidualCorrection(), EcalDQMonitorClient::EcalDQMonitorClient(), ElectronIdMVAProducer::ElectronIdMVAProducer(), ElectronPATIdMVAProducer::ElectronPATIdMVAProducer(), OccupancyPlots::endRun(), ESDataFormatterV4::ESDataFormatterV4(), ESElectronicsMapper::ESElectronicsMapper(), ESIntegrityClient::ESIntegrityClient(), ESPedestalClient::ESPedestalClient(), MultipleScatteringX0Data::fileName(), CSCReadoutMappingFromFile::fill(), HGCalTriggerGeometryHexImp1::fillMaps(), HGCalTriggerGeometryHexImp2::fillMaps(), HGCalTriggerGeometryHexImp2::fillNeighborMaps(), SiStripGain::fillNewGain(), popcon::SiStripPopConHandlerUnitTest< T >::fillObject(), popcon::SiStripPopConHandlerUnitTestGain< T >::fillObject(), popcon::SiStripPopConHandlerUnitTestNoise< T >::fillObject(), muonisolation::IsolatorByNominalEfficiency::findPath(), gen::BaseHadronizer::generateLHE(), GeometryConfiguration::GeometryConfiguration(), ESTrivialConditionRetriever::getChannelStatusFromConfiguration(), EcalTrivialConditionRetriever::getChannelStatusFromConfiguration(), getfullpathfromfip_(), EcalTrivialConditionRetriever::getMappingFromConfiguration(), SiStripGainFromAsciiFile::getNewObject(), SiStripBadStripFromASCIIFile::getNewObject(), EcalMappingElectronicsHandler::getNewObjects(), EcalTrivialConditionRetriever::getTrgChannelStatusFromConfiguration(), ESTrivialConditionRetriever::getWeightsFromConfiguration(), EcalTrivialConditionRetriever::getWeightsFromConfiguration(), HcalHardcodeCalibrations::HcalHardcodeCalibrations(), HcalLaserEventFilter2012::HcalLaserEventFilter2012(), HcalTextCalibrations::HcalTextCalibrations(), pfEGHelpers::HeavyObjectCache::HeavyObjectCache(), PDFWeightsHelper::Init(), gen::EvtGenInterface::init(), CandidateBoostedDoubleSecondaryVertexComputer::initialize(), HGCalTriggerGeometryImp1::initialize(), CombinedMVAV2JetTagComputer::initialize(), MuonTagger::initialize(), CandidateChargeBTagComputer::initialize(), ElectronTagger::initialize(), CharmTagger::initialize(), ApeSettingAlgorithm::initialize(), PileupJetIdProducer::initJetEnergyCorrector(), JetCalibrationParameterSetTauJet::JetCalibrationParameterSetTauJet(), JetPartonNamespace::JetPartonCalibrationParameterSet::JetPartonCalibrationParameterSet(), L1GtTriggerMenuXmlProducer::L1GtTriggerMenuXmlProducer(), L1TCaloParamsESProducer::L1TCaloParamsESProducer(), L1TCaloStage2ParamsESProducer::L1TCaloStage2ParamsESProducer(), L1TGlobalPrescalesVetosESProducer::L1TGlobalPrescalesVetosESProducer(), l1t::L1TGlobalUtil::L1TGlobalUtil(), L1TMuonBarrelParamsESProducer::L1TMuonBarrelParamsESProducer(), L1TMuonGlobalParamsESProducer::L1TMuonGlobalParamsESProducer(), L1TMuonOverlapParamsESProducer::L1TMuonOverlapParamsESProducer(), CovarianceParameterization::load(), L1MuDTPhiLut::load(), L1MuDTPtaLut::load(), L1MuDTEtaPatternLut::load(), L1MuDTQualPatternLut::load(), L1MuDTExtLut::load(), L1TMuonBarrelParamsHelper::load_ext(), EcalDeadChannelRecoveryNN< DetIdT >::load_file(), L1TMuonBarrelParamsHelper::load_phi(), L1TMuonBarrelParamsHelper::load_pt(), PFMETAlgorithmMVA::loadMVAfromFile(), ClusterShapeHitFilter::loadStripLimits(), SiStripFedCablingFakeESSource::make(), SiStripHashedDetIdFakeESSource::make(), jpt::Map::Map(), MultiEventFilter::MultiEventFilter(), MuonErrorMatrix::MuonErrorMatrix(), PhysicsTools::MVAComputerESSourceBase::MVAComputerESSourceBase(), MVAJetPuId::MVAJetPuId(), PhysicsTools::MVATrainer::MVATrainer(), NuclearInteractionSimulator::NuclearInteractionSimulator(), gen::Herwig6Instance::openParticleSpecFile(), l1t::L1TGlobalUtil::OverridePrescalesAndMasks(), HcalTBObjectUnpacker::parseCalib(), cond::persistency::parseFipConnectionString(), DDLParser::parseOneFile(), EcalTrigPrimESProducer::parseTextFile(), EcalTrigTowerConstituentsMapBuilder::parseTextMap(), CaloTowerConstituentsMapBuilder::parseTextMap(), PileupJetIdAlgo::PileupJetIdAlgo(), cms::PileupJPTJetIdAlgo::PileupJPTJetIdAlgo(), PixelBarrelTemplateSmearerPlugin::PixelBarrelTemplateSmearerPlugin(), PixelForwardTemplateSmearerPlugin::PixelForwardTemplateSmearerPlugin(), SiPixelFakeCPEGenericErrorParmESSource::produce(), SiPixelFakeTemplateDBObjectESSource::produce(), SiPixelFakeGenErrorDBObjectESSource::produce(), HBHEDarkeningEP::produce(), SiStripLatencyFakeESSource::produce(), SiStripApvGainFakeESSource::produce(), SiStripBaseDelayFakeESSource::produce(), SiStripThresholdFakeESSource::produce(), SiStripBackPlaneCorrectioNFakeESSource::produce(), SiStripPedestalsFakeESSource::produce(), SiStripBadModuleConfigurableFakeESSource::produce(), SiStripNoisesFakeESSource::produce(), HepPDTESSource::produce(), SiStripLorentzAngleFakeESSource::produce(), SiPixelFakeGainESSource::produce(), SiPixelFakeGainForHLTESSource::produce(), SiPixelFakeGainOfflineESSource::produce(), SiPixelFakeLorentzAngleESSource::produce(), CaloTPGTranscoderULUTs::produce(), MaskedRctInputDigiProducer::produce(), JetCorrectionESSource< Corrector >::produce(), gen::PtYDistributor::PtYDistributor(), SiStripFEDErrorsDQM::readBadAPVs(), SiStripBadComponentsDQMService::readBadComponents(), FIPConfiguration::readConfig(), CSCTFPtLUT::readLUT(), CSCSectorReceiverLUT::readLUTsFromFile(), SiStripNoisesDQMService::readNoises(), GsfBetheHeitlerUpdator::readParameters(), SiStripPedestalsDQMService::readPedestals(), 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(), and ZSPJPTJetCorrector::ZSPJPTJetCorrector().

185  {
186  return canonicalFilename_;
187  }
std::string canonicalFilename_
Definition: FileInPath.h:121
void FileInPath::getEnvironment ( void  )
private

Definition at line 393 of file FileInPath.cc.

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

Referenced by FileInPath().

393  {
394  static std::string const searchPath = removeSymLinksTokens(PathVariableName.c_str());
395  if (searchPath.empty()) {
397  << PathVariableName
398  << " must be defined\n";
399  }
400  searchPath_ = searchPath;
401 
402  static std::string const releaseTop = removeSymLinksSrc(RELEASETOP.c_str());
403  releaseTop_ = releaseTop;
404 
405  static std::string const localTop = removeSymLinksSrc(LOCALTOP.c_str());
406  localTop_ = localTop;
407 
408  static std::string const dataTop = removeSymLinks(DATATOP.c_str());
409  dataTop_ = dataTop;
410 
411  if (releaseTop_.empty()) {
412  // RELEASETOP was not set. This means that the environment is set
413  // for the base release itself. So LOCALTOP actually contains the
414  // location of the base release.
415  releaseTop_ = localTop_;
416  localTop_.clear();
417  }
418  if (releaseTop_ == localTop_) {
419  // RELEASETOP is the same as LOCALTOP. This means that the environment is set
420  // for the base release itself. So LOCALTOP actually contains the
421  // location of the base release.
422  localTop_.clear();
423  }
424  }
std::string dataTop_
Definition: FileInPath.h:125
std::string searchPath_
Definition: FileInPath.h:126
std::string releaseTop_
Definition: FileInPath.h:124
std::string localTop_
Definition: FileInPath.h:123
void FileInPath::initialize_ ( )
private

Definition at line 427 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().

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

Definition at line 151 of file FileInPath.cc.

References swap(), and groupFilesInBlocks::temp.

152  {
154  this->swap(temp);
155  return *this;
156  }
void swap(FileInPath &other)
Definition: FileInPath.cc:159
void 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 253 of file FileInPath.cc.

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

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

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

Definition at line 332 of file FileInPath.cc.

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

Referenced by edm::decode().

333  {
334  std::string vsn;
335  std::string relname;
336  std::string canFilename;
337  is >> vsn;
338  if (!is) return;
339  bool oldFormat = (version != vsn);
340  if (oldFormat) {
341  relname = vsn;
342  bool local;
343  is >> local;
344  location_ = (local ? Local : Release);
345  is >> canFilename;
346  } else {
347  // Current format
348  int loc;
349  is >> relname >> loc;
350  location_ = static_cast<FileInPath::LocationCode>(loc);
351  if (location_ != Unknown) is >> canFilename;
352  }
353  if (!is) return;
354  relativePath_ = relname;
355  if (location_ == Local) {
356  if (localTop_.empty()) {
357  localTop_ = "@LOCAL";
358  }
359  if (oldFormat) {
360  canonicalFilename_ = canFilename;
361  } else
362  canonicalFilename_ = localTop_ + canFilename;
363  } else if (location_ == Release) {
364  if (releaseTop_.empty()) {
365  releaseTop_="@RELEASE";
366  }
367  if (oldFormat) {
368  std::string::size_type pos = canFilename.find(BASE);
369  if (pos == 0) {
370  // Replace the placehoder with the path to the base release (site dependent).
371  canonicalFilename_ = releaseTop_ + canFilename.substr(BASE.size());
372  } else {
373  // Needed for files written before CMSSW_1_2_0_pre2.
374  canonicalFilename_ = canFilename;
375  }
376  } else
377  canonicalFilename_ = releaseTop_ + canFilename;
378  } else if (location_ == Data) {
379  if (dataTop_.empty()) {
381  << "Environment Variable "
382  << DATATOP
383  << " is not set.\n";
384  }
385  canonicalFilename_ = dataTop_ + canFilename;
386  }
387  }
std::string canonicalFilename_
Definition: FileInPath.h:121
std::string dataTop_
Definition: FileInPath.h:125
uint16_t size_type
std::string releaseTop_
Definition: FileInPath.h:124
LocationCode location_
Definition: FileInPath.h:122
std::string relativePath_
Definition: FileInPath.h:120
std::string localTop_
Definition: FileInPath.h:123
std::string 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 171 of file FileInPath.cc.

References relativePath_.

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

172  {
173  return relativePath_;
174  }
std::string relativePath_
Definition: FileInPath.h:120
void FileInPath::swap ( FileInPath other)

Definition at line 159 of file FileInPath.cc.

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

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

160  {
161  relativePath_.swap(other.relativePath_);
162  canonicalFilename_.swap(other.canonicalFilename_);
163  std::swap(location_, other.location_);
164  localTop_.swap(other.localTop_);
165  releaseTop_.swap(other.releaseTop_);
166  dataTop_.swap(other.dataTop_);
167  searchPath_.swap(other.searchPath_);
168  }
std::string canonicalFilename_
Definition: FileInPath.h:121
std::string dataTop_
Definition: FileInPath.h:125
std::string searchPath_
Definition: FileInPath.h:126
std::string releaseTop_
Definition: FileInPath.h:124
LocationCode location_
Definition: FileInPath.h:122
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::string relativePath_
Definition: FileInPath.h:120
std::string localTop_
Definition: FileInPath.h:123
void 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 190 of file FileInPath.cc.

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

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

191  {
192  if (location_ == Unknown) {
193  os << version << ' ' << relativePath_ << ' ' << location_;
194  } else if (location_ == Local) {
195  // Guarantee a site independent value by stripping $LOCALTOP.
196  if (localTop_.empty()) {
198  << "Environment Variable "
199  << LOCALTOP
200  << " is not set.\n";
201  }
203  if (pos != 0) {
205  << "Path "
207  << " is not in the local release area "
208  << localTop_
209  << "\n";
210  }
211  os << version << ' ' << relativePath_ << ' ' << location_ << ' ' << canonicalFilename_.substr(localTop_.size());
212  } else if (location_ == Release) {
213  // Guarantee a site independent value by stripping $RELEASETOP.
214  if (releaseTop_.empty()) {
216  << "Environment Variable "
217  << RELEASETOP
218  << " is not set.\n";
219  }
221  if (pos != 0) {
223  << "Path "
225  << " is not in the base release area "
226  << releaseTop_
227  << "\n";
228  }
229  os << version << ' ' << relativePath_ << ' ' << location_ << ' ' << canonicalFilename_.substr(releaseTop_.size());
230  } else if (location_ == Data) {
231  // Guarantee a site independent value by stripping $DATATOP.
232  if (dataTop_.empty()) {
234  << "Environment Variable "
235  << DATATOP
236  << " is not set.\n";
237  }
239  if (pos != 0) {
241  << "Path "
243  << " is not in the data area "
244  << dataTop_
245  << "\n";
246  }
247  os << version << ' ' << relativePath_ << ' ' << location_ << ' ' << canonicalFilename_.substr(dataTop_.size());
248  }
249  }
std::string canonicalFilename_
Definition: FileInPath.h:121
std::string dataTop_
Definition: FileInPath.h:125
uint16_t size_type
std::string releaseTop_
Definition: FileInPath.h:124
LocationCode location_
Definition: FileInPath.h:122
std::string relativePath_
Definition: FileInPath.h:120
std::string localTop_
Definition: FileInPath.h:123

Member Data Documentation

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

Definition at line 121 of file FileInPath.h.

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

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

Definition at line 125 of file FileInPath.h.

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

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

Definition at line 123 of file FileInPath.h.

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

LocationCode edm::FileInPath::location_
private

Definition at line 122 of file FileInPath.h.

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

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

Definition at line 120 of file FileInPath.h.

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

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

Definition at line 124 of file FileInPath.h.

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

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

Definition at line 126 of file FileInPath.h.

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