torc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
torc::common::DirectoryTree Class Reference

Encapsulation of filesystem paths that are used by the library. More...

#include <DirectoryTree.hpp>

Public Member Functions

 DirectoryTree (const char *argv0)
 Mandatory constructor. More...
 

Static Public Member Functions

static const
boost::filesystem::path & 
getRelativePath (void)
 Returns the relative path from the working directory to the executable home. More...
 
static const
boost::filesystem::path & 
getWorkingPath (void)
 Returns the absolute path to the working directory. More...
 
static const
boost::filesystem::path & 
getExecutablePath (void)
 Returns the absolute path to the executable directory. More...
 
static const
boost::filesystem::path & 
getDevicesPath (void)
 Returns the absolute path to the family and device database directory. More...
 
static const
boost::filesystem::path & 
getLogPath (void)
 Returns the absolute path to the log files directory. More...
 

Static Protected Attributes

static boost::filesystem::path sRelativePath
 Relative path from the working directory to the executable home. More...
 
static boost::filesystem::path sWorkingPath
 Absolute path to the working directory. More...
 
static boost::filesystem::path sExecutablePath
 Absolute path to the executable directory. More...
 
static boost::filesystem::path sEdaPath
 Absolute path to the EDA libraries directory. More...
 
static boost::filesystem::path sDevicesPath
 Absolute path to the family and device database directory. More...
 
static boost::filesystem::path sLogPath
 Absolute path to the log files directory. More...
 

Detailed Description

Encapsulation of filesystem paths that are used by the library.

Definition at line 28 of file DirectoryTree.hpp.

Constructor & Destructor Documentation

torc::common::DirectoryTree::DirectoryTree ( const char *  argv0)

Mandatory constructor.

Parameters
argv0The zero-th argument passed to main in argv[]. DirectoryTree needs this to derive the relative path from the working directory to the executable, until such a time as Boost provides a better approach.

Extracts the zero-th argument, and builds the various static paths used by the executable.

Definition at line 40 of file DirectoryTree.cpp.

40  {
41  // resolve symbolic links for the executable if necessary
42  boost::filesystem::path argvPath(argv0);
43  char buffer[FILENAME_MAX];
44  ssize_t count = readlink(argv0, buffer, sizeof(buffer));
45  if(count != -1) {
46  buffer[count] = 0;
47  argvPath = buffer;
48  //std::cout << "Resolving symbolic link " << argv[0] << " to executable name " << path
49  // << std::endl;
50  }
51  //std::cout << ">>>> argvPath: " << argvPath << std::endl;
52  // get the working directory and the relative executable path
53  sWorkingPath = boost::filesystem::initial_path();
54  //std::cout << ">>>> sWorkingPath: " << sWorkingPath << std::endl;
55  sRelativePath = argvPath.parent_path(); // so much for relative paths ...
56  //std::cout << ">>>> sRelativePath: " << sRelativePath << std::endl;
57  // get the executable path
59  // build the eda and log paths
61  // build the database path
63  if(!exists(sDevicesPath))
65 
66  // normalize each of the paths
67  sRelativePath.normalize();
68  sWorkingPath.normalize();
69  sExecutablePath.normalize();
70  sDevicesPath.normalize();
71  sLogPath.normalize();
72  }
static boost::filesystem::path sWorkingPath
Absolute path to the working directory.
boost::filesystem::path path
const std::string cTorcNameConst("torc")
Name of the torc directory.
static boost::filesystem::path sExecutablePath
Absolute path to the executable directory.
static boost::filesystem::path sLogPath
Absolute path to the log files directory.
static boost::filesystem::path sRelativePath
Relative path from the working directory to the executable home.
const std::string cDevicesNameConst("devices")
Name of the devices directory.
static boost::filesystem::path sDevicesPath
Absolute path to the family and device database directory.

+ Here is the call graph for this function:

Member Function Documentation

static const boost::filesystem::path& torc::common::DirectoryTree::getDevicesPath ( void  )
inlinestatic

Returns the absolute path to the family and device database directory.

Definition at line 60 of file DirectoryTree.hpp.

60 { return sDevicesPath; }
static boost::filesystem::path sDevicesPath
Absolute path to the family and device database directory.

+ Here is the caller graph for this function:

static const boost::filesystem::path& torc::common::DirectoryTree::getExecutablePath ( void  )
inlinestatic

Returns the absolute path to the executable directory.

Definition at line 58 of file DirectoryTree.hpp.

58 { return sExecutablePath; }
static boost::filesystem::path sExecutablePath
Absolute path to the executable directory.

+ Here is the caller graph for this function:

static const boost::filesystem::path& torc::common::DirectoryTree::getLogPath ( void  )
inlinestatic

Returns the absolute path to the log files directory.

Definition at line 62 of file DirectoryTree.hpp.

62 { return sLogPath; }
static boost::filesystem::path sLogPath
Absolute path to the log files directory.

+ Here is the caller graph for this function:

static const boost::filesystem::path& torc::common::DirectoryTree::getRelativePath ( void  )
inlinestatic

Returns the relative path from the working directory to the executable home.

Definition at line 54 of file DirectoryTree.hpp.

54 { return sRelativePath; }
static boost::filesystem::path sRelativePath
Relative path from the working directory to the executable home.

+ Here is the caller graph for this function:

static const boost::filesystem::path& torc::common::DirectoryTree::getWorkingPath ( void  )
inlinestatic

Returns the absolute path to the working directory.

Definition at line 56 of file DirectoryTree.hpp.

56 { return sWorkingPath; }
static boost::filesystem::path sWorkingPath
Absolute path to the working directory.

+ Here is the caller graph for this function:

Field Documentation

boost::filesystem::path torc::common::DirectoryTree::sDevicesPath
staticprotected

Absolute path to the family and device database directory.

Definition at line 40 of file DirectoryTree.hpp.

boost::filesystem::path torc::common::DirectoryTree::sEdaPath
staticprotected

Absolute path to the EDA libraries directory.

Definition at line 38 of file DirectoryTree.hpp.

boost::filesystem::path torc::common::DirectoryTree::sExecutablePath
staticprotected

Absolute path to the executable directory.

Definition at line 36 of file DirectoryTree.hpp.

boost::filesystem::path torc::common::DirectoryTree::sLogPath
staticprotected

Absolute path to the log files directory.

Definition at line 42 of file DirectoryTree.hpp.

boost::filesystem::path torc::common::DirectoryTree::sRelativePath
staticprotected

Relative path from the working directory to the executable home.

Definition at line 32 of file DirectoryTree.hpp.

boost::filesystem::path torc::common::DirectoryTree::sWorkingPath
staticprotected

Absolute path to the working directory.

Definition at line 34 of file DirectoryTree.hpp.


The documentation for this class was generated from the following files: