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 64 of file FileInPath.h.

Member Enumeration Documentation

Enumerator
Unknown 
Local 
Release 
Data 

Definition at line 66 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 106 of file FileInPath.cc.

References getEnvironment().

107  if (s_fileLookupDisabled) {
108  return;
109  }
110  getEnvironment();
111  }
std::string canonicalFilename_
Definition: FileInPath.h:114
void getEnvironment()
Definition: FileInPath.cc:333
LocationCode location_
Definition: FileInPath.h:115
std::string relativePath_
Definition: FileInPath.h:113
edm::FileInPath::FileInPath ( const std::string &  r)
explicit

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

Definition at line 113 of file FileInPath.cc.

References getEnvironment(), and initialize_().

114  if (s_fileLookupDisabled) {
115  return;
116  }
117  getEnvironment();
118  initialize_();
119  }
std::string canonicalFilename_
Definition: FileInPath.h:114
void getEnvironment()
Definition: FileInPath.cc:333
LocationCode location_
Definition: FileInPath.h:115
void initialize_()
Definition: FileInPath.cc:364
std::string relativePath_
Definition: FileInPath.h:113
edm::FileInPath::FileInPath ( const char *  r)
explicit

Definition at line 121 of file FileInPath.cc.

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

122  if (s_fileLookupDisabled) {
123  return;
124  }
125  if (r == nullptr) {
126  throw edm::Exception(edm::errors::FileInPathError) << "Relative path must not be null\n";
127  }
128  getEnvironment();
129  initialize_();
130  }
std::string canonicalFilename_
Definition: FileInPath.h:114
void getEnvironment()
Definition: FileInPath.cc:333
LocationCode location_
Definition: FileInPath.h:115
void initialize_()
Definition: FileInPath.cc:364
std::string relativePath_
Definition: FileInPath.h:113
edm::FileInPath::FileInPath ( FileInPath const &  other)

Definition at line 132 of file FileInPath.cc.

133  : relativePath_(other.relativePath_),
134  canonicalFilename_(other.canonicalFilename_),
135  location_(other.location_),
136  localTop_(other.localTop_),
137  releaseTop_(other.releaseTop_),
138  dataTop_(other.dataTop_),
139  searchPath_(other.searchPath_) {}
std::string canonicalFilename_
Definition: FileInPath.h:114
std::string dataTop_
Definition: FileInPath.h:118
std::string searchPath_
Definition: FileInPath.h:119
std::string releaseTop_
Definition: FileInPath.h:117
LocationCode location_
Definition: FileInPath.h:115
std::string relativePath_
Definition: FileInPath.h:113
std::string localTop_
Definition: FileInPath.h:116
edm::FileInPath::~FileInPath ( )

Definition at line 141 of file FileInPath.cc.

141 {}

Member Function Documentation

void edm::FileInPath::disableFileLookup ( )
static

Should only be called while the edmWriteConfigs executable runs.

Definition at line 436 of file FileInPath.cc.

436 { s_fileLookupDisabled = true; }
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 163 of file FileInPath.cc.

References canonicalFilename_.

