1786
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1786
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_pathsearch_h) |
|
24 #define octave_pathsearch_h 1 |
|
25 |
|
26 #include <string> |
|
27 |
|
28 #include "str-vec.h" |
|
29 |
|
30 class |
|
31 dir_path |
|
32 { |
|
33 public: |
|
34 |
3174
|
35 dir_path (const string& s = string ()) |
|
36 : p_orig (s), initialized (false) |
1786
|
37 { |
3174
|
38 if (! p_orig.empty ()) |
1786
|
39 init (); |
|
40 } |
|
41 |
|
42 dir_path (const dir_path& dp) |
3174
|
43 : p_orig (dp.p_orig), initialized (dp.initialized), p (dp.p), pv (dp.pv) |
|
44 { } |
1786
|
45 |
|
46 dir_path& operator = (const dir_path& dp) |
|
47 { |
3174
|
48 p_orig = dp.p_orig; |
|
49 initialized = dp.initialized; |
1786
|
50 p = dp.p; |
|
51 pv = dp.pv; |
|
52 return *this; |
|
53 } |
|
54 |
|
55 ~dir_path (void) { } |
|
56 |
|
57 void set (const string& s) |
|
58 { |
|
59 initialized = false; |
3174
|
60 p_orig = s; |
1786
|
61 init (); |
|
62 } |
|
63 |
|
64 string_vector elements (void); |
|
65 string_vector all_directories (void); |
|
66 |
|
67 string find_first (const string&); |
|
68 string find (const string& nm) { return find_first (nm); } |
|
69 |
|
70 string_vector find_all (const string&); |
|
71 |
3174
|
72 static void set_program_name (const string&); |
3024
|
73 |
3185
|
74 void rehash (void) |
|
75 { |
|
76 initialized = false; |
|
77 init (); |
|
78 } |
|
79 |
1786
|
80 private: |
|
81 |
3174
|
82 // The colon separated list that we were given. |
|
83 string p_orig; |
1786
|
84 |
|
85 // TRUE means we've unpacked p. |
|
86 bool initialized; |
|
87 |
3174
|
88 // A version of the colon separate list on which we have performed |
|
89 // tilde and variable expansion. |
|
90 string p; |
|
91 |
1786
|
92 // The elements of the list. |
|
93 string_vector pv; |
|
94 |
|
95 void init (void); |
|
96 }; |
|
97 |
|
98 #endif |
|
99 |
|
100 /* |
|
101 ;;; Local Variables: *** |
|
102 ;;; mode: C++ *** |
|
103 ;;; End: *** |
|
104 */ |