A Discrete-Event Network Simulator
API
Host Filesystem

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

+ Collaboration diagram for Host Filesystem:

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...
 

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 
)

Join two file system path elements.

Parameters
[in]leftA path element
[in]rightA path element
Returns
A concatenation of the two input paths

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

References NS_LOG_FUNCTION, and SYSTEM_PATH_SEP.

Referenced by ns3::TestCase::CreateDataDirFilename(), ns3::TestCase::CreateTempDirFilename(), and ns3::DesMetrics::Initialize().

+ Here is the caller graph for this function:

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().

Parameters
[in]pathThe full path to a file.
Returns
The full path to the containing directory.

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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ns3::SystemPath::FindSelfDirectory ( void  )

Get the file system path to the current executable.

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 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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Parameters
[in]beginIterator to first element to join
[in]endIterator to last element to join
Returns
A path that is a concatenation of all the input elements.

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().

+ Here is the caller graph for this function:

void ns3::SystemPath::MakeDirectories ( std::string  path)

Create all the directories leading to path.

Parameters
[in]pathA 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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Returns
A path which identifies a temporary directory.

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

References NS_LOG_FUNCTION_NOARGS, and SYSTEM_PATH_SEP.

Referenced by ns3::TestRunnerImpl::Run().

+ Here is the caller graph for this function:

std::list< std::string > ns3::SystemPath::ReadFiles ( std::string  path)

Get the list of files located in a file system directory.

Parameters
[in]pathA path which identifies a directory
Returns
A list of the filenames which are located in the input directory

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

References NS_FATAL_ERROR, and NS_LOG_FUNCTION.

Referenced by ns3::TestRunnerImpl::IsTopLevelSourceDir().

+ Here is the caller graph for this function:

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.

Parameters
[in]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 204 of file system-path.cc.

References NS_LOG_FUNCTION, and SYSTEM_PATH_SEP.

Referenced by ns3::SystemPath::Dirname(), ns3::TestRunnerImpl::GetTopLevelSourceDir(), ns3::DesMetrics::Initialize(), ns3::SystemPath::MakeDirectories(), ns3::CommandLine::Parse(), and ns3::TestRunnerImpl::Run().

+ Here is the caller graph for this function: