![]() |
|
|||
File indexing completed on 2025-02-21 10:00:29
0001 /***********************************************************************************\ 0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations * 0003 * * 0004 * This software is distributed under the terms of the Apache version 2 licence, * 0005 * copied verbatim in the file "LICENSE". * 0006 * * 0007 * In applying this licence, CERN does not waive the privileges and immunities * 0008 * granted to it by virtue of its status as an Intergovernmental Organization * 0009 * or submit itself to any jurisdiction. * 0010 \***********************************************************************************/ 0011 #ifndef JOBOPTIONS_DIRSEARCHPATH_H 0012 #define JOBOPTIONS_DIRSEARCHPATH_H 0013 /** @file DirSearchPath.h 0014 * @brief search for files in a list of directories 0015 * @author Paolo Calafiura <pcalafiura@lbl.gov> - ATLAS Collaboration 0016 */ 0017 #include "GaudiKernel/Kernel.h" /* GAUDI_API */ 0018 #include "boost/filesystem/exception.hpp" /*filesystem_error*/ 0019 #include "boost/filesystem/path.hpp" 0020 #include <functional> /* binary_function */ 0021 #include <list> 0022 #include <string> 0023 #include <vector> 0024 0025 /** @class DirSearchPath 0026 * @brief search for files in a list of directories 0027 * @author Paolo Calafiura <pcalafiura@lbl.gov> - ATLAS Collaboration 0028 */ 0029 class GAUDI_API DirSearchPath { 0030 public: 0031 typedef boost::filesystem::path path; 0032 0033 /// \name constructors 0034 //@{ 0035 DirSearchPath() { addCWD(); } 0036 /// \throws boost::filesystem::filesystem_error 0037 #ifdef _WIN32 0038 DirSearchPath( const std::string& stringifiedPath, const char* separator = ",;" ); 0039 #else 0040 DirSearchPath( const std::string& stringifiedPath, const char* separator = ",:" ); 0041 #endif 0042 //@} 0043 0044 /// \name modifiers 0045 //@{ 0046 // bool add(const std::string& dirName); ///< \throws filesystem_error 0047 bool add( const path& dir ); ///< \throws filesystem_error 0048 bool addCWD(); ///< add current work dir (*nix pwd) to path 0049 //@} 0050 0051 /// \name accessors 0052 //@{ 0053 /// returns a flag if fileName found in search path, and sets ref to 0054 /// fully qualified file name (in native form) 0055 bool find( const std::string& fileName, std::string& fullFileName ) const; 0056 /// returns a flag if file found in search path. Sets ref to completed path 0057 bool find( const path& file, path& fileFound ) const; 0058 /// returns lists of files found in search path. 0059 std::list<path> find_all( const path& file ) const; 0060 //@} 0061 0062 /// \name helpers 0063 //@{ 0064 static bool existsDir( const std::string& dirName ); ///< check dirName is valid 0065 static bool existsDir( const path& dir ); ///< check dir path is valid 0066 //@} 0067 0068 private: 0069 // 0070 /// @class eqPath compare paths name 0071 struct eqPath { 0072 eqPath( const path& ref ) : m_ref( ref ) {} 0073 bool operator()( const path& p ) const { return p.string() == m_ref.string(); } 0074 0075 private: 0076 path m_ref; 0077 }; 0078 // @class lessPath order paths by (system-independent) name 0079 // struct lessPath : public std::binary_function<const path&,const path&,bool> { 0080 // bool operator() (const path& lhs, const path& rhs) const { 0081 // return lhs.string() < rhs.string(); 0082 // } 0083 //}; 0084 /// 0085 0086 // typedef std::set<path, lessPath> PathSet; ///<a set ordered by path name 0087 // PathSet m_dirs; ///<the dir container 0088 // 0089 std::vector<path> m_dirs; ///< the dir container 0090 }; 0091 #endif // JOBOPTIONS_DIRSEARCHPATH_H
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |