00001 // Torc - Copyright 2011 University of Southern California. All Rights Reserved. 00002 // $HeadURL: https://torc-isi.svn.sourceforge.net/svnroot/torc-isi/branches/staging/0.9/src/torc/common/DirectoryTree.hpp $ 00003 // $Id: DirectoryTree.hpp 10 2011-10-12 18:40:16Z nsteiner $ 00004 00005 // This program is free software: you can redistribute it and/or modify it under the terms of the 00006 // GNU General Public License as published by the Free Software Foundation, either version 3 of the 00007 // License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 00010 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 00011 // the GNU General Public License for more details. 00012 // 00013 // You should have received a copy of the GNU General Public License along with this program. If 00014 // not, see <http://www.gnu.org/licenses/>. 00015 00016 /// \file 00017 /// \brief Header for the DirectoryTree class. 00018 00019 #ifndef TORC_COMMON_DIRECTORYTREE_HPP 00020 #define TORC_COMMON_DIRECTORYTREE_HPP 00021 00022 #include <boost/filesystem/convenience.hpp> 00023 00024 namespace torc { 00025 namespace common { 00026 00027 /// \brief Encapsulation of filesystem paths that are used by the library. 00028 class DirectoryTree { 00029 protected: 00030 // static variables 00031 /// \brief Relative path from the working directory to the executable home. 00032 static boost::filesystem::path sRelativePath; 00033 /// \brief Absolute path to the working directory. 00034 static boost::filesystem::path sWorkingPath; 00035 /// \brief Absolute path to the executable directory. 00036 static boost::filesystem::path sExecutablePath; 00037 /// \brief Absolute path to the EDA libraries directory. 00038 static boost::filesystem::path sEdaPath; 00039 /// \brief Absolute path to the family and device database directory. 00040 static boost::filesystem::path sDevicesPath; 00041 /// \brief Absolute path to the log files directory. 00042 static boost::filesystem::path sLogPath; 00043 public: 00044 // constructors 00045 /// \brief Mandatory constructor. 00046 /// \param argv0 The zero-th argument passed to main in argv[]. DirectoryTree needs this 00047 /// to derive the relative path from the working directory to the executable, until 00048 /// such a time as Boost provides a better approach. 00049 /// \details Extracts the zero-th argument, and builds the various static paths used by the 00050 /// executable. 00051 DirectoryTree(const char* argv0); 00052 // static functions 00053 /// \brief Returns the relative path from the working directory to the executable home. 00054 static const boost::filesystem::path& getRelativePath(void) { return sRelativePath; } 00055 /// \brief Returns the absolute path to the working directory. 00056 static const boost::filesystem::path& getWorkingPath(void) { return sWorkingPath; } 00057 /// \brief Returns the absolute path to the executable directory. 00058 static const boost::filesystem::path& getExecutablePath(void) { return sExecutablePath; } 00059 /// \brief Returns the absolute path to the family and device database directory. 00060 static const boost::filesystem::path& getDevicesPath(void) { return sDevicesPath; } 00061 /// \brief Returns the absolute path to the log files directory. 00062 static const boost::filesystem::path& getLogPath(void) { return sLogPath; } 00063 }; 00064 00065 } // namespace common 00066 } // namespace torc 00067 00068 #endif // TORC_COMMON_DIRECTORYTREE_HPP