Referenced by MillePedeAlignmentAlgorithm::addPxbSurvey(), SiStripNoisesBuilder::analyze(), SiStripPedestalsBuilder::analyze(), SiStripThresholdBuilder::analyze(), SiStripApvGainBuilder::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(), HGCalValidator::bookHistograms(), BTagSFProducer::BTagSFProducer(), HcalTPGCoderULUT::buildCoder(), SiStripDetVOffBuilder::BuildDetVOffObj(), MagGeoBuilderFromDDD::buildInterpolator(), HGCalTriggerGeometryImp1::buildMaps(), CaloMiscalibTools::CaloMiscalibTools(), CaloMiscalibToolsMC::CaloMiscalibToolsMC(), CastorTextCalibrations::CastorTextCalibrations(), GBRForestWriter::categoryEntryType::categoryEntryType(), CTPPSPixelDAQMappingESSourceXML::CompleteFileName(), TotemDAQMappingESSourceXML::CompleteFileName(), createGBRForest(), CSCMonitorModule::CSCMonitorModule(), CSCTFPtLUT::CSCTFPtLUT(), DatabasePDG::DatabasePDG(), 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(), HGCalTriggerGeometryV9Imp2::fillMaps(), HGCalTriggerGeometryHexImp2::fillMaps(), HGCalTriggerGeometryHexLayerBasedImp1::fillMaps(), HGCalTriggerGeometryV9Imp1::fillMaps(), HGCalTriggerGeometryV9Imp1::fillNeighborMap(), HGCalTriggerGeometryHexImp2::fillNeighborMaps(), HGCalTriggerGeometryHexLayerBasedImp1::fillNeighborMaps(), SiStripGain::fillNewGain(), popcon::SiStripPopConHandlerUnitTest< T >::fillObject(), popcon::SiStripPopConHandlerUnitTestGain< T >::fillObject(), popcon::SiStripPopConHandlerUnitTestNoise< T >::fillObject(), SiStripPI::fillTotalComponents(), muonisolation::IsolatorByNominalEfficiency::findPath(), G4ProcessHelper::G4ProcessHelper(), GEMRecHitProducer::GEMRecHitProducer(), gen::BaseHadronizer::generateLHE(), GeometryConfiguration::GeometryConfiguration(), ESTrivialConditionRetriever::getChannelStatusFromConfiguration(), EcalTrivialConditionRetriever::getChannelStatusFromConfiguration(), EcalTrivialConditionRetriever::getMappingFromConfiguration(), SiStripBadStripFromASCIIFile::getNewObject(), SiStripGainFromAsciiFile::getNewObject(), SiStripBadFiberBuilder::getNewObject(), SiStripBadChannelBuilder::getNewObject(), SiStripNoisesFromDBMiscalibrator::getNewObject_withDefaults(), EcalMappingElectronicsHandler::getNewObjects(), EcalTrivialConditionRetriever::getTrgChannelStatusFromConfiguration(), ESTrivialConditionRetriever::getWeightsFromConfiguration(), EcalTrivialConditionRetriever::getWeightsFromConfiguration(), HcalHardcodeCalibrations::HcalHardcodeCalibrations(), HcalLaserEventFilter2012::HcalLaserEventFilter2012(), HcalTextCalibrations::HcalTextCalibrations(), l1t::HGC3DClusterTMVASelector::HGC3DClusterTMVASelector(), HGCalTriggerTowerGeometryHelper::HGCalTriggerTowerGeometryHelper(), HGCalValidator::HGCalValidator(), PDFWeightsHelper::Init(), gen::EvtGenInterface::init(), CandidateBoostedDoubleSecondaryVertexComputer::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(), DTCCablingMapProducer::LoadModulesToDTCCablingMapFromCSV(), PFMETAlgorithmMVA::loadMVAfromFile(), ClusterShapeHitFilter::loadStripLimits(), SiStripFedCablingFakeESSource::make(), jpt::Map::Map(), MaterialBudgetCategorizer::MaterialBudgetCategorizer(), MultiEventFilter::MultiEventFilter(), MuonErrorMatrix::MuonErrorMatrix(), PhysicsTools::MVAComputerESSourceBase::MVAComputerESSourceBase(), MVAJetPuId::MVAJetPuId(), PhysicsTools::MVATrainer::MVATrainer(), MVAVariableManager< reco::GsfElectron >::MVAVariableManager(), fastsim::NuclearInteraction::NuclearInteraction(), NuclearInteractionSimulator::NuclearInteractionSimulator(), gen::Herwig6Instance::openParticleSpecFile(), OverlapValidation::OverlapValidation(), 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(), LwtnnESProducer::produce(), HBHEDarkeningEP::produce(), HepPDTESSource::produce(), SiPixelFakeGainOfflineESSource::produce(), SiPixelFakeGainESSource::produce(), SiPixelFakeGainForHLTESSource::produce(), SiPixelFakeLorentzAngleESSource::produce(), CaloTPGTranscoderULUTs::produce(), MaskedRctInputDigiProducer::produce(), JetCorrectionESSource< Corrector >::produce(), gen::PtYDistributor::PtYDistributor(), SiPixelTemplate2D::pushfile(), SiPixelTemplate::pushfile(), gen::Py8InterfaceBase::Py8InterfaceBase(), PYBIND11_MODULE(), 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(), HcalTPGCoderULUT::setupDBRecord(), ShiftedJetProducerT< T, Textractor >::ShiftedJetProducerT(), ShiftedPFCandidateProducerForNoPileUpPFMEt::ShiftedPFCandidateProducerForNoPileUpPFMEt(), ShiftedPFCandidateProducerForPFNoPUMEt::ShiftedPFCandidateProducerForPFNoPUMEt(), SiLinearChargeDivider::SiLinearChargeDivider(), SiStripAnalyser::SiStripAnalyser(), SiStripBadModuleByHandBuilder::SiStripBadModuleByHandBuilder(), SiStripDetInfoFileReader::SiStripDetInfoFileReader(), SiStripDigitizerAlgorithm::SiStripDigitizerAlgorithm(), SiStripHitEffFromCalibTree::SiStripHitEffFromCalibTree(), SiStripQuality::SiStripQuality(), SiStripQualityHotStripIdentifier::SiStripQualityHotStripIdentifier(), SiStripQualityStatistics::SiStripQualityStatistics(), PhysicsTools::MVATrainerLooper::Trainer::Trainer(), TtSemiLepHitFitProducer< LeptonCollection >::TtSemiLepHitFitProducer(), FWRecoGeometryESProducer::writeTrackerParametersXML(), and ZSPJPTJetCorrector::ZSPJPTJetCorrector().

