diff --git a/FWCore/Integration/test/ProducerWithPSetDesc.cc b/FWCore/Integration/test/ProducerWithPSetDesc.cc index f9638e1cd6828..07e514e64bac0 100644 --- a/FWCore/Integration/test/ProducerWithPSetDesc.cc +++ b/FWCore/Integration/test/ProducerWithPSetDesc.cc @@ -14,7 +14,7 @@ #include "DataFormats/Provenance/interface/LuminosityBlockID.h" #include "DataFormats/Provenance/interface/EventID.h" #include "FWCore/Utilities/interface/InputTag.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/FileInPath.h" #include "FWCore/ParameterSet/interface/PluginDescription.h" #include "FWCore/ParameterSet/interface/ValidatedPluginMacros.h" #include "FWCore/ParameterSet/interface/ValidatedPluginFactoryMacros.h" diff --git a/FWCore/ParameterSet/bin/edmWriteConfigs.cpp b/FWCore/ParameterSet/bin/edmWriteConfigs.cpp index f472dc59f1457..051096ff07dbc 100644 --- a/FWCore/ParameterSet/bin/edmWriteConfigs.cpp +++ b/FWCore/ParameterSet/bin/edmWriteConfigs.cpp @@ -29,7 +29,7 @@ #include "FWCore/Utilities/interface/TimeOfDay.h" #include "FWCore/PluginManager/interface/PluginManager.h" #include "FWCore/PluginManager/interface/standard.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/FileInPath.h" #include "FWCore/ParameterSet/interface/ParameterSetDescriptionFillerPluginFactory.h" #include "FWCore/Utilities/interface/Algorithms.h" #include "FWCore/PluginManager/interface/PluginInfo.h" diff --git a/FWCore/ParameterSet/interface/Entry.h b/FWCore/ParameterSet/interface/Entry.h index 5e744375c6803..b24bb016c0a2f 100644 --- a/FWCore/ParameterSet/interface/Entry.h +++ b/FWCore/ParameterSet/interface/Entry.h @@ -14,7 +14,7 @@ #include #include -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/FileInPath.h" #include "FWCore/Utilities/interface/InputTag.h" #include "FWCore/Utilities/interface/ESInputTag.h" //@@ not needed, but there might be trouble if we take it out diff --git a/FWCore/ParameterSet/interface/FileInPath.h b/FWCore/ParameterSet/interface/FileInPath.h index 68225fba6497e..1646f9d35d2d4 100644 --- a/FWCore/ParameterSet/interface/FileInPath.h +++ b/FWCore/ParameterSet/interface/FileInPath.h @@ -1,145 +1,2 @@ -#ifndef FWCore_ParameterSet_FileInPath_h -#define FWCore_ParameterSet_FileInPath_h - -/// - -/// Find a non-event-data file, given a relative path. - -/// FileInPath knows how to take a string, interpreted as a relative -/// path to a file, and to interpret using the "standard CMS -/// non-event-data file searching mechanism". -/// -/// The mechanism using the environment variables: -/// CMSSW_SEARCH_PATH: may be set by the end-user -/// CMSSW_RELEASE_BASE: should be set by a site administrator -/// CMSSW_DATA_PATH: should be set by a site administrator -/// -/// CMSSW_SEARCH_PATH is a 'search path' limited to 1 to 3 -/// components. The legal values are: -/// -/// -/// "." or "LOCAL", which means to search for files under -/// the top level of the "local working area", which is -/// defined as ${SCRAMRT_LOCALRT}/src -/// -/// "CMSSW_RELEASE_BASE", which means search the "official place", -/// defined by the value of the CMSSW_RELEASE_BASE environment -/// variable, for files. -/// -/// "CMSSW_DATA_PATH", which means search the "official place", -/// defined by the value of the CMSSW_DATA_PATH environment -/// variable, for files. -/// -/// ".:CMSSW_RELEASE_BASE" or "LOCAL:CMSSW_RELEASE_BASE", -/// which means look first in the current working -/// directory, then in the "official place", for files. -/// -/// ".:CMSSW_DATA_PATH" or "LOCAL:CMSSW_DATA_PATH", -/// which means look first in the current working -/// directory, then in the "official place", for files. -/// -/// ".:CMSSW_RELEASE_BASE:CMSSW_DATA_PATH" or "LOCAL:CMSSW_RELEASE_BASE:CMSSW_DATA_PATH", -/// which means look first in the current working -/// directory, then in both "official places", for files. -/// - -// Notes: -// -// 1. We do not deal well with paths that contain spaces; this is because -// of the way the ParameterSet system's 'encode' and 'decode' functions -// are implemented for FileInPath objects. This could be fixed, if it -// is important to handle filenames or paths with embedded spaces. -// -// 2. All environment variables are read only once, when the FileInPath object is constructed. -// Therefore, any changes made to these variables externally during the lifetime of -// a FileInPath object will have no effect. - -// TODO: Find the correct package for this class to reside. It -// doesn't seem well-suited for ParameterSet. - -#include -#include - -namespace edm { - class FileInPath { - public: - enum LocationCode { Unknown = 0, Local = 1, Release = 2, Data = 3 }; - - /// Default c'tor does no file-existence check; what file would it - /// check for existence? - FileInPath(); - - /// We throw an exception is the referenced file is not found. - explicit FileInPath(const std::string& r); - explicit FileInPath(const char* r); - - FileInPath(FileInPath const& other); - FileInPath& operator=(FileInPath const& other); - ~FileInPath(); - void swap(FileInPath& other); - - /// 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. - std::string relativePath() const; - - /// Where was the file found? - LocationCode location() 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. - std::string fullPath() const; - - /// Write contents to the given ostream. - /// Writing errors are reflected in the state of the stream. - void write(std::ostream& os) const; - - /// Read from the given istream, and set contents accordingly. - /// Reading errors are reflected in the state of the stream. - void read(std::istream& is); - - void readFromParameterSetBlob(std::istream& is); - - /// Should only be called while the edmWriteConfigs executable runs - static void disableFileLookup(); - - private: - std::string relativePath_; - std::string canonicalFilename_; - LocationCode location_; - std::string localTop_; - std::string releaseTop_; - std::string dataTop_; - std::string searchPath_; - - // Helper function for construction. - void getEnvironment(); - void initialize_(); - }; - - // Free swap function - inline void swap(FileInPath& a, FileInPath& b) { a.swap(b); } - - inline std::ostream& operator<<(std::ostream& os, const edm::FileInPath& fip) { - fip.write(os); - return os; - } - - inline std::istream& operator>>(std::istream& is, FileInPath& fip) { - fip.read(is); - return is; - } - - inline bool operator==(edm::FileInPath const& a, edm::FileInPath const& b) { - return a.location() == b.location() && a.relativePath() == b.relativePath(); - } - -} // namespace edm - -#endif +//Forward to new location +#include "FWCore/Utilities/interface/FileInPath.h" \ No newline at end of file diff --git a/FWCore/ParameterSet/interface/ParameterSet.h b/FWCore/ParameterSet/interface/ParameterSet.h index 53c2a358fae65..1ff9369c7f7b6 100644 --- a/FWCore/ParameterSet/interface/ParameterSet.h +++ b/FWCore/ParameterSet/interface/ParameterSet.h @@ -13,7 +13,7 @@ #include "DataFormats/Provenance/interface/ParameterSetID.h" #include "FWCore/ParameterSet/interface/Entry.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/FileInPath.h" #include "FWCore/ParameterSet/interface/ParameterSetEntry.h" #include "FWCore/ParameterSet/interface/VParameterSetEntry.h" diff --git a/FWCore/ParameterSet/src/ParameterDescription.cc b/FWCore/ParameterSet/src/ParameterDescription.cc index efdca7d9aa044..6dd18c869baf7 100644 --- a/FWCore/ParameterSet/src/ParameterDescription.cc +++ b/FWCore/ParameterSet/src/ParameterDescription.cc @@ -6,7 +6,7 @@ #include "DataFormats/Provenance/interface/LuminosityBlockID.h" #include "DataFormats/Provenance/interface/LuminosityBlockRange.h" #include "FWCore/ParameterSet/interface/DocFormatHelper.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/FileInPath.h" #include "FWCore/ParameterSet/src/FillDescriptionFromPSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/ParameterSet/interface/VParameterSetEntry.h" diff --git a/FWCore/ParameterSet/test/parameterSetDescription_t.cc b/FWCore/ParameterSet/test/parameterSetDescription_t.cc index 408e8e9cdaa84..28acd120992ab 100644 --- a/FWCore/ParameterSet/test/parameterSetDescription_t.cc +++ b/FWCore/ParameterSet/test/parameterSetDescription_t.cc @@ -6,7 +6,7 @@ #include "DataFormats/Provenance/interface/LuminosityBlockID.h" #include "FWCore/ParameterSet/interface/AllowedLabelsDescription.h" #include "FWCore/ParameterSet/interface/IfExistsDescription.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/FileInPath.h" #include "FWCore/ParameterSet/interface/ParameterDescriptionBase.h" #include "FWCore/ParameterSet/interface/ParameterDescriptionNode.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" diff --git a/FWCore/PyDevParameterSet/src/Python11ParameterSet.cc b/FWCore/PyDevParameterSet/src/Python11ParameterSet.cc index 079d459808aa5..61933c056b443 100644 --- a/FWCore/PyDevParameterSet/src/Python11ParameterSet.cc +++ b/FWCore/PyDevParameterSet/src/Python11ParameterSet.cc @@ -1,5 +1,5 @@ #include "FWCore/PyDevParameterSet/interface/Python11ParameterSet.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/FileInPath.h" namespace cmspython3 { Python11ParameterSet::Python11ParameterSet() : theParameterSet() {} diff --git a/FWCore/PythonParameterSet/src/Python11ParameterSet.cc b/FWCore/PythonParameterSet/src/Python11ParameterSet.cc index 2e60d9bf6c6fd..7ce8fadb4893f 100644 --- a/FWCore/PythonParameterSet/src/Python11ParameterSet.cc +++ b/FWCore/PythonParameterSet/src/Python11ParameterSet.cc @@ -1,5 +1,5 @@ #include "FWCore/PythonParameterSet/interface/Python11ParameterSet.h" -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/FileInPath.h" Python11ParameterSet::Python11ParameterSet() : theParameterSet() {} diff --git a/FWCore/Utilities/interface/FileInPath.h b/FWCore/Utilities/interface/FileInPath.h new file mode 100644 index 0000000000000..07b3d7bcb773a --- /dev/null +++ b/FWCore/Utilities/interface/FileInPath.h @@ -0,0 +1,142 @@ +#ifndef FWCore_Utilities_FileInPath_h +#define FWCore_Utilities_FileInPath_h + +/// + +/// Find a non-event-data file, given a relative path. + +/// FileInPath knows how to take a string, interpreted as a relative +/// path to a file, and to interpret using the "standard CMS +/// non-event-data file searching mechanism". +/// +/// The mechanism using the environment variables: +/// CMSSW_SEARCH_PATH: may be set by the end-user +/// CMSSW_RELEASE_BASE: should be set by a site administrator +/// CMSSW_DATA_PATH: should be set by a site administrator +/// +/// CMSSW_SEARCH_PATH is a 'search path' limited to 1 to 3 +/// components. The legal values are: +/// +/// +/// "." or "LOCAL", which means to search for files under +/// the top level of the "local working area", which is +/// defined as ${SCRAMRT_LOCALRT}/src +/// +/// "CMSSW_RELEASE_BASE", which means search the "official place", +/// defined by the value of the CMSSW_RELEASE_BASE environment +/// variable, for files. +/// +/// "CMSSW_DATA_PATH", which means search the "official place", +/// defined by the value of the CMSSW_DATA_PATH environment +/// variable, for files. +/// +/// ".:CMSSW_RELEASE_BASE" or "LOCAL:CMSSW_RELEASE_BASE", +/// which means look first in the current working +/// directory, then in the "official place", for files. +/// +/// ".:CMSSW_DATA_PATH" or "LOCAL:CMSSW_DATA_PATH", +/// which means look first in the current working +/// directory, then in the "official place", for files. +/// +/// ".:CMSSW_RELEASE_BASE:CMSSW_DATA_PATH" or "LOCAL:CMSSW_RELEASE_BASE:CMSSW_DATA_PATH", +/// which means look first in the current working +/// directory, then in both "official places", for files. +/// + +// Notes: +// +// 1. We do not deal well with paths that contain spaces; this is because +// of the way the Utilities system's 'encode' and 'decode' functions +// are implemented for FileInPath objects. This could be fixed, if it +// is important to handle filenames or paths with embedded spaces. +// +// 2. All environment variables are read only once, when the FileInPath object is constructed. +// Therefore, any changes made to these variables externally during the lifetime of +// a FileInPath object will have no effect. + +#include +#include + +namespace edm { + class FileInPath { + public: + enum LocationCode { Unknown = 0, Local = 1, Release = 2, Data = 3 }; + + /// Default c'tor does no file-existence check; what file would it + /// check for existence? + FileInPath(); + + /// We throw an exception is the referenced file is not found. + explicit FileInPath(const std::string& r); + explicit FileInPath(const char* r); + + FileInPath(FileInPath const& other); + FileInPath& operator=(FileInPath const& other); + ~FileInPath(); + void swap(FileInPath& other); + + /// 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. + std::string relativePath() const; + + /// Where was the file found? + LocationCode location() 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. + std::string fullPath() const; + + /// Write contents to the given ostream. + /// Writing errors are reflected in the state of the stream. + void write(std::ostream& os) const; + + /// Read from the given istream, and set contents accordingly. + /// Reading errors are reflected in the state of the stream. + void read(std::istream& is); + + void readFromParameterSetBlob(std::istream& is); + + /// Should only be called while the edmWriteConfigs executable runs + static void disableFileLookup(); + + private: + std::string relativePath_; + std::string canonicalFilename_; + LocationCode location_; + std::string localTop_; + std::string releaseTop_; + std::string dataTop_; + std::string searchPath_; + + // Helper function for construction. + void getEnvironment(); + void initialize_(); + }; + + // Free swap function + inline void swap(FileInPath& a, FileInPath& b) { a.swap(b); } + + inline std::ostream& operator<<(std::ostream& os, const edm::FileInPath& fip) { + fip.write(os); + return os; + } + + inline std::istream& operator>>(std::istream& is, FileInPath& fip) { + fip.read(is); + return is; + } + + inline bool operator==(edm::FileInPath const& a, edm::FileInPath const& b) { + return a.location() == b.location() && a.relativePath() == b.relativePath(); + } + +} // namespace edm + +#endif diff --git a/FWCore/ParameterSet/src/FileInPath.cc b/FWCore/Utilities/src/FileInPath.cc similarity index 99% rename from FWCore/ParameterSet/src/FileInPath.cc rename to FWCore/Utilities/src/FileInPath.cc index 8ed69b450b955..1fcb41df29987 100644 --- a/FWCore/ParameterSet/src/FileInPath.cc +++ b/FWCore/Utilities/src/FileInPath.cc @@ -7,7 +7,7 @@ #include #include -#include "FWCore/ParameterSet/interface/FileInPath.h" +#include "FWCore/Utilities/interface/FileInPath.h" #include "FWCore/Utilities/interface/EDMException.h" #include "FWCore/Utilities/interface/Parse.h" #include "FWCore/Utilities/interface/resolveSymbolicLinks.h"