Encapsulate OS-specific functions to manipulate file and directory paths. More...
Files | |
file | system-path.cc |
System-independent file and directory functions implementation. | |
file | system-path.h |
System-independent file and directory function declarations. | |
Namespaces | |
ns3::SystemPath | |
Namespace for various file and directory path functions. | |
Functions | |
std::string | ns3::SystemPath::Append (std::string left, std::string right) |
Join two file system path elements. More... | |
std::string | ns3::SystemPath::Dirname (std::string path) |
Get the directory path for a file. More... | |
std::string | ns3::SystemPath::FindSelfDirectory (void) |
Get the file system path to the current executable. More... | |
std::string | ns3::SystemPath::Join (std::list< std::string >::const_iterator begin, std::list< std::string >::const_iterator end) |
Join a list of file system path directories into a single file system path. More... | |
void | ns3::SystemPath::MakeDirectories (std::string path) |
Create all the directories leading to path. More... | |
std::string | ns3::SystemPath::MakeTemporaryDirectoryName (void) |
Get the name of a temporary directory. More... | |
std::list< std::string > | ns3::SystemPath::ReadFiles (std::string path) |
Get the list of files located in a file system directory. More... | |
std::list< std::string > | ns3::SystemPath::Split (std::string path) |
Split a file system path into directories according to the local path separator. More... | |
Encapsulate OS-specific functions to manipulate file and directory paths.
The functions provided here are used mostly to implement the ns-3 test framework.
std::string ns3::SystemPath::Append | ( | std::string | left, |
std::string | right | ||
) |
Join two file system path elements.
[in] | left | A path element |
[in] | right | A path element |
Definition at line 187 of file system-path.cc.
References NS_LOG_FUNCTION, and SYSTEM_PATH_SEP.
Referenced by ns3::TestCase::CreateDataDirFilename(), and ns3::TestCase::CreateTempDirFilename().
std::string ns3::SystemPath::Dirname | ( | std::string | path | ) |
Get the directory path for a file.
This is an internal function (by virtue of not being declared in a .h file); the public API is FindSelfDirectory().
[in] | path | The full path to a file. |
Definition at line 88 of file system-path.cc.
References ns3::SystemPath::Join(), NS_LOG_FUNCTION, and ns3::SystemPath::Split().
Referenced by ns3::SystemPath::FindSelfDirectory().
std::string ns3::SystemPath::FindSelfDirectory | ( | void | ) |
Get the file system path to the current executable.
This function returns the path to the running $PREFIX. Mac OS X: _NSGetExecutablePath() (man 3 dyld) Linux: readlink /proc/self/exe Solaris: getexecname() FreeBSD: sysctl CTL_KERN KERN_PROC KERN_PROC_PATHNAME -1 BSD with procfs: readlink /proc/curproc/file Windows: GetModuleFileName() with hModule = NULL
Definition at line 97 of file system-path.cc.
References ns3::SystemPath::Dirname(), NS_ASSERT, NS_FATAL_ERROR, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::TestRunnerImpl::GetTopLevelSourceDir().
std::string ns3::SystemPath::Join | ( | std::list< std::string >::const_iterator | begin, |
std::list< std::string >::const_iterator | end | ||
) |
Join a list of file system path directories into a single file system path.
This is the inverse of Split.
[in] | begin | Iterator to first element to join |
[in] | end | Iterator to last element to join |
Definition at line 222 of file system-path.cc.
References NS_LOG_FUNCTION, and SYSTEM_PATH_SEP.
Referenced by ns3::TestCase::CreateTempDirFilename(), ns3::SystemPath::Dirname(), ns3::TestRunnerImpl::GetTopLevelSourceDir(), and ns3::SystemPath::MakeDirectories().
void ns3::SystemPath::MakeDirectories | ( | std::string | path | ) |
Create all the directories leading to path.
[in] | path | A path to a directory |
Definition at line 327 of file system-path.cc.
References ns3::SystemPath::Join(), NS_LOG_ERROR, NS_LOG_FUNCTION, and ns3::SystemPath::Split().
Referenced by ns3::TestCase::CreateTempDirFilename().
std::string ns3::SystemPath::MakeTemporaryDirectoryName | ( | void | ) |
Get the name of a temporary directory.
The returned path identifies a directory which does not exist yet. Call ns3::SystemPath::MakeDirectories to create it. Yes, there is a well-known security race in this API but we don't care in ns-3.
Definition at line 280 of file system-path.cc.
References NS_LOG_FUNCTION_NOARGS, and SYSTEM_PATH_SEP.
Referenced by ns3::TestRunnerImpl::Run().
std::list< std::string > ns3::SystemPath::ReadFiles | ( | std::string | path | ) |
Get the list of files located in a file system directory.
[in] | path | A path which identifies a directory |
Definition at line 241 of file system-path.cc.
References NS_FATAL_ERROR, and NS_LOG_FUNCTION.
Referenced by ns3::TestRunnerImpl::IsTopLevelSourceDir().
std::list< std::string > ns3::SystemPath::Split | ( | std::string | path | ) |
Split a file system path into directories according to the local path separator.
This is the inverse of Join.
[in] | path | A path |
Definition at line 204 of file system-path.cc.
References NS_LOG_FUNCTION, and SYSTEM_PATH_SEP.
Referenced by ns3::SystemPath::Dirname(), ns3::TestRunnerImpl::GetTopLevelSourceDir(), ns3::SystemPath::MakeDirectories(), and ns3::CommandLine::Parse().