163 { return canonicalFilename_; }
std::string canonicalFilename_
Definition: FileInPath.h:114
void edm::FileInPath::getEnvironment ( void  )
private

Definition at line 333 of file FileInPath.cc.

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

Referenced by FileInPath().

333  {
334  static std::string const searchPath = removeSymLinksTokens(PathVariableName);
335  if (searchPath.empty()) {
336  throw edm::Exception(edm::errors::FileInPathError) << PathVariableName << " must be defined\n";
337  }
338  searchPath_ = searchPath;
339 
340  static std::string const releaseTop = removeSymLinksSrc(RELEASETOP);
341  releaseTop_ = releaseTop;
342 
343  static std::string const localTop = removeSymLinksSrc(LOCALTOP);
344  localTop_ = localTop;
345 
346  static std::string const dataTop = removeSymLinks(DATATOP);
347  dataTop_ = dataTop;
348 
349  if (releaseTop_.empty()) {
350  // RELEASETOP was not set. This means that the environment is set
351  // for the base release itself. So LOCALTOP actually contains the
352  // location of the base release.
354  localTop_.clear();
355  }
356  if (releaseTop_ == localTop_) {
357  // RELEASETOP is the same as LOCALTOP. This means that the environment is set
358  // for the base release itself. So LOCALTOP actually contains the
359  // location of the base release.
360  localTop_.clear();
361  }
362  }
std::string dataTop_
Definition: FileInPath.h:118
std::string searchPath_
Definition: FileInPath.h:119
std::string releaseTop_
Definition: FileInPath.h:117
std::string localTop_
Definition: FileInPath.h:116
void edm::FileInPath::initialize_ ( )
private

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

