Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

AbsPath Class Reference

#include <PathTest.h>

Collaboration diagram for AbsPath:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Mode { Executable }

Public Member Functions

 AbsPath (const char *filename, const char *execname, Mode mode=Executable)
void prependSearchDir (const char *dirname)
void appendSearchDir (const char *dirname)
bool exists (MNString &absfilename)

Detailed Description

A class that tests whether the given filename exists in the search PATH of the environment. The search PATH may be extended by the caller before calling exists() for the first time. After that first call, the test will be completed and the path extension will fail. Exists() can be called as often as necessary and it will always return a boolean value indicating whether the file has been found, and if yes, it's absolute path.

The only supported mode right now is executable. All other tests that are supported by access() or stat() can be added in the future.


Member Enumeration Documentation

enum AbsPath::Mode
 

Enumeration values:
Executable 


Constructor & Destructor Documentation

AbsPath::AbsPath const char *  filename,
const char *  execname,
Mode  mode = Executable
 

The AbsPath class is intended for automatic search for one specific filename, and for caching the result. Right now only searching for executables is supported.

Parameters:
filename The name of the executable that we are looking for.
execname This should be argv[0]. Relative paths in the executable will usually be provided relative to the installation directory of the exectuable itself, and not relative to the current working directory. But calling the exectuable from the current working directory allows to determine this directory by looking at the basename of argv[0]. This parameter is meant to used for that step.
mode We look only at executables with this access mode (read, write, execute, or a combination).


Member Function Documentation

void AbsPath::appendSearchDir const char *  dirname  ) 
 

bool AbsPath::exists MNString absfilename  ) 
 

The first call to this function triggers the search for the filename in the PATH. All subsequent calls to this function return the result of the first search.

Parameters:
absfilename OUT variable that contains the absolute file name if the return value is true.
Return values:
true Indicates the a file with the requested mode has been found.
false Indicates that no file with the request mode has been found.

void AbsPath::prependSearchDir const char *  dirname  ) 
 


The documentation for this class was generated from the following file:
Generated on Sun Mar 6 13:35:50 2005 for Komssys by doxygen 1.3.8