DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

Search_path(C++)


Search_path -- UNIX search paths

Synopsis

   #include <Search_path.h>
   namespace SCO_SC {
   

class Search_path : public List<Path>{ public: // Constructors Search_path(); Search_path(const char* p); // Copy and assign Search_path(const Search_path& p); Search_path& operator=(const Search_path& p); // Conversion to and from strings operator const char*()const; operator String()const; // Searching int find( const Path& p, Path& ret, Ksh_test::unary u = Ksh_test::x, Ksh_test::id id = Ksh_test::effective )const; int find_all( const Path& p, List<Path>& ret, Ksh_test::unary u = Ksh_test::x, Ksh_test::id id = Ksh_test::effective )const; // Stream insertion and extraction friend ostream& operator<<(ostream& os, const Search_path& p); friend istream& operator>>(istream& is, Search_path& p); }; // Global variables extern Search_path PATH; }

Description

A Search_path represents a UNIX search path, that is, a list of zero or more path names. A Search_path is constructed, written and read in standard UNIX search path format, i.e., as a string of colon-separated path names. However, Search_paths are real Lists, and as such obey all the semantics of Lists (see List(3C++)).

Search_path

Constructors

Search_path(); The empty search path.

Search_path(const char* p); Constructs the search path corresponding to the colon-separated list of paths pointed to by p. If p is 0, constructs the empty search path. (This enables usages such as Search_path(getenv("PATH")) shown below.)

Copy and assign

Search_path(const Search_path& p);

Search_path& operator=(const Search_path& p); Copy and assignment operator.

Conversion to and from strings

operator const char*()const;

operator String()const; Conversion to colon-separated list of paths.

Searching

int find( const Path& p, Path& ret, Ksh_test::unary u = Ksh_test::x, Ksh_test::id id = Ksh_test::effective )const; If p is relative, looks for the first Path dir in this Search_path for which ksh_test(t,Path(dir,p),id) is true. If such a directory exists, sets ret to Path(dir,p) and returns true, otherwise returns false without affecting ret. If p is absolute, returns ksh_test(t,p,id), setting ret to p if true.

int find_all( const Path& p, List<Path>& ret, Ksh_test::unary u = Ksh_test::x, Ksh_test::id id = Ksh_test::effective )const; Similar to the above, except that in the case p is relative, sets ret to the list consisting of all the satisfying Paths, and in the case p is absolute, sets ret to the list consisting of p or the empty list, depending on whether ksh_test(t,p,id) is true. The current position of ret is set to the beginning of the List. Returns true just if the returned value of ret is non-empty.

Stream insertion and extraction

friend ostream& operator<<(ostream& os," const Search_path& p);

friend istream& operator>>(istream& is, Search_path& p); Representation is as a colon-separated list of Paths.

Global variables

extern Search_path PATH; The value of the environment variable PATH at the time of program start-up. PATH is intentionally not declared const in order to enable assignment to it in case the value of the environment variable PATH changes while the program is executing. Assignment can be done as follows: PATH = Search_path(getenv("PATH")).

References

ksh_test(C++), Path(C++), Tmppath(C++)
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005