364  {
365  if (relativePath_.empty()) {
366  throw edm::Exception(edm::errors::FileInPathError) << "Relative path must not be empty\n";
367  }
368 
369  // Find the file, based on the value of path variable.
370  typedef std::vector<std::string> stringvec_t;
371  stringvec_t pathElements = tokenize(searchPath_, ":");
372  for (auto const& element : pathElements) {
373  // Set the boost::fs path to the current element of
374  // CMSSW_SEARCH_PATH:
375  bf::path pathPrefix(element);
376 
377  // Does the a file exist? locateFile throws is it finds
378  // something goofy.
379  if (locateFile(pathPrefix, relativePath_)) {
380  // Convert relative path to canonical form, and save it.
381  relativePath_ = bf::path(relativePath_).normalize().string();
382 
383  // Save the absolute path.
384  canonicalFilename_ = bf::absolute(relativePath_, pathPrefix).string();
385  if (canonicalFilename_.empty()) {
387  << "fullPath is empty"
388  << "\nrelativePath() is: " << relativePath_ << "\npath prefix is: " << pathPrefix.string() << '\n';
389  }
390 
391  // From the current path element, find the branch path (basically the path minus the
392  // last directory, e.g. /src or /share):
393  for (bf::path br = pathPrefix.branch_path(); !br.normalize().string().empty(); br = br.branch_path()) {
394  if (!localTop_.empty()) {
395  // Create a path object for our local path LOCALTOP:
396  bf::path local_(localTop_);
397  // If the branch path matches the local path, the file was found locally:
398  if (br == local_) {
399  location_ = Local;
400  return;
401  }
402  }
403 
404  if (!releaseTop_.empty()) {
405  // Create a path object for our release path RELEASETOP:
406  bf::path release_(releaseTop_);
407  // If the branch path matches the release path, the file was found in the release:
408  if (br == release_) {
409  location_ = Release;
410  return;
411  }
412  }
413 
414  if (!dataTop_.empty()) {
415  // Create a path object for our data path DATATOP:
416  bf::path data_(dataTop_);
417  // If the branch path matches the data path, the file was found in the data area:
418  if (br == data_) {
419  location_ = Data;
420  return;
421  }
422  }
423  }
424  }
425  }
426 
427  // If we got here, we ran out of path elements without finding
428  // what we're looking found.
430  << "edm::FileInPath unable to find file " << relativePath_ << " anywhere in the search path."
431  << "\nThe search path is defined by: " << PathVariableName << "\n${" << PathVariableName
432  << "} is: " << getenv(PathVariableName.c_str()) << "\nCurrent directory is: " << bf::initial_path().string()
433  << "\n";
434  }
std::string canonicalFilename_
Definition: FileInPath.h:114
std::string dataTop_
Definition: FileInPath.h:118
std::string searchPath_
Definition: FileInPath.h:119
std::string releaseTop_
Definition: FileInPath.h:117
LocationCode location_
Definition: FileInPath.h:115
std::string relativePath_
Definition: FileInPath.h:113
std::string localTop_
Definition: FileInPath.h:116
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 143 of file FileInPath.cc.

References swap(), and groupFilesInBlocks::temp.

143  {
145  this->swap(temp);
146  return *this;
147  }
void swap(FileInPath &other)
Definition: FileInPath.cc:149
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 204 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>>().

