A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::SystemPath Namespace Reference

Encapsulate OS-specific functions to manipulate file and directory paths. More...

Functions

std::string Append (std::string left, std::string right)
 
std::string Dirname (std::string path)
 
std::string FindSelfDirectory (void)
 
std::string Join (std::list< std::string >::const_iterator begin, std::list< std::string >::const_iterator end)
 
void MakeDirectories (std::string path)
 
std::string MakeTemporaryDirectoryName (void)
 
std::list< std::string > ReadFiles (std::string path)
 
std::list< std::string > Split (std::string path)
 

Detailed Description

Encapsulate OS-specific functions to manipulate file and directory paths.

The functions provided here are used mostly to implement the ns-3 test framework.

Function Documentation

std::string ns3::SystemPath::Append ( std::string  left,
std::string  right 
)
Parameters
lefta path element
righta path element
Returns
a concatenation of the two input paths

Definition at line 163 of file system-path.cc.

References NS_LOG_FUNCTION.

std::string ns3::SystemPath::FindSelfDirectory ( void  )
Returns
the directory in which the currently-executing binary is located

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 73 of file system-path.cc.

References NS_ASSERT, NS_FATAL_ERROR, and NS_LOG_FUNCTION_NOARGS.

std::string ns3::SystemPath::Join ( std::list< std::string >::const_iterator  begin,
std::list< std::string >::const_iterator  end 
)
Parameters
beginiterator to first element to join
enditerator to last element to join
Returns
a path that is a concatenation of all the input elements.

Definition at line 198 of file system-path.cc.

References NS_LOG_FUNCTION.

Referenced by MakeDirectories().

void ns3::SystemPath::MakeDirectories ( std::string  path)
Parameters
patha path to a directory

Create all the directories leading to path.

Definition at line 303 of file system-path.cc.

References Join(), NS_LOG_FUNCTION, and Split().

std::string ns3::SystemPath::MakeTemporaryDirectoryName ( void  )
Returns
a path which identifies 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 256 of file system-path.cc.

References NS_LOG_FUNCTION_NOARGS.

std::list< std::string > ns3::SystemPath::ReadFiles ( std::string  path)
Parameters
patha path which identifies a directory
Returns
a list of the filenames which are located in the input directory

Definition at line 217 of file system-path.cc.

References NS_FATAL_ERROR, and NS_LOG_FUNCTION.

std::list< std::string > ns3::SystemPath::Split ( std::string  path)
Parameters
patha path
Returns
a list of path elements that can be joined together again with the Join function.
See Also
ns3::SystemPath::Join

Definition at line 180 of file system-path.cc.

References NS_LOG_FUNCTION.

Referenced by MakeDirectories().