Vcsn
2.0
Be Rational
|
Manage search paths. More...
#include <file-library.hh>
Classes | |
class | not_found |
Exception thrown when a file cannot be located. More... | |
Public Types | |
using | self_type = file_library |
using | path_list_type = std::list< path > |
Broken on Mac OS X (https://trac.macports.org/ticket/41588). More... | |
using | strings_type = std::list< std::string > |
Public Member Functions | |
template<typename ForwardRange > | |
file_library & | push_back (const ForwardRange &r, const char *sep) |
template<class Iterable > | |
file_library & | push_back (const std::string &user_path, const Iterable &default_path, const char *sep) |
Constructor. | |
An empty library. | |
file_library () | |
file_library (const path &p) | |
Init the library with one path. More... | |
file_library (const std::string &library, const char *separator) | |
Init the library with a string to split at separator. More... | |
template<typename ForwardRange > | |
file_library (const ForwardRange &r, const char *sep) | |
Handle a list of search-paths. More... | |
Managing inclusion paths. | |
self_type & | push_back (const path &p) |
self_type & | push_back (const std::string &library, const char *separator) |
Split library on separator and put at the end of path list. More... | |
template<typename ForwardRange > | |
self_type & | push_back (const ForwardRange &r, const char *sep) |
Handle a list of search-paths. More... | |
template<class Iterable > | |
self_type & | push_back (const std::string &user_path, const Iterable &default_path, const char *sep) |
self_type & | append (const path &p) |
self_type & | push_front (const path &p) |
self_type & | push_front (const std::string &library, const char *separator) |
Split library on separator and put at the beginning of path list. More... | |
self_type & | prepend (const path &p) |
current directory. | |
void | push_current_directory (const path &p) |
void | pop_current_directory () |
path | current_directory_get () const |
Finding files. | |
path | find_file (const path &file) const |
Search a file. More... | |
Printing. | |
std::ostream & | dump (std::ostream &ostr) const |
Accessor. | |
const path_list_type & | search_path_get () const |
path_list_type & | search_path () |
Static Public Member Functions | |
static strings_type | split (const std::string &lib, const char *sep) |
Split lib at each occurrence of sep, return the list of components. More... | |
Private Member Functions | |
void | push_cwd () |
Push the working directory on the stack. More... | |
path | find_in_search_path (const path &filename) const |
Find file filename using include path. More... | |
Private Attributes | |
path_list_type | search_path_ |
Inclusion path list. More... | |
path_list_type | current_directory_ |
Current directory stack. More... | |
Manage search paths.
Store a search path and all informations used for handling paths when processing import directives.
Definition at line 23 of file file-library.hh.
using vcsn::file_library::path_list_type = std::list<path> |
Broken on Mac OS X (https://trac.macports.org/ticket/41588).
Definition at line 30 of file file-library.hh.
Definition at line 26 of file file-library.hh.
using vcsn::file_library::strings_type = std::list<std::string> |
Definition at line 97 of file file-library.hh.
vcsn::file_library::file_library | ( | ) |
Definition at line 32 of file file-library.cc.
References push_cwd().
vcsn::file_library::file_library | ( | const path & | p | ) |
Init the library with one path.
Definition at line 37 of file file-library.cc.
References push_back(), and push_cwd().
vcsn::file_library::file_library | ( | const std::string & | library, |
const char * | separator | ||
) |
Init the library with a string to split at separator.
Definition at line 45 of file file-library.cc.
References push_back(), and push_cwd().
vcsn::file_library::file_library | ( | const ForwardRange & | r, |
const char * | sep | ||
) |
Handle a list of search-paths.
r | the collection of search-paths. each occurrence of an additional colon marks the place where the following search-paths will be inserted. If there is none, the remaining components are ignored. |
sep | the separator to split search-paths (typically colon). |
Definition at line 13 of file file-library.hxx.
References push_back(), and push_cwd().
|
inline |
Definition at line 79 of file file-library.hxx.
References push_back().
auto vcsn::file_library::current_directory_get | ( | ) | const |
Definition at line 110 of file file-library.cc.
References current_directory_.
Referenced by find_file().
std::ostream & vcsn::file_library::dump | ( | std::ostream & | ostr | ) | const |
Definition at line 157 of file file-library.cc.
References search_path_.
Referenced by vcsn::operator<<().
auto vcsn::file_library::find_file | ( | const path & | file | ) | const |
Search a file.
Determine real path of file, by looking in search path if necessary.
not_found | file cannot be found, in which case errno is set to ENOENT. |
Definition at line 118 of file file-library.cc.
References current_directory_get(), vcsn::exists(), and find_in_search_path().
|
private |
Find file filename using include path.
not_found | file not found. |
Definition at line 140 of file file-library.cc.
References vcsn::exists(), and search_path_.
Referenced by find_file().
void vcsn::file_library::pop_current_directory | ( | ) |
Definition at line 103 of file file-library.cc.
References current_directory_.
|
inline |
Definition at line 85 of file file-library.hxx.
References push_front().
file_library& vcsn::file_library::push_back | ( | const ForwardRange & | r, |
const char * | sep | ||
) |
Definition at line 21 of file file-library.hxx.
References push_back(), and split().
file_library& vcsn::file_library::push_back | ( | const std::string & | user_path, |
const Iterable & | default_path, | ||
const char * | sep | ||
) |
Definition at line 48 of file file-library.hxx.
References push_back(), and split().
file_library & vcsn::file_library::push_back | ( | const path & | p | ) |
Definition at line 65 of file file-library.cc.
References vcsn::absolute(), and search_path_.
Referenced by append(), file_library(), and push_back().
file_library & vcsn::file_library::push_back | ( | const std::string & | library, |
const char * | separator | ||
) |
Split library on separator and put at the end of path list.
Definition at line 72 of file file-library.cc.
References push_back(), and split().
self_type& vcsn::file_library::push_back | ( | const ForwardRange & | r, |
const char * | sep | ||
) |
Handle a list of search-paths.
r | the collection of search-paths. each occurrence of an additional colon marks the place where the following search-paths will be inserted. If there is none, the remaining components are ignored. |
sep | the separator to split search-paths (typically colon). |
self_type& vcsn::file_library::push_back | ( | const std::string & | user_path, |
const Iterable & | default_path, | ||
const char * | sep | ||
) |
void vcsn::file_library::push_current_directory | ( | const path & | p | ) |
Definition at line 97 of file file-library.cc.
References vcsn::absolute(), and current_directory_.
Referenced by push_cwd().
|
private |
Push the working directory on the stack.
Definition at line 26 of file file-library.cc.
References vcsn::path::cwd(), and push_current_directory().
Referenced by file_library().
file_library & vcsn::file_library::push_front | ( | const path & | p | ) |
Definition at line 81 of file file-library.cc.
References vcsn::absolute(), and search_path_.
Referenced by prepend(), and push_front().
file_library & vcsn::file_library::push_front | ( | const std::string & | library, |
const char * | separator | ||
) |
Split library on separator and put at the beginning of path list.
Definition at line 88 of file file-library.cc.
References push_front(), and split().
|
inline |
Definition at line 97 of file file-library.hxx.
References search_path_.
|
inline |
Definition at line 91 of file file-library.hxx.
References search_path_.
|
static |
Split lib at each occurrence of sep, return the list of components.
Behaves especially on Windows when splitting on ":", in order to preserve drive prefixes (i.e., "c:foo:d:bar" is split in "c:foo", "d:bar").
Definition at line 52 of file file-library.cc.
Referenced by push_back(), and push_front().
|
private |
Current directory stack.
Definition at line 143 of file file-library.hh.
Referenced by current_directory_get(), pop_current_directory(), and push_current_directory().
|
private |
Inclusion path list.
Definition at line 140 of file file-library.hh.
Referenced by dump(), find_in_search_path(), push_back(), push_front(), search_path(), and search_path_get().