204  {
205  std::string vsn;
206  std::string relname;
207  std::string canFilename;
208 #if 1
209  // This #if needed for backward compatibility
210  // for files written before CMSSW_1_5_0_pre3.
211  is >> vsn;
212  if (!is)
213  return;
214  bool oldFormat = (version != vsn);
215  if (oldFormat) {
216  relname = vsn;
217  bool local;
218  is >> local;
219  location_ = (local ? Local : Release);
220  is >> canFilename;
221  } else {
222  // Current format
223  int loc;
224  is >> relname >> loc;
225  location_ = static_cast<FileInPath::LocationCode>(loc);
226  if (location_ != Unknown)
227  is >> canFilename;
228  }
229 #else
230  is >> vsn >> relname >> loc >> canFilename;
231 #endif
232  if (!is)
233  return;
234  relativePath_ = relname;
235  if (location_ == Local) {
236  if (localTop_.empty()) {
237  throw edm::Exception(edm::errors::FileInPathError) << "Environment Variable " << LOCALTOP << " is not set.\n"
238  << "Trying to read Local file: " << canFilename << ".\n";
239  }
240 #if 1
241  // This #if needed for backward compatibility
242  // for files written before CMSSW_1_5_0_pre3.
243  if (oldFormat) {
244  canonicalFilename_ = canFilename;
245  } else
246 #endif
247  canonicalFilename_ = localTop_ + canFilename;
248  } else if (location_ == Release) {
249  if (releaseTop_.empty()) {
250  throw edm::Exception(edm::errors::FileInPathError) << "Environment Variable " << RELEASETOP << " is not set.\n";
251  }
252 #if 1
253  // This #if needed for backward compatibility
254  // for files written before CMSSW_1_5_0_pre3.
255  if (oldFormat) {
256  std::string::size_type pos = canFilename.find(BASE);
257  if (pos == 0) {
258  // Replace the placehoder with the path to the base release (site dependent).
259  canonicalFilename_ = releaseTop_ + canFilename.substr(BASE.size());
260  } else {
261  // Needed for files written before CMSSW_1_2_0_pre2.
262  canonicalFilename_ = canFilename;
263  }
264  } else
265 #endif
266  canonicalFilename_ = releaseTop_ + canFilename;
267  } else if (location_ == Data) {
268  if (dataTop_.empty()) {
269  throw edm::Exception(edm::errors::FileInPathError) << "Environment Variable " << DATATOP << " is not set.\n";
270  }
271  canonicalFilename_ = dataTop_ + canFilename;
272  }
273  }
std::string canonicalFilename_
Definition: FileInPath.h:114
std::string dataTop_
Definition: FileInPath.h:118
uint16_t size_type
std::string releaseTop_
Definition: FileInPath.h:117
LocationCode location_
Definition: FileInPath.h:115
std::string relativePath_
Definition: FileInPath.h:113
std::string localTop_
Definition: FileInPath.h:116
void edm::FileInPath::readFromParameterSetBlob ( std::istream &  is)

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

275  {
276  std::string vsn;
277  std::string relname;
278  std::string canFilename;
279  is >> vsn;
280  if (!is)
281  return;
282  bool oldFormat = (version != vsn);
283  if (oldFormat) {
284  relname = vsn;
285  bool local;
286  is >> local;
287  location_ = (local ? Local : Release);
288  is >> canFilename;
289  } else {
290  // Current format
291  int loc;
292  is >> relname >> loc;
293  location_ = static_cast<FileInPath::LocationCode>(loc);
294  if (location_ != Unknown)
295  is >> canFilename;
296  }
297  if (!is)
298  return;
299  relativePath_ = relname;
300  if (location_ == Local) {
301  if (localTop_.empty()) {
302  localTop_ = "@LOCAL";
303  }
304  if (oldFormat) {
305  canonicalFilename_ = canFilename;
306  } else
307  canonicalFilename_ = localTop_ + canFilename;
308  } else if (location_ == Release) {
309  if (releaseTop_.empty()) {
310  releaseTop_ = "@RELEASE";
311  }
312  if (oldFormat) {
313  std::string::size_type pos = canFilename.find(BASE);
314  if (pos == 0) {
315  // Replace the placehoder with the path to the base release (site dependent).
316  canonicalFilename_ = releaseTop_ + canFilename.substr(BASE.size());
317  } else {
318  // Needed for files written before CMSSW_1_2_0_pre2.
319  canonicalFilename_ = canFilename;
320  }
321  } else
322  canonicalFilename_ = releaseTop_ + canFilename;
323  } else if (location_ == Data) {
324  if (dataTop_.empty()) {
325  throw edm::Exception(edm::errors::FileInPathError) << "Environment Variable " << DATATOP << " is not set.\n";
326  }
327  canonicalFilename_ = dataTop_ + canFilename;
328  }
329  }
std::string canonicalFilename_
Definition: FileInPath.h:114
std::string dataTop_
Definition: FileInPath.h:118
uint16_t size_type
std::string releaseTop_
Definition: FileInPath.h:117
LocationCode location_
Definition: FileInPath.h:115
std::string relativePath_
Definition: FileInPath.h:113
std::string localTop_
Definition: FileInPath.h:116
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 159 of file FileInPath.cc.

