LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
misc::file_library Class Reference

Manage search path. More...

#include <file-library.hh>

Collaboration diagram for misc::file_library:

Public Member Functions

Constructor.

An empty library.

 file_library ()
 file_library (path p)
 Init the library with one path.
Managing inclusion paths.
void append_dir (path p)
void prepend_dir (path p)
current directory.
void push_current_directory (path p)
void pop_current_directory ()
path current_directory_get () const
Findind file
path find_file (const std::string &file)
 Search a file.
bool find_in_directory (const path &dir, const std::string &file) const
 Check if file exists in directory dir.
Printing.
std::ostream & dump (std::ostream &ostr) const

Private Types

typedef std::list< pathpath_list_type

Private Member Functions

void push_cwd ()
 Push the working directory on the stack.
path find_in_search_path (const path &relative_path, const std::string &filename) const
 Find file "\a relative_path / \a filename" using include path.
void append_dir_list (std::string path_list)
 Split the string with character ':', and insert each resultant string as a new search path.
path ensure_absolute_path (path p) const
 Ensure that path is absolute by prepending current directory if necessary.

Private Attributes

path_list_type search_path_
 Inclusion path list.
path_list_type current_directory_
 Current directory stack.

Detailed Description

Manage search path.

Store search path and all informations used for handling paths when processing import directives.

Member Typedef Documentation

typedef std::list<path> misc::file_library::path_list_type
private

Constructor & Destructor Documentation

misc::file_library::file_library ( )

References push_cwd().

misc::file_library::file_library ( path  p)

Init the library with one path.

References push_cwd(), and search_path_.

Member Function Documentation

void misc::file_library::append_dir ( path  p)
void misc::file_library::append_dir_list ( std::string  path_list)
private

Split the string with character ':', and insert each resultant string as a new search path.

References append_dir().

path misc::file_library::current_directory_get ( ) const
std::ostream & misc::file_library::dump ( std::ostream &  ostr) const

References search_path_.

Referenced by misc::operator<<().

path misc::file_library::ensure_absolute_path ( path  p) const
private

Ensure that path is absolute by prepending current directory if necessary.

References misc::path::absolute_get(), and current_directory_get().

Referenced by append_dir(), and prepend_dir().

path misc::file_library::find_file ( const std::string &  file)

Search a file.

Determine real path of file, by looking in search path if necessary.

Returns
Directory containing file, or "" if not found.

References misc::path::absolute_get(), misc::basedir(), misc::basename(), current_directory_get(), misc::file_exists(), filename, find_in_directory(), and find_in_search_path().

Referenced by parse::TigerParser::parse_import().

bool misc::file_library::find_in_directory ( const path dir,
const std::string &  file 
) const

Check if file exists in directory dir.

References misc::file_exists().

Referenced by find_file(), and find_in_search_path().

path misc::file_library::find_in_search_path ( const path relative_path,
const std::string &  filename 
) const
private

Find file "\a relative_path / \a filename" using include path.

Returns
Absolute path where the file lies or empty path if the file does not exist.

References current_directory_get(), find_in_directory(), and search_path_.

Referenced by find_file().

void misc::file_library::pop_current_directory ( )
void misc::file_library::prepend_dir ( path  p)
void misc::file_library::push_current_directory ( path  p)
void misc::file_library::push_cwd ( )
private

Push the working directory on the stack.

References push_current_directory().

Referenced by file_library().

Member Data Documentation

path_list_type misc::file_library::current_directory_
private

Current directory stack.

Referenced by current_directory_get(), pop_current_directory(), and push_current_directory().

path_list_type misc::file_library::search_path_
private

Inclusion path list.

Referenced by append_dir(), dump(), file_library(), find_in_search_path(), and prepend_dir().


The documentation for this class was generated from the following files: