00001 /* 00002 The lestes compiler suite 00003 Copyright (C) 2002, 2003, 2004, 2005 Miroslav Tichy 00004 Copyright (C) 2002, 2003, 2004, 2005 Petr Zika 00005 Copyright (C) 2002, 2003, 2004, 2005 Vojtech Hala 00006 Copyright (C) 2002, 2003, 2004, 2005 Jiri Kosina 00007 Copyright (C) 2002, 2003, 2004, 2005 Pavel Sanda 00008 Copyright (C) 2002, 2003, 2004, 2005 Jan Zouhar 00009 Copyright (C) 2002, 2003, 2004, 2005 Rudolf Thomas 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation; version 2 of the License. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 00020 See the full text of the GNU General Public License version 2, and 00021 the limitations in the file doc/LICENSE. 00022 00023 By accepting the license the licensee waives any and all claims 00024 against the copyright holder(s) related in whole or in part to the 00025 work, its use, and/or the inability to use it. 00026 00027 */ 00028 #ifndef lestes__lang__cplus__lex___file_system_hh___included 00029 #define lestes__lang__cplus__lex___file_system_hh___included 00030 00031 /*! \file 00032 \brief File system binding. 00033 00034 Declaration of file_system class providing access to the file system. 00035 \author pt 00036 */ 00037 #include <lestes/common.hh> 00038 #include <lestes/std/vector.hh> 00039 00040 package(lestes); 00041 package(lang); 00042 package(cplus); 00043 package(lex); 00044 00045 // forward declaration to break cycle 00046 class named_istream; 00047 00048 /*! 00049 \brief File system binding. 00050 00051 Provides acces to the file system. 00052 Enables opening file streams and include path search. 00053 */ 00054 class file_system: public ::lestes::std::object { 00055 public: 00056 //! The type of name for classification. 00057 typedef enum { 00058 //! Invalid name. 00059 NM_INVALID, 00060 //! Relative file name. 00061 NM_FILE_REL, 00062 //! Absolute file name. 00063 NM_FILE_ABS, 00064 //! Relative path. 00065 NM_PATH_REL, 00066 //! Absolute path. 00067 NM_PATH_ABS 00068 } name_type; 00069 //! Opens a file stream, using only working directory. 00070 ptr<named_istream> open_file(const lstring &name); 00071 //! Opens a file stream, searching given paths. 00072 ptr<named_istream> find_file(const lstring &path, const lstring &name, bool system); 00073 #if 0 00074 //! Opens a file stream, searching given paths. 00075 ptr<named_stream> find_file(const ptr<named_stream> &a_parent, const lstring &name, bool system); 00076 #endif 00077 //! Adds search path. 00078 bool add_search_path(const lstring &path); 00079 //! Returns new instance. 00080 static ptr<file_system> create(void); 00081 //! Classifies path and file name. 00082 static name_type classify_name(const lstring &name); 00083 protected: 00084 //! Creates the object. 00085 file_system(void); 00086 //! Marks the object. 00087 virtual void gc_mark(void); 00088 private: 00089 //! Type of sequence of strings, used for search path list. 00090 typedef ::lestes::std::vector<lstring> lstrings_type; 00091 //! Splits string into parts. 00092 static ptr< lstrings_type > split(const lstring &str, hchar delimiter); 00093 //! System search paths. 00094 srp<lstrings_type> search_paths; 00095 //! Hides copy constructor. 00096 file_system(const file_system &); 00097 //! Hides assignment operator. 00098 file_system &operator=(const file_system &); 00099 }; 00100 00101 end_package(lex); 00102 end_package(cplus); 00103 end_package(lang); 00104 end_package(lestes); 00105 00106 #endif 00107 /* vim: set ft=lestes : */ 00108
1.5.1-20070107