References relativePath_.

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

159 { return relativePath_; }
std::string relativePath_
Definition: FileInPath.h:113
void edm::FileInPath::swap ( FileInPath other)

Definition at line 149 of file FileInPath.cc.

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

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

149  {
150  relativePath_.swap(other.relativePath_);
151  canonicalFilename_.swap(other.canonicalFilename_);
152  std::swap(location_, other.location_);
153  localTop_.swap(other.localTop_);
154  releaseTop_.swap(other.releaseTop_);
155  dataTop_.swap(other.dataTop_);
156  searchPath_.swap(other.searchPath_);
157  }
std::string canonicalFilename_
Definition: FileInPath.h:114
std::string dataTop_
Definition: FileInPath.h:118
std::string searchPath_
Definition: FileInPath.h:119
std::string releaseTop_
Definition: FileInPath.h:117
LocationCode location_
Definition: FileInPath.h:115
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
std::string relativePath_
Definition: FileInPath.h:113
std::string localTop_
Definition: FileInPath.h:116
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 165 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<<().

165  {
166  if (location_ == Unknown) {
167  os << version << ' ' << relativePath_ << ' ' << location_;
168  } else if (location_ == Local) {
169  // Guarantee a site independent value by stripping $LOCALTOP.
170  if (localTop_.empty()) {
171  throw edm::Exception(edm::errors::FileInPathError) << "Environment Variable " << LOCALTOP << " is not set.\n";
172  }
174  if (pos != 0) {
176  << "Path " << canonicalFilename_ << " is not in the local release area " << localTop_ << "\n";
177  }
178  os << version << ' ' << relativePath_ << ' ' << location_ << ' ' << canonicalFilename_.substr(localTop_.size());
179  } else if (location_ == Release) {
180  // Guarantee a site independent value by stripping $RELEASETOP.
181  if (releaseTop_.empty()) {
182  throw edm::Exception(edm::errors::FileInPathError) << "Environment Variable " << RELEASETOP << " is not set.\n";
183  }
185  if (pos != 0) {
187  << "Path " << canonicalFilename_ << " is not in the base release area " << releaseTop_ << "\n";
188  }
189  os << version << ' ' << relativePath_ << ' ' << location_ << ' ' << canonicalFilename_.substr(releaseTop_.size());
190  } else if (location_ == Data) {
191  // Guarantee a site independent value by stripping $DATATOP.
192  if (dataTop_.empty()) {
193  throw edm::Exception(edm::errors::FileInPathError) << "Environment Variable " << DATATOP << " is not set.\n";
194  }
196  if (pos != 0) {
198  << "Path " << canonicalFilename_ << " is not in the data area " << dataTop_ << "\n";
199  }
200  os << version << ' ' << relativePath_ << ' ' << location_ << ' ' << canonicalFilename_.substr(dataTop_.size());
201  }
202  }
std::string canonicalFilename_
Definition: FileInPath.h:114
std::string dataTop_
Definition: FileInPath.h:118
uint16_t size_type
std::string releaseTop_
Definition: FileInPath.h:117
LocationCode location_
Definition: FileInPath.h:115
std::string relativePath_
Definition: FileInPath.h:113
std::string localTop_
Definition: FileInPath.h:116

Member Data Documentation

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

Definition at line 114 of file FileInPath.h.

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

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

Definition at line 118 of file FileInPath.h.

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

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

Definition at line 116 of file FileInPath.h.

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

LocationCode edm::FileInPath::location_
private

Definition at line 115 of file FileInPath.h.

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

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

Definition at line 113 of file FileInPath.h.

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

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

Definition at line 117 of file FileInPath.h.

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

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

Definition at line 119 of file FileInPath.h.

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