Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FWCore/Integration/test/ProducerWithPSetDesc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion FWCore/ParameterSet/bin/edmWriteConfigs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion FWCore/ParameterSet/interface/Entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <vector>
#include <iosfwd>

#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
Expand Down
147 changes: 2 additions & 145 deletions FWCore/ParameterSet/interface/FileInPath.h
Original file line number Diff line number Diff line change
@@ -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 <iosfwd>
#include <string>

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"
2 changes: 1 addition & 1 deletion FWCore/ParameterSet/interface/ParameterSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion FWCore/ParameterSet/src/ParameterDescription.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion FWCore/ParameterSet/test/parameterSetDescription_t.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion FWCore/PyDevParameterSet/src/Python11ParameterSet.cc
Original file line number Diff line number Diff line change
@@ -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() {}
Expand Down
2 changes: 1 addition & 1 deletion FWCore/PythonParameterSet/src/Python11ParameterSet.cc
Original file line number Diff line number Diff line change
@@ -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() {}

Expand Down
142 changes: 142 additions & 0 deletions FWCore/Utilities/interface/FileInPath.h
Original file line number Diff line number Diff line change
@@ -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 <iosfwd>
#include <string>

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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <cassert>
#include <filesystem>

#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"
Expand Down