Mercurial > octave
annotate libinterp/corefcn/load-path.cc @ 27923:bd51beb6205e
update formatting of copyright notices
* Use <https://octave.org/copyright/> instead of
<https://octave.org/COPYRIGHT.html/>.
* For consistency with other comments in the Octave sources, use
C++-style comments for copyright blocks in C and C++ files.
* Use delimiters above and below copyright blocks that are appropriate
for the language used in the file.
* Eliminate extra spacing inside copyright blocks.
* lex.ll (looks_like_copyright): Also allow newlines and carriage
returns before the word "Copyright".
* scripts/mk-doc.pl (gethelp): Also skip empty comment lines.
* bp-table.cc, type.m: Adjust tests.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Jan 2020 11:59:41 -0500 |
parents | 1891570abac8 |
children | b018f553fd85 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
3 // Copyright (C) 2006-2020 The Octave Project Developers |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
5832 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21418
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
5832 | 28 #endif |
29 | |
30 #include <algorithm> | |
31 | |
32 #include "dir-ops.h" | |
33 #include "file-ops.h" | |
34 #include "file-stat.h" | |
35 #include "oct-env.h" | |
36 #include "pathsearch.h" | |
37 | |
38 #include "defaults.h" | |
39 #include "defun.h" | |
40 #include "input.h" | |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
41 #include "interpreter-private.h" |
22094
9203833cab7d
move new interpreter class to separate file
John W. Eaton <jwe@octave.org>
parents:
21992
diff
changeset
|
42 #include "interpreter.h" |
5832 | 43 #include "load-path.h" |
18204
adbbacce8aaf
find load file in private directories (bug #35697)
John W. Eaton <jwe@octave.org>
parents:
18137
diff
changeset
|
44 #include "ov-usr-fcn.h" |
5832 | 45 #include "pager.h" |
46 #include "parse.h" | |
25516
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
47 #include "sysdep.h" |
5832 | 48 #include "unwind-prot.h" |
49 #include "utils.h" | |
50 | |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
51 namespace octave |
5832 | 52 { |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
53 // Canonicalize file name (keeping the path relative) if it exists. |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
54 // Return it unmodified otherwise. |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
55 |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
56 static std::string |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
57 maybe_canonicalize (const std::string& dir_arg) |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
58 { |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
59 bool is_absolute_path = octave::sys::env::absolute_pathname (dir_arg); |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
60 |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
61 std::string canonical_dir = octave::sys::canonicalize_file_name (dir_arg); |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
62 std::string dir; |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
63 if (canonical_dir.empty ()) |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
64 dir = dir_arg; |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
65 else |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
66 { |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
67 dir = canonical_dir; |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
68 |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
69 if (! is_absolute_path) |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
70 { |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
71 // Remove current path from absolute path generated by |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
72 // canonicalize_file_name. |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
73 std::string cwd = octave::sys::canonicalize_file_name ("."); |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
74 if (dir.compare (0, cwd.length (), cwd) == 0) |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
75 dir.erase (0, cwd.length ()+1); |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
76 if (dir.empty ()) |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
77 dir = "."; |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
78 } |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
79 } |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
80 |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
81 return dir; |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
82 } |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
83 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
84 static void |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
85 maybe_add_path_elts (std::string& path, const std::string& dir) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
86 { |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
87 std::string tpath = genpath (maybe_canonicalize (dir)); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
88 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
89 if (! tpath.empty ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
90 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
91 if (path.empty ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
92 path = tpath; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
93 else |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
94 path += directory_path::path_sep_str () + tpath; |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
95 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
96 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
97 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
98 static std::list<std::string> |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
99 split_path (const std::string& p) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
100 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
101 std::list<std::string> retval; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
102 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
103 size_t beg = 0; |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
104 size_t end = p.find (directory_path::path_sep_char ()); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
105 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
106 size_t len = p.length (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
107 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
108 while (end != std::string::npos) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
109 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
110 std::string elt = p.substr (beg, end-beg); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
111 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
112 if (! elt.empty ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
113 retval.push_back (elt); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
114 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
115 beg = end + 1; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
116 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
117 if (beg == len) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
118 break; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
119 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
120 end = p.find (directory_path::path_sep_char (), beg); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
121 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
122 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
123 std::string elt = p.substr (beg); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
124 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
125 if (! elt.empty ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
126 retval.push_back (elt); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
127 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
128 return retval; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
129 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
130 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
131 // Strip trailing directory separators. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
132 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
133 static std::string |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
134 strip_trailing_separators (const std::string& dir_arg) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
135 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
136 std::string dir = dir_arg; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
137 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
138 size_t k = dir.length (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
139 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
140 while (k > 1 && sys::file_ops::is_dir_sep (dir[k-1])) |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
141 k--; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
142 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
143 if (k < dir.length ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
144 dir.resize (k); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
145 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
146 return dir; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
147 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
148 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
149 // Should we cache all files in private directories, or is it OK to just |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
150 // look them up each time as needed? |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
151 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
152 static std::string |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
153 find_private_file (const std::string& fname) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
154 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
155 std::string retval; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
156 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
157 // Look in private directory corresponding to current function (if |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
158 // any). |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
159 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
160 symbol_scope scope = __get_current_scope__ ("find_private_file"); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
161 |
27745
7a45100a40c4
allow private scripts to be called from other private scripts
John W. Eaton <jwe@octave.org>
parents:
27703
diff
changeset
|
162 octave_user_code *curr_code = scope ? scope.user_code () : nullptr; |
7a45100a40c4
allow private scripts to be called from other private scripts
John W. Eaton <jwe@octave.org>
parents:
27703
diff
changeset
|
163 |
7a45100a40c4
allow private scripts to be called from other private scripts
John W. Eaton <jwe@octave.org>
parents:
27703
diff
changeset
|
164 if (curr_code) |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
165 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
166 // Even for private functions, dir_name doesn't contain the |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
167 // "private" directory component so we append it here in all |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
168 // cases. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
169 |
27745
7a45100a40c4
allow private scripts to be called from other private scripts
John W. Eaton <jwe@octave.org>
parents:
27703
diff
changeset
|
170 std::string dir_name = curr_code->dir_name (); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
171 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
172 if (! dir_name.empty ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
173 { |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
174 std::string pfname = dir_name + sys::file_ops::dir_sep_str () |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
175 + "private" + sys::file_ops::dir_sep_str () + fname; |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
176 |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
177 sys::file_stat fs (pfname); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
178 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
179 if (fs.exists () && fs.is_reg ()) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
180 retval = pfname; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
181 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
182 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
183 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
184 return retval; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
185 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
186 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
187 // True if a path is contained in a path list separated by path_sep_char |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
188 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
189 static bool |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
190 in_path_list (const std::string& path_list, const std::string& path) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
191 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
192 size_t ps = path.size (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
193 size_t pls = path_list.size (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
194 size_t pos = path_list.find (path); |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
195 char psc = directory_path::path_sep_char (); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
196 while (pos != std::string::npos) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
197 { |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
198 if ((pos == 0 || path_list[pos-1] == psc) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
199 && (pos + ps == pls || path_list[pos + ps] == psc)) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
200 return true; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
201 else |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
202 pos = path_list.find (path, pos + 1); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
203 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
204 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
205 return false; |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
206 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
207 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
208 static void |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
209 rehash_internal (void) |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
210 { |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
211 load_path& lp = __get_load_path__ ("rehash_internal"); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
212 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
213 lp.update (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
214 |
27311
0040b7668518
update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27102
diff
changeset
|
215 // Signal the GUI allowing updating the load path dialog |
0040b7668518
update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27102
diff
changeset
|
216 event_manager& evmgr = __get_event_manager__ ("rehash_internal"); |
0040b7668518
update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27102
diff
changeset
|
217 evmgr.update_path_dialog (); |
0040b7668518
update load path dialog when path is modified via console
Torsten Lilge <ttl-octave@mailbox.org>
parents:
27102
diff
changeset
|
218 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
219 // FIXME: maybe we should rename this variable since it is being |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
220 // used for more than keeping track of the prompt time. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
221 |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
222 // This will force updated functions to be found. |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
223 Vlast_prompt_time.stamp (); |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
224 } |
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
225 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
226 std::string load_path::sys_path; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
227 load_path::abs_dir_cache_type load_path::abs_dir_cache; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
228 |
27394
489c74ac36da
store reference to interpreter in load_path object
John W. Eaton <jwe@octave.org>
parents:
27311
diff
changeset
|
229 load_path::load_path (interpreter& interp) |
489c74ac36da
store reference to interpreter in load_path object
John W. Eaton <jwe@octave.org>
parents:
27311
diff
changeset
|
230 : m_interpreter (interp), package_map (), top_level_package (), |
489c74ac36da
store reference to interpreter in load_path object
John W. Eaton <jwe@octave.org>
parents:
27311
diff
changeset
|
231 dir_info_list (), init_dirs (), m_command_line_path (), |
25344
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
232 add_hook ([this] (const std::string& dir) { this->execute_pkg_add (dir); }), |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
233 remove_hook ([this] (const std::string& dir) { this->execute_pkg_del (dir); }) |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
234 { } |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
235 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
236 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
237 load_path::initialize (bool set_initial_path) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
238 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
239 sys_path = ""; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
240 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
241 if (set_initial_path) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
242 { |
23717
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
243 maybe_add_path_elts (sys_path, config::local_ver_oct_file_dir ()); |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
244 maybe_add_path_elts (sys_path, config::local_api_oct_file_dir ()); |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
245 maybe_add_path_elts (sys_path, config::local_oct_file_dir ()); |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
246 maybe_add_path_elts (sys_path, config::local_ver_fcn_file_dir ()); |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
247 maybe_add_path_elts (sys_path, config::local_api_fcn_file_dir ()); |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
248 maybe_add_path_elts (sys_path, config::local_fcn_file_dir ()); |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
249 maybe_add_path_elts (sys_path, config::oct_file_dir ()); |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
250 maybe_add_path_elts (sys_path, config::fcn_file_dir ()); |
06579337237b
move configuration variables inside octave::config namespace
John W. Eaton <jwe@octave.org>
parents:
23696
diff
changeset
|
251 maybe_add_path_elts (sys_path, config::oct_data_dir ()); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
252 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
253 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
254 std::string tpath = load_path::m_command_line_path; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
255 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
256 if (tpath.empty ()) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
257 tpath = sys::env::getenv ("OCTAVE_PATH"); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
258 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
259 std::string xpath; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
260 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
261 if (! tpath.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
262 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
263 xpath = tpath; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
264 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
265 if (! sys_path.empty ()) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
266 xpath += directory_path::path_sep_str () + sys_path; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
267 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
268 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
269 xpath = sys_path; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
270 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
271 set (xpath, false, true); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
272 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
273 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
274 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
275 load_path::clear (void) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
276 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
277 dir_info_list.clear (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
278 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
279 top_level_package.clear (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
280 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
281 package_map.clear (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
282 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
283 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
284 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
285 load_path::set (const std::string& p, bool warn, bool is_init) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
286 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
287 // Use a list when we need to preserve order. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
288 std::list<std::string> elts = split_path (p); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
289 |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
290 for (auto& elt : elts) |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
291 elt = maybe_canonicalize (elt); |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
292 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
293 // Use a set when we need to search and order is not important. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
294 std::set<std::string> elts_set (elts.begin (), elts.end ()); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
295 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
296 if (is_init) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
297 init_dirs = elts_set; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
298 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
299 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
300 for (const auto& init_dir : init_dirs) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
301 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
302 if (elts_set.find (init_dir) == elts_set.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
303 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
304 warning_with_id ("Octave:remove-init-dir", |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
305 "default load path altered. Some built-in functions may not be found. Try restoredefaultpath() to recover it."); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
306 break; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
307 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
308 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
309 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
310 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
311 // Temporarily disable add hook. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
312 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
313 unwind_protect frame; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
314 frame.protect_var (add_hook); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
315 |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23717
diff
changeset
|
316 add_hook = nullptr; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
317 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
318 clear (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
319 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
320 for (const auto& elt : elts) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
321 append (elt, warn); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
322 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
323 // Restore add hook and execute for all newly added directories. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
324 frame.run_first (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
325 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
326 // FIXME: Shouldn't the test for add_hook be outside the for loop? |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
327 // Why not use const here? Does add_hook change dir_info_list? |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
328 for (auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
329 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
330 if (add_hook) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
331 add_hook (di.dir_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
332 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
333 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
334 // Always prepend current directory. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
335 prepend (".", warn); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
336 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
337 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
338 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
339 load_path::append (const std::string& dir, bool warn) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
340 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
341 if (! dir.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
342 add (dir, true, warn); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
343 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
344 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
345 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
346 load_path::prepend (const std::string& dir, bool warn) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
347 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
348 if (! dir.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
349 add (dir, false, warn); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
350 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
351 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
352 bool |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
353 load_path::remove (const std::string& dir_arg) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
354 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
355 bool retval = false; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
356 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
357 if (! dir_arg.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
358 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
359 if (dir_arg == ".") |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
360 { |
23803
90689bdbe048
Use C++11 raw string literals to avoid escaping double quotes.
Rik <rik@octave.org>
parents:
23795
diff
changeset
|
361 warning (R"(rmpath: can't remove "." from path)"); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
362 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
363 // Avoid additional warnings. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
364 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
365 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
366 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
367 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
368 std::string dir = sys::file_ops::tilde_expand (dir_arg); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
369 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
370 dir = strip_trailing_separators (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
371 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
372 auto i = find_dir_info (dir); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
373 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
374 if (i != dir_info_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
375 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
376 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
377 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
378 if (remove_hook) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
379 remove_hook (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
380 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
381 dir_info& di = *i; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
382 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
383 remove (di); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
384 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
385 dir_info_list.erase (i); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
386 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
387 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
388 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
389 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
390 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
391 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
392 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
393 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
394 load_path::update (void) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
395 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
396 // I don't see a better way to do this because we need to |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
397 // preserve the correct directory ordering for new files that |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
398 // have appeared. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
399 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
400 top_level_package.clear (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
401 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
402 package_map.clear (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
403 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
404 for (auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
405 { |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
406 bool ok = di.update (); |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
407 |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
408 if (! ok) |
26105
0cebf81fcdc5
Stop segfault when load-path directory does not exist (bug #55046).
Rik <rik@octave.org>
parents:
25958
diff
changeset
|
409 warning ("load-path: update failed for '%s', removing from path", |
0cebf81fcdc5
Stop segfault when load-path directory does not exist (bug #55046).
Rik <rik@octave.org>
parents:
25958
diff
changeset
|
410 di.dir_name.c_str ()); |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
411 else |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
412 add (di, true, "", true); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
413 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
414 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
415 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
416 bool |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
417 load_path::contains_canonical (const std::string& dir) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
418 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
419 bool retval = false; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
420 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
421 for (const auto& d : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
422 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
423 if (same_file (dir, d.dir_name)) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
424 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
425 retval = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
426 break; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
427 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
428 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
429 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
430 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
431 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
432 |
27396
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
433 bool |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
434 load_path::contains_file_in_dir (const std::string& file, |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
435 const std::string& dir) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
436 { |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
437 bool ok = false; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
438 bool addpath_option = true; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
439 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
440 std::string curr_dir = sys::env::get_current_directory (); |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
441 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
442 if (same_file (curr_dir, dir)) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
443 ok = true; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
444 else |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
445 { |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
446 bool dir_in_load_path = contains_canonical (dir); |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
447 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
448 // get base name, allowing "@class/method.m" (bug #41514) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
449 std::string base_file = (file.length () > dir.length ()) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
450 ? file.substr (dir.length () + 1) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
451 : sys::env::base_pathname (file); |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
452 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
453 std::string lp_file = find_file (base_file); |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
454 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
455 if (dir_in_load_path) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
456 { |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
457 if (same_file (lp_file, file)) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
458 ok = true; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
459 } |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
460 else |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
461 { |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
462 // File directory is not in path. Is the file in the path in |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
463 // the current directory? If so, then changing the current |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
464 // directory will be needed. Adding directory to path is |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
465 // not enough because the file in the current directory would |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
466 // still be found. |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
467 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
468 if (same_file (lp_file, base_file)) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
469 { |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
470 if (same_file (curr_dir, dir)) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
471 ok = true; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
472 else |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
473 addpath_option = false; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
474 } |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
475 } |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
476 } |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
477 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
478 if (! ok) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
479 { |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
480 event_manager& evmgr = m_interpreter.get_event_manager (); |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
481 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
482 int action |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
483 = evmgr.debug_cd_or_addpath_error (file, dir, addpath_option); |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
484 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
485 switch (action) |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
486 { |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
487 case 1: |
27408
9b19eec60931
move change directory function to interpreter class
John W. Eaton <jwe@octave.org>
parents:
27396
diff
changeset
|
488 m_interpreter.chdir (dir); |
27396
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
489 ok = true; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
490 break; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
491 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
492 case 2: |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
493 { |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
494 prepend (dir); |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
495 ok = true; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
496 } |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
497 break; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
498 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
499 default: |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
500 break; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
501 } |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
502 } |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
503 |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
504 return ok; |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
505 } |
930c0fbc003b
move qt_interpreter_events::file_in_path to load_path::contains_file_in_dir
John W. Eaton <jwe@octave.org>
parents:
27394
diff
changeset
|
506 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
507 std::list<std::string> |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
508 load_path::overloads (const std::string& meth) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
509 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
510 std::list<std::string> retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
511 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
512 // update (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
513 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
514 top_level_package.overloads (meth, retval); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
515 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
516 for (const auto& nm_ldr : package_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
517 nm_ldr.second.overloads (meth, retval); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
518 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
519 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
520 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
521 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
522 std::list<std::string> |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
523 load_path::get_all_package_names (bool only_top_level) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
524 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
525 std::list<std::string> retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
526 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
527 for (const auto& dir_ldr : package_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
528 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
529 if (! only_top_level || dir_ldr.first.find ('.') == std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
530 retval.push_back (dir_ldr.first); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
531 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
532 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
533 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
534 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
535 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
536 std::string |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
537 load_path::find_file (const std::string& file) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
538 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
539 std::string retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
540 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
541 if (sys::env::absolute_pathname (file) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
542 || sys::env::rooted_relative_pathname (file)) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
543 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
544 sys::file_stat fs (file); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
545 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
546 return fs.exists () ? file : retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
547 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
548 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
549 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
550 std::string tfile = find_private_file (file); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
551 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
552 if (! tfile.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
553 return tfile; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
554 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
555 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
556 if (file.find_first_of (sys::file_ops::dir_sep_chars ()) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
557 != std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
558 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
559 // Given name has a directory separator, so append it to each |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
560 // element of the load path in turn. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
561 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
562 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
563 std::string tfile = sys::file_ops::concat (di.dir_name, file); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
564 |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
565 sys::file_stat fs (tfile); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
566 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
567 if (fs.exists ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
568 return tfile; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
569 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
570 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
571 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
572 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
573 // Look in cache. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
574 for (const auto & di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
575 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
576 string_vector all_files = di.all_files; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
577 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
578 octave_idx_type len = all_files.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
579 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
580 for (octave_idx_type i = 0; i < len; i++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
581 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
582 if (all_files[i] == file) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
583 return sys::file_ops::concat (di.dir_name, file); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
584 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
585 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
586 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
587 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
588 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
589 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
590 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
591 std::string |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
592 load_path::find_dir (const std::string& dir) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
593 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
594 std::string retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
595 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
596 if (dir.find_first_of (sys::file_ops::dir_sep_chars ()) != std::string::npos |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
597 && (sys::env::absolute_pathname (dir) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
598 || sys::env::rooted_relative_pathname (dir))) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
599 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
600 sys::file_stat fs (dir); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
601 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
602 if (fs.exists () && fs.is_dir ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
603 return dir; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
604 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
605 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
606 { |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
607 std::string canon_dir = maybe_canonicalize (dir); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
608 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
609 { |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
610 std::string dname = sys::env::make_absolute (di.dir_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
611 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
612 size_t dname_len = dname.length (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
613 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
614 if (dname.substr (dname_len - 1) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
615 == sys::file_ops::dir_sep_str ()) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
616 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
617 dname = dname.substr (0, dname_len - 1); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
618 dname_len--; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
619 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
620 |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
621 size_t dir_len = canon_dir.length (); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
622 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
623 if (dname_len > dir_len |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
624 && sys::file_ops::is_dir_sep (dname[dname_len - dir_len - 1]) |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
625 && canon_dir == dname.substr (dname_len - dir_len)) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
626 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
627 sys::file_stat fs (di.dir_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
628 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
629 if (fs.exists () && fs.is_dir ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
630 return di.dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
631 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
632 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
633 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
634 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
635 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
636 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
637 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
638 string_vector |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
639 load_path::find_matching_dirs (const std::string& dir) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
640 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
641 std::list<std::string> retlist; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
642 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
643 if (dir.find_first_of (sys::file_ops::dir_sep_chars ()) != std::string::npos |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
644 && (sys::env::absolute_pathname (dir) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
645 || sys::env::rooted_relative_pathname (dir))) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
646 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
647 sys::file_stat fs (dir); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
648 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
649 if (fs.exists () && fs.is_dir ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
650 retlist.push_back (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
651 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
652 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
653 { |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
654 std::string canon_dir = maybe_canonicalize (dir); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
655 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
656 { |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
657 std::string dname = sys::env::make_absolute (di.dir_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
658 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
659 size_t dname_len = dname.length (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
660 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
661 if (dname.substr (dname_len - 1) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
662 == sys::file_ops::dir_sep_str ()) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
663 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
664 dname = dname.substr (0, dname_len - 1); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
665 dname_len--; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
666 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
667 |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
668 size_t dir_len = canon_dir.length (); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
669 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
670 if (dname_len > dir_len |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
671 && sys::file_ops::is_dir_sep (dname[dname_len - dir_len - 1]) |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
672 && canon_dir == dname.substr (dname_len - dir_len)) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
673 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
674 sys::file_stat fs (di.dir_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
675 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
676 if (fs.exists () && fs.is_dir ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
677 retlist.push_back (di.dir_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
678 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
679 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
680 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
681 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
682 return retlist; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
683 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
684 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
685 std::string |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
686 load_path::find_first_of (const string_vector& flist) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
687 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
688 std::string retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
689 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
690 std::string dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
691 std::string file_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
692 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
693 octave_idx_type flen = flist.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
694 octave_idx_type rel_flen = 0; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
695 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
696 string_vector rel_flist (flen); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
697 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
698 for (octave_idx_type i = 0; i < flen; i++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
699 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
700 std::string file = flist[i]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
701 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
702 if (file.find_first_of (sys::file_ops::dir_sep_chars ()) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
703 != std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
704 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
705 if (sys::env::absolute_pathname (file) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
706 || sys::env::rooted_relative_pathname (file)) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
707 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
708 sys::file_stat fs (file); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
709 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
710 if (fs.exists ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
711 return file; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
712 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
713 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
714 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
715 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
716 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
717 std::string tfile; |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
718 tfile = sys::file_ops::concat (di.dir_name, file); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
719 |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
720 sys::file_stat fs (tfile); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
721 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
722 if (fs.exists ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
723 return tfile; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
724 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
725 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
726 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
727 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
728 rel_flist[rel_flen++] = file; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
729 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
730 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
731 rel_flist.resize (rel_flen); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
732 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
733 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
734 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
735 string_vector all_files = di.all_files; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
736 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
737 octave_idx_type len = all_files.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
738 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
739 for (octave_idx_type i = 0; i < len; i++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
740 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
741 for (octave_idx_type j = 0; j < rel_flen; j++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
742 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
743 if (all_files[i] == rel_flist[j]) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
744 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
745 dir_name = di.dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
746 file_name = rel_flist[j]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
747 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
748 goto done; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
749 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
750 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
751 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
752 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
753 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
754 done: |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
755 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
756 if (! dir_name.empty ()) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
757 retval = sys::file_ops::concat (dir_name, file_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
758 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
759 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
760 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
761 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
762 string_vector |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
763 load_path::find_all_first_of (const string_vector& flist) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
764 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
765 std::list<std::string> retlist; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
766 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
767 std::string dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
768 std::string file_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
769 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
770 octave_idx_type flen = flist.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
771 octave_idx_type rel_flen = 0; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
772 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
773 string_vector rel_flist (flen); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
774 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
775 for (octave_idx_type i = 0; i < flen; i++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
776 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
777 std::string file = flist[i]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
778 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
779 if (file.find_first_of (sys::file_ops::dir_sep_chars ()) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
780 != std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
781 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
782 if (sys::env::absolute_pathname (file) |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
783 || sys::env::rooted_relative_pathname (file)) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
784 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
785 sys::file_stat fs (file); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
786 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
787 if (fs.exists ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
788 retlist.push_back (file); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
789 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
790 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
791 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
792 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
793 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
794 std::string tfile; |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
795 tfile = sys::file_ops::concat (di.dir_name, file); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
796 |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
797 sys::file_stat fs (tfile); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
798 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
799 if (fs.exists ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
800 retlist.push_back (tfile); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
801 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
802 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
803 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
804 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
805 rel_flist[rel_flen++] = file; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
806 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
807 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
808 rel_flist.resize (rel_flen); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
809 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
810 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
811 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
812 string_vector all_files = di.all_files; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
813 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
814 octave_idx_type len = all_files.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
815 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
816 for (octave_idx_type i = 0; i < len; i++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
817 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
818 for (octave_idx_type j = 0; j < rel_flen; j++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
819 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
820 if (all_files[i] == rel_flist[j]) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
821 retlist.push_back (sys::file_ops::concat (di.dir_name, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
822 rel_flist[j])); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
823 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
824 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
825 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
826 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
827 return retlist; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
828 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
829 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
830 string_vector |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
831 load_path::dirs (void) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
832 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
833 size_t len = dir_info_list.size (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
834 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
835 string_vector retval (len); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
836 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
837 octave_idx_type k = 0; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
838 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
839 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
840 retval[k++] = di.dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
841 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
842 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
843 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
844 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
845 std::list<std::string> |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
846 load_path::dir_list (void) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
847 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
848 std::list<std::string> retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
849 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
850 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
851 retval.push_back (di.dir_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
852 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
853 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
854 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
855 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
856 string_vector |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
857 load_path::files (const std::string& dir, bool omit_exts) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
858 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
859 string_vector retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
860 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
861 const_dir_info_list_iterator p = find_dir_info (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
862 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
863 if (p != dir_info_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
864 retval = p->fcn_files; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
865 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
866 if (omit_exts) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
867 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
868 octave_idx_type len = retval.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
869 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
870 for (octave_idx_type i = 0; i < len; i++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
871 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
872 std::string fname = retval[i]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
873 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
874 size_t pos = fname.rfind ('.'); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
875 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
876 if (pos != std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
877 retval[i] = fname.substr (0, pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
878 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
879 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
880 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
881 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
882 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
883 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
884 string_vector |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
885 load_path::fcn_names (void) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
886 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
887 return top_level_package.fcn_names (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
888 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
889 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
890 std::string |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
891 load_path::path (void) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
892 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
893 std::string xpath; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
894 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
895 string_vector xdirs = load_path::dirs (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
896 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
897 octave_idx_type len = xdirs.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
898 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
899 if (len > 0) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
900 xpath = xdirs[0]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
901 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
902 for (octave_idx_type i = 1; i < len; i++) |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
903 xpath += directory_path::path_sep_str () + xdirs[i]; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
904 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
905 return xpath; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
906 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
907 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
908 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
909 load_path::display (std::ostream& os) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
910 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
911 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
912 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
913 string_vector fcn_files = di.fcn_files; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
914 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
915 if (! fcn_files.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
916 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
917 os << "\n*** function files in " << di.dir_name << ":\n\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
918 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
919 fcn_files.list_in_columns (os); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
920 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
921 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
922 const dir_info::method_file_map_type& method_file_map |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
923 = di.method_file_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
924 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
925 if (! method_file_map.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
926 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
927 for (const auto& cls_ci : method_file_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
928 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
929 os << "\n*** methods in " << di.dir_name |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
930 << "/@" << cls_ci.first << ":\n\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
931 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
932 const dir_info::class_info& ci = cls_ci.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
933 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
934 string_vector method_files = get_file_list (ci.method_file_map); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
935 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
936 method_files.list_in_columns (os); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
937 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
938 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
939 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
940 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
941 top_level_package.display (os); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
942 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
943 for (const auto& nm_ldr : package_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
944 nm_ldr.second.display (os); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
945 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
946 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
947 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
948 load_path::execute_pkg_add (const std::string& dir) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
949 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
950 execute_pkg_add_or_del (dir, "PKG_ADD"); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
951 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
952 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
953 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
954 load_path::execute_pkg_del (const std::string& dir) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
955 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
956 execute_pkg_add_or_del (dir, "PKG_DEL"); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
957 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
958 |
25344
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
959 void load_path::execute_pkg_add_or_del (const std::string& dir, |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
960 const std::string& script_file) |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
961 { |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
962 if (! octave_interpreter_ready) |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
963 return; |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
964 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
965 unwind_protect frame; |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
966 |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
967 std::string file = sys::file_ops::concat (dir, script_file); |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
968 |
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
969 sys::file_stat fs (file); |
25344
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
970 |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
971 if (fs.exists ()) |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
972 source_file (file, "base"); |
25344
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
973 } |
4d3ce214da32
use std::function object for load-path add/remove hook functions
John W. Eaton <jwe@octave.org>
parents:
25343
diff
changeset
|
974 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
975 // FIXME: maybe we should also maintain a map to speed up this method of access. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
976 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
977 load_path::const_dir_info_list_iterator |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
978 load_path::find_dir_info (const std::string& dir_arg) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
979 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
980 std::string dir = sys::file_ops::tilde_expand (dir_arg); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
981 |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
982 dir = maybe_canonicalize (dir); |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
983 |
25343
4d7790d9793f
use cbegin, crbegin, cend, and crend and auto decls where possible
John W. Eaton <jwe@octave.org>
parents:
25342
diff
changeset
|
984 auto retval = dir_info_list.cbegin (); |
4d7790d9793f
use cbegin, crbegin, cend, and crend and auto decls where possible
John W. Eaton <jwe@octave.org>
parents:
25342
diff
changeset
|
985 |
4d7790d9793f
use cbegin, crbegin, cend, and crend and auto decls where possible
John W. Eaton <jwe@octave.org>
parents:
25342
diff
changeset
|
986 while (retval != dir_info_list.cend ()) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
987 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
988 if (retval->dir_name == dir) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
989 break; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
990 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
991 retval++; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
992 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
993 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
994 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
995 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
996 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
997 load_path::dir_info_list_iterator |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
998 load_path::find_dir_info (const std::string& dir_arg) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
999 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1000 std::string dir = sys::file_ops::tilde_expand (dir_arg); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1001 |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
1002 dir = maybe_canonicalize (dir); |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
1003 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1004 auto retval = dir_info_list.begin (); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1005 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1006 while (retval != dir_info_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1007 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1008 if (retval->dir_name == dir) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1009 break; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1010 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1011 retval++; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1012 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1013 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1014 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1015 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1016 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1017 bool |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1018 load_path::contains (const std::string& dir) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1019 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1020 return find_dir_info (dir) != dir_info_list.end (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1021 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1022 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1023 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1024 load_path::move (dir_info_list_iterator i, bool at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1025 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1026 if (dir_info_list.size () > 1) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1027 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1028 dir_info di = *i; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1029 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1030 dir_info_list.erase (i); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1031 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1032 if (at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1033 dir_info_list.push_back (di); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1034 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1035 dir_info_list.push_front (di); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1036 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1037 move (di, at_end); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1038 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1039 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1040 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1041 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1042 load_path::move (const dir_info& di, bool at_end, const std::string& pname) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1043 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1044 package_info& l = get_package (pname); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1045 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1046 l.move (di, at_end); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1047 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1048 dir_info::package_dir_map_type package_dir_map = di.package_dir_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1049 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1050 for (const auto& pkg_di : package_dir_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1051 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1052 std::string full_name = pkg_di.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1053 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1054 if (! pname.empty ()) |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
1055 full_name = pname + '.' + full_name; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1056 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1057 move (pkg_di.second, at_end, full_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1058 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1059 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1060 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1061 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1062 load_path::add (const std::string& dir_arg, bool at_end, bool warn) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1063 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1064 size_t len = dir_arg.length (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1065 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1066 if (len > 1 && dir_arg.substr (len-2) == "//") |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1067 warning_with_id ("Octave:recursive-path-search", |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1068 "trailing '//' is no longer special in search path elements"); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1069 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1070 std::string dir = sys::file_ops::tilde_expand (dir_arg); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1071 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1072 dir = strip_trailing_separators (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1073 |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
1074 dir = maybe_canonicalize (dir); |
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
1075 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1076 auto i = find_dir_info (dir); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1077 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1078 if (i != dir_info_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1079 move (i, at_end); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1080 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1081 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1082 sys::file_stat fs (dir); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1083 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1084 if (fs) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1085 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1086 if (fs.is_dir ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1087 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1088 dir_info di (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1089 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1090 if (at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1091 dir_info_list.push_back (di); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1092 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1093 dir_info_list.push_front (di); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1094 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1095 add (di, at_end); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1096 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1097 if (add_hook) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1098 add_hook (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1099 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1100 else if (warn) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1101 warning ("addpath: %s: not a directory", dir_arg.c_str ()); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1102 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1103 else if (warn) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1104 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1105 std::string msg = fs.error (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1106 warning ("addpath: %s: %s", dir_arg.c_str (), msg.c_str ()); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1107 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1108 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1109 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1110 // FIXME: is there a better way to do this? |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1111 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1112 i = find_dir_info ("."); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1113 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1114 if (i != dir_info_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1115 move (i, false); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1116 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1117 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1118 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1119 load_path::remove (const dir_info& di, const std::string& pname) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1120 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1121 package_info& l = get_package (pname); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1122 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1123 l.remove (di); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1124 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1125 dir_info::package_dir_map_type package_dir_map = di.package_dir_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1126 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1127 for (const auto& pkg_di : package_dir_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1128 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1129 std::string full_name = pkg_di.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1130 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1131 if (! pname.empty ()) |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
1132 full_name = pname + '.' + full_name; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1133 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1134 remove (pkg_di.second, full_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1135 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1136 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1137 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1138 bool |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1139 load_path::is_package (const std::string& name) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1140 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1141 for (const auto& di : dir_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1142 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1143 if (di.is_package (name)) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1144 return true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1145 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1146 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1147 return false; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1148 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1149 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1150 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1151 load_path::add (const dir_info& di, bool at_end, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1152 const std::string& pname, bool updating) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1153 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1154 package_info& l = get_package (pname); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1155 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1156 l.add (di, at_end, updating); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1157 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1158 dir_info::package_dir_map_type package_dir_map = di.package_dir_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1159 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1160 for (const auto& pkg_di : package_dir_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1161 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1162 std::string full_name = pkg_di.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1163 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1164 if (! pname.empty ()) |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
1165 full_name = pname + '.' + full_name; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1166 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1167 add (pkg_di.second, at_end, full_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1168 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1169 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1170 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1171 string_vector |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1172 load_path::get_file_list (const load_path::dir_info::fcn_file_map_type& lst) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1173 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1174 octave_idx_type n = lst.size (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1175 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1176 string_vector retval (n); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1177 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1178 octave_idx_type count = 0; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1179 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1180 for (const auto& nm_typ : lst) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1181 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1182 std::string nm = nm_typ.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1183 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1184 int types = nm_typ.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1185 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1186 if (types & load_path::OCT_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1187 nm += ".oct"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1188 else if (types & load_path::MEX_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1189 nm += ".mex"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1190 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1191 nm += ".m"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1192 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1193 retval[count++] = nm; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1194 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1195 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1196 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1197 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1198 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1199 load_path::dir_info::fcn_file_map_type |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1200 get_fcn_files (const std::string& d) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1201 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1202 load_path::dir_info::fcn_file_map_type retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1203 |
25516
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
1204 string_vector flist; |
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
1205 std::string msg; |
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
1206 |
27102
84ff9953faa1
where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
27101
diff
changeset
|
1207 if (! sys::get_dirlist (d, flist, msg)) |
25516
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
1208 warning ("load_path: %s: %s", d.c_str (), msg.c_str ()); |
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
1209 else |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1210 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1211 octave_idx_type len = flist.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1212 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1213 for (octave_idx_type i = 0; i < len; i++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1214 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1215 std::string fname = flist[i]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1216 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1217 size_t pos = fname.rfind ('.'); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1218 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1219 if (pos != std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1220 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1221 std::string base = fname.substr (0, pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1222 std::string ext = fname.substr (pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1223 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1224 if (valid_identifier (base)) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1225 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1226 int t = 0; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1227 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1228 if (ext == ".m") |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1229 t = load_path::M_FILE; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1230 else if (ext == ".oct") |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1231 t = load_path::OCT_FILE; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1232 else if (ext == ".mex") |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1233 t = load_path::MEX_FILE; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1234 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1235 if (t) |
25376
cc40e47d3a44
track multiple file types (oct|m|mex) for private functions (bug #53856)
John W. Eaton <jwe@octave.org>
parents:
25374
diff
changeset
|
1236 { |
cc40e47d3a44
track multiple file types (oct|m|mex) for private functions (bug #53856)
John W. Eaton <jwe@octave.org>
parents:
25374
diff
changeset
|
1237 load_path::dir_info::fcn_file_map_iterator p |
cc40e47d3a44
track multiple file types (oct|m|mex) for private functions (bug #53856)
John W. Eaton <jwe@octave.org>
parents:
25374
diff
changeset
|
1238 = retval.find (base); |
cc40e47d3a44
track multiple file types (oct|m|mex) for private functions (bug #53856)
John W. Eaton <jwe@octave.org>
parents:
25374
diff
changeset
|
1239 |
cc40e47d3a44
track multiple file types (oct|m|mex) for private functions (bug #53856)
John W. Eaton <jwe@octave.org>
parents:
25374
diff
changeset
|
1240 if (p == retval.end ()) |
cc40e47d3a44
track multiple file types (oct|m|mex) for private functions (bug #53856)
John W. Eaton <jwe@octave.org>
parents:
25374
diff
changeset
|
1241 retval[base] = t; |
cc40e47d3a44
track multiple file types (oct|m|mex) for private functions (bug #53856)
John W. Eaton <jwe@octave.org>
parents:
25374
diff
changeset
|
1242 else |
cc40e47d3a44
track multiple file types (oct|m|mex) for private functions (bug #53856)
John W. Eaton <jwe@octave.org>
parents:
25374
diff
changeset
|
1243 p->second |= t; |
cc40e47d3a44
track multiple file types (oct|m|mex) for private functions (bug #53856)
John W. Eaton <jwe@octave.org>
parents:
25374
diff
changeset
|
1244 } |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1245 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1246 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1247 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1248 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1249 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1250 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1251 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1252 |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1253 bool |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1254 load_path::dir_info::update (void) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1255 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1256 sys::file_stat fs (dir_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1257 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1258 if (! fs) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1259 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1260 std::string msg = fs.error (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1261 warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1262 return false; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1263 } |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1264 |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1265 sys::file_stat pfs (sys::file_ops::concat (dir_name, "private")); |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1266 bool has_private_dir = pfs && pfs.is_dir (); |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1267 |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1268 if (is_relative) |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1269 { |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1270 try |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1271 { |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1272 std::string abs_name = sys::env::make_absolute (dir_name); |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1273 |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1274 const_abs_dir_cache_iterator p = abs_dir_cache.find (abs_name); |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1275 |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1276 if (p != abs_dir_cache.end ()) |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1277 { |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1278 // The directory is in the cache of all directories we have |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1279 // visited (indexed by absolute name). If it is out of date, |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1280 // initialize it. Otherwise, copy the info from the cache. |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1281 // By doing that, we avoid unnecessary calls to stat that can |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1282 // slow things down tremendously for large directories. |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1283 const dir_info& di = p->second; |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1284 |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1285 if ((fs.mtime () + fs.time_resolution () |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1286 > di.dir_time_last_checked) |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1287 || (has_private_dir |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1288 && (pfs.mtime () + pfs.time_resolution () |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1289 > dir_time_last_checked))) |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1290 initialize (); |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1291 else |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1292 { |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1293 // Copy over info from cache, but leave dir_name and |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1294 // is_relative unmodified. |
25958
56ac36b5f7b0
eliminate unnecessary use of this-> in member function
John W. Eaton <jwe@octave.org>
parents:
25957
diff
changeset
|
1295 abs_dir_name = di.abs_dir_name; |
56ac36b5f7b0
eliminate unnecessary use of this-> in member function
John W. Eaton <jwe@octave.org>
parents:
25957
diff
changeset
|
1296 dir_mtime = di.dir_mtime; |
56ac36b5f7b0
eliminate unnecessary use of this-> in member function
John W. Eaton <jwe@octave.org>
parents:
25957
diff
changeset
|
1297 dir_time_last_checked = di.dir_time_last_checked; |
56ac36b5f7b0
eliminate unnecessary use of this-> in member function
John W. Eaton <jwe@octave.org>
parents:
25957
diff
changeset
|
1298 all_files = di.all_files; |
56ac36b5f7b0
eliminate unnecessary use of this-> in member function
John W. Eaton <jwe@octave.org>
parents:
25957
diff
changeset
|
1299 fcn_files = di.fcn_files; |
56ac36b5f7b0
eliminate unnecessary use of this-> in member function
John W. Eaton <jwe@octave.org>
parents:
25957
diff
changeset
|
1300 private_file_map = di.private_file_map; |
56ac36b5f7b0
eliminate unnecessary use of this-> in member function
John W. Eaton <jwe@octave.org>
parents:
25957
diff
changeset
|
1301 method_file_map = di.method_file_map; |
56ac36b5f7b0
eliminate unnecessary use of this-> in member function
John W. Eaton <jwe@octave.org>
parents:
25957
diff
changeset
|
1302 package_dir_map = di.package_dir_map; |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1303 } |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1304 } |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1305 else |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1306 { |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1307 // We haven't seen this directory before. |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1308 initialize (); |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1309 } |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1310 } |
27471 | 1311 catch (const execution_exception& ee) |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1312 { |
27471 | 1313 // Skip updating if we don't know where we are, but don't |
1314 // treat it as an error. | |
1315 | |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
1316 interpreter& interp |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
1317 = __get_interpreter__ ("load_path::dir_info::update"); |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
1318 |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
1319 interp.recover_from_exception (); |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1320 } |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1321 } |
25957
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1322 // Absolute path, check timestamp to see whether it requires re-caching |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1323 else if (fs.mtime () + fs.time_resolution () > dir_time_last_checked |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1324 || (has_private_dir |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1325 && (pfs.mtime () + pfs.time_resolution () |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1326 > dir_time_last_checked))) |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1327 initialize (); |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1328 |
d8993fe43a64
remove nonexistent directories when updating loadpath
John W. Eaton <jwe@octave.org>
parents:
25952
diff
changeset
|
1329 return true; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1330 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1331 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1332 bool |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1333 load_path::dir_info::is_package (const std::string& name) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1334 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1335 size_t pos = name.find ('.'); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1336 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1337 if (pos == std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1338 return package_dir_map.find (name) != package_dir_map.end (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1339 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1340 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1341 std::string name_head = name.substr (0, pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1342 std::string name_tail = name.substr (pos + 1); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1343 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1344 const_package_dir_map_iterator it = package_dir_map.find (name_head); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1345 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1346 if (it != package_dir_map.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1347 return it->second.is_package (name_tail); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1348 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1349 return false; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1350 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1351 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1352 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1353 void |
26970
340d44f2f942
backout changeset 98f1a964ff33
John W. Eaton <jwe@octave.org>
parents:
26781
diff
changeset
|
1354 load_path::dir_info::initialize (void) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1355 { |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1356 is_relative = ! sys::env::absolute_pathname (dir_name); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1357 |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1358 dir_time_last_checked = sys::time (static_cast<time_t> (0)); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1359 |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1360 sys::file_stat fs (dir_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1361 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1362 if (fs) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1363 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1364 method_file_map.clear (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1365 package_dir_map.clear (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1366 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1367 dir_mtime = fs.mtime (); |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1368 dir_time_last_checked = sys::time (); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1369 |
26970
340d44f2f942
backout changeset 98f1a964ff33
John W. Eaton <jwe@octave.org>
parents:
26781
diff
changeset
|
1370 get_file_list (dir_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1371 |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1372 try |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1373 { |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1374 std::string abs_name = sys::env::make_absolute (dir_name); |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1375 |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1376 // FIXME: nothing is ever removed from this cache of |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1377 // directory information, so there could be some resource |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1378 // problems. Perhaps it should be pruned from time to time. |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1379 |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1380 abs_dir_cache[abs_name] = *this; |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1381 } |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1382 catch (const execution_exception&) |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1383 { |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1384 // Skip updating if we don't know where we are but don't treat |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1385 // it as an error. |
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1386 |
27474
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
1387 interpreter& interp |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
1388 = __get_interpreter__ ("load_path::dir_info::initialize"); |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
1389 |
3fec8e9fa2aa
make recover_from_exception a member function
John W. Eaton <jwe@octave.org>
parents:
27471
diff
changeset
|
1390 interp.recover_from_exception (); |
24367
1909f2d7a36e
Backed out changeset 4e746afab617
John W. Eaton <jwe@octave.org>
parents:
24363
diff
changeset
|
1391 } |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1392 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1393 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1394 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1395 std::string msg = fs.error (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1396 warning ("load_path: %s: %s", dir_name.c_str (), msg.c_str ()); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1397 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1398 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1399 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1400 void |
26970
340d44f2f942
backout changeset 98f1a964ff33
John W. Eaton <jwe@octave.org>
parents:
26781
diff
changeset
|
1401 load_path::dir_info::get_file_list (const std::string& d) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1402 { |
27703
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1403 string_vector flist; |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1404 std::string msg; |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1405 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1406 if (! sys::get_dirlist (d, flist, msg)) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1407 { |
27703
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1408 warning ("load_path: %s: %s", d.c_str (), msg.c_str ()); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1409 return; |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1410 } |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1411 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1412 octave_idx_type len = flist.numel (); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1413 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1414 all_files.resize (len); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1415 fcn_files.resize (len); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1416 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1417 octave_idx_type all_files_count = 0; |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1418 octave_idx_type fcn_files_count = 0; |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1419 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1420 for (octave_idx_type i = 0; i < len; i++) |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1421 { |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1422 std::string fname = flist[i]; |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1423 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1424 std::string full_name = sys::file_ops::concat (d, fname); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1425 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1426 sys::file_stat fs (full_name); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1427 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1428 if (fs) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1429 { |
27703
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1430 if (fs.is_dir ()) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1431 { |
27703
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1432 if (fname == "private") |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1433 get_private_file_map (full_name); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1434 else if (fname[0] == '@') |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1435 get_method_file_map (full_name, fname.substr (1)); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1436 else if (fname[0] == '+') |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1437 get_package_dir (full_name, fname.substr (1)); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1438 } |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1439 else |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1440 { |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1441 all_files[all_files_count++] = fname; |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1442 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1443 size_t pos = fname.rfind ('.'); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1444 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1445 if (pos != std::string::npos) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1446 { |
27703
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1447 std::string ext = fname.substr (pos); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1448 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1449 if (ext == ".m" || ext == ".oct" || ext == ".mex") |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1450 { |
27703
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1451 std::string base = fname.substr (0, pos); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1452 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1453 if (valid_identifier (base)) |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1454 fcn_files[fcn_files_count++] = fname; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1455 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1456 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1457 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1458 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1459 } |
27703
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1460 |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1461 all_files.resize (all_files_count); |
12a53552db92
Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27609
diff
changeset
|
1462 fcn_files.resize (fcn_files_count); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1463 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1464 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1465 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1466 load_path::dir_info::get_private_file_map (const std::string& d) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1467 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1468 private_file_map = get_fcn_files (d); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1469 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1470 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1471 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1472 load_path::dir_info::get_method_file_map (const std::string& d, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1473 const std::string& class_name) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1474 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1475 method_file_map[class_name].method_file_map = get_fcn_files (d); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1476 |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1477 std::string pd = sys::file_ops::concat (d, "private"); |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1478 |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1479 sys::file_stat fs (pd); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1480 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1481 if (fs && fs.is_dir ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1482 method_file_map[class_name].private_file_map = get_fcn_files (pd); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1483 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1484 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1485 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1486 load_path::dir_info::get_package_dir (const std::string& d, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1487 const std::string& package_name) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1488 { |
26970
340d44f2f942
backout changeset 98f1a964ff33
John W. Eaton <jwe@octave.org>
parents:
26781
diff
changeset
|
1489 package_dir_map[package_name] = dir_info (d); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1490 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1491 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1492 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1493 load_path::package_info::move (const dir_info& di, bool at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1494 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1495 std::string dir_name = di.dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1496 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1497 auto s = std::find (dir_list.begin (), dir_list.end (), dir_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1498 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1499 if (s != dir_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1500 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1501 dir_list.erase (s); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1502 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1503 if (at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1504 dir_list.push_back (dir_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1505 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1506 dir_list.push_front (dir_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1507 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1508 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1509 move_fcn_map (dir_name, di.fcn_files, at_end); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1510 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1511 // No need to move elements of private function map. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1512 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1513 move_method_map (dir_name, at_end); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1514 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1515 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1516 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1517 load_path::package_info::remove (const dir_info& di) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1518 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1519 std::string dir = di.dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1520 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1521 string_vector fcn_files = di.fcn_files; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1522 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1523 dir_list.remove (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1524 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1525 remove_fcn_map (dir, fcn_files); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1526 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1527 remove_private_fcn_map (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1528 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1529 remove_method_map (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1530 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1531 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1532 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1533 load_path::package_info::display (std::ostream& os) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1534 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1535 os << "*** package_info: " |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1536 << (m_package_name.empty () ? "<top-level>" : m_package_name) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1537 << "\n\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1538 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1539 for (const auto& dir : dir_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1540 os << dir << "\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1541 os << "\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1542 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1543 for (const auto& dir_fnlst : private_fcn_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1544 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1545 os << "\n*** private functions in " |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1546 << sys::file_ops::concat (dir_fnlst.first, "private") |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1547 << ":\n\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1548 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1549 print_fcn_list (os, dir_fnlst.second); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1550 } |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1551 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1552 #if defined (DEBUG_LOAD_PATH) |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1553 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1554 for (const auto& nm_filst : fcn_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1555 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1556 os << nm_filst.first << ":\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1557 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1558 const file_info_list_type& file_info_list = nm_filst.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1559 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1560 for (const auto& finfo : file_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1561 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1562 os << " " << finfo.dir_name << " ("; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1563 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1564 print_types (os, finfo.types); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1565 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1566 os << ")\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1567 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1568 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1569 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1570 for (const auto& cls_fnmap : method_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1571 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1572 os << "CLASS " << cls_fnmap.first << ":\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1573 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1574 const fcn_map_type& fm = cls_fnmap.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1575 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1576 for (const auto& nm_fnlst : fcn_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1577 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1578 os << " " << nm_fnlst.first << ":\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1579 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1580 const file_info_list_type& file_info_list = nm_fnlst.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1581 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1582 for (const auto& finfo : file_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1583 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1584 os << " " << finfo.dir_name << " ("; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1585 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1586 print_types (os, finfo.types); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1587 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1588 os << ")\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1589 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1590 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1591 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1592 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1593 os << "\n"; |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1594 |
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
1595 #endif |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1596 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1597 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1598 std::string |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1599 load_path::package_info::find_fcn (const std::string& fcn, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1600 std::string& dir_name, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1601 int type) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1602 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1603 std::string retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1604 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1605 // update (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1606 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1607 if (fcn.length () > 0 && fcn[0] == '@') |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1608 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1609 size_t pos = fcn.find ('/'); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1610 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1611 if (pos != std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1612 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1613 std::string class_name = fcn.substr (1, pos-1); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1614 std::string meth = fcn.substr (pos+1); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1615 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1616 retval = find_method (class_name, meth, dir_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1617 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1618 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1619 retval = ""; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1620 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1621 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1622 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1623 dir_name = ""; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1624 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1625 const_fcn_map_iterator p = fcn_map.find (fcn); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1626 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1627 if (p != fcn_map.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1628 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1629 const file_info_list_type& file_info_list = p->second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1630 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1631 for (const auto& fi : file_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1632 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1633 retval = sys::file_ops::concat (fi.dir_name, fcn); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1634 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1635 if (check_file_type (retval, type, fi.types, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1636 fcn, "load_path::find_fcn")) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1637 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1638 dir_name = fi.dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1639 break; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1640 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1641 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1642 retval = ""; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1643 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1644 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1645 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1646 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1647 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1648 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1649 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1650 std::string |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1651 load_path::package_info::find_private_fcn (const std::string& dir, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1652 const std::string& fcn, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1653 int type) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1654 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1655 std::string retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1656 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1657 // update (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1658 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1659 const_private_fcn_map_iterator q = private_fcn_map.find (dir); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1660 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1661 if (q != private_fcn_map.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1662 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1663 const dir_info::fcn_file_map_type& m = q->second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1664 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1665 dir_info::const_fcn_file_map_iterator p = m.find (fcn); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1666 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1667 if (p != m.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1668 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1669 std::string fname |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1670 = sys::file_ops::concat (sys::file_ops::concat (dir, "private"), fcn); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1671 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1672 if (check_file_type (fname, type, p->second, fcn, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1673 "load_path::find_private_fcn")) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1674 retval = fname; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1675 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1676 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1677 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1678 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1679 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1680 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1681 std::string |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1682 load_path::package_info::find_method (const std::string& class_name, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1683 const std::string& meth, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1684 std::string& dir_name, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1685 int type) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1686 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1687 std::string retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1688 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1689 // update (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1690 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1691 dir_name = ""; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1692 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1693 const_method_map_iterator q = method_map.find (class_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1694 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1695 if (q != method_map.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1696 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1697 const fcn_map_type& m = q->second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1698 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1699 const_fcn_map_iterator p = m.find (meth); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1700 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1701 if (p != m.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1702 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1703 const file_info_list_type& file_info_list = p->second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1704 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1705 for (const auto& fi : file_info_list) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1706 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1707 retval = sys::file_ops::concat (fi.dir_name, meth); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1708 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1709 bool found = check_file_type (retval, type, fi.types, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1710 meth, "load_path::find_method"); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1711 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1712 if (found) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1713 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1714 dir_name = fi.dir_name; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1715 break; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1716 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1717 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1718 retval = ""; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1719 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1720 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1721 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1722 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1723 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1724 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1725 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1726 std::list<std::string> |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1727 load_path::package_info::methods (const std::string& class_name) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1728 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1729 std::list<std::string> retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1730 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1731 // update (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1732 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1733 const_method_map_iterator mtd_map_it = method_map.find (class_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1734 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1735 if (mtd_map_it != method_map.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1736 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1737 for (const auto& nm_filst : mtd_map_it->second) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1738 retval.push_back (nm_filst.first); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1739 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1740 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1741 if (! retval.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1742 retval.sort (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1743 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1744 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1745 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1746 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1747 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1748 load_path::package_info::overloads (const std::string& meth, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1749 std::list<std::string>& l) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1750 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1751 for (const auto& cls_fnmap : method_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1752 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1753 const fcn_map_type& m = cls_fnmap.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1754 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1755 if (m.find (meth) != m.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1756 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1757 std::string class_name = cls_fnmap.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1758 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1759 if (! m_package_name.empty ()) |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
1760 class_name = m_package_name + '.' + class_name; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1761 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1762 l.push_back (class_name); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1763 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1764 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1765 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1766 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1767 string_vector |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1768 load_path::package_info::fcn_names (void) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1769 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1770 size_t len = fcn_map.size (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1771 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1772 string_vector retval (len); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1773 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1774 octave_idx_type count = 0; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1775 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1776 for (const auto& nm_filst : fcn_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1777 retval[count++] = nm_filst.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1778 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1779 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1780 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1781 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1782 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1783 load_path::package_info::add_to_fcn_map (const dir_info& di, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1784 bool at_end, bool updating) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1785 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1786 std::string dir_name = di.dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1787 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1788 string_vector fcn_files = di.fcn_files; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1789 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1790 octave_idx_type len = fcn_files.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1791 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1792 for (octave_idx_type i = 0; i < len; i++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1793 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1794 std::string fname = fcn_files[i]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1795 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1796 std::string ext; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1797 std::string base = fname; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1798 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1799 size_t pos = fname.rfind ('.'); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1800 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1801 if (pos != std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1802 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1803 base = fname.substr (0, pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1804 ext = fname.substr (pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1805 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1806 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1807 file_info_list_type& file_info_list = fcn_map[base]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1808 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1809 auto p = file_info_list.begin (); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1810 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1811 while (p != file_info_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1812 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1813 if (p->dir_name == dir_name) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1814 break; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1815 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1816 p++; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1817 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1818 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1819 int t = 0; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1820 if (ext == ".m") |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1821 t = load_path::M_FILE; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1822 else if (ext == ".oct") |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1823 t = load_path::OCT_FILE; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1824 else if (ext == ".mex") |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1825 t = load_path::MEX_FILE; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1826 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1827 if (p == file_info_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1828 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1829 // Warn if a built-in or library function is being shadowed, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1830 // but not if we are just updating (rehashing) the list. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1831 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1832 if (! updating) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1833 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1834 if (file_info_list.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1835 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1836 symbol_table& symtab |
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1837 = __get_symbol_table__ ("load_path::package_info::add_to_fcn_map"); |
23599
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23586
diff
changeset
|
1838 |
5cb3a2bb5e1e
don't use singleton for symbol_table
John W. Eaton <jwe@octave.org>
parents:
23586
diff
changeset
|
1839 if (symtab.is_built_in_function_name (base)) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1840 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1841 std::string fcn_path = sys::file_ops::concat (dir_name, fname); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1842 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1843 warning_with_id ("Octave:shadowed-function", |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1844 "function %s shadows a built-in function", |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1845 fcn_path.c_str ()); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1846 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1847 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1848 else if (! at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1849 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1850 file_info& old = file_info_list.front (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1851 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1852 // FIXME: do we need to be more careful about the |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1853 // way we look for old.dir_name in sys_path to avoid |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1854 // partial matches? |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1855 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1856 // Don't warn about Contents.m files since we expect |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1857 // more than one to exist in the load path. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1858 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1859 if (fname != "Contents.m" |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1860 && sys_path.find (old.dir_name) != std::string::npos |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1861 && in_path_list (sys_path, old.dir_name)) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1862 { |
23696
08036a7f3660
remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
23693
diff
changeset
|
1863 std::string fcn_path = sys::file_ops::concat (dir_name, fname); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1864 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1865 warning_with_id ("Octave:shadowed-function", |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1866 "function %s shadows a core library function", |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1867 fcn_path.c_str ()); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1868 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1869 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1870 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1871 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1872 file_info fi (dir_name, t); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1873 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1874 if (at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1875 file_info_list.push_back (fi); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1876 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1877 file_info_list.push_front (fi); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1878 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1879 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1880 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1881 file_info& fi = *p; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1882 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1883 fi.types |= t; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1884 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1885 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1886 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1887 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1888 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1889 load_path::package_info::add_to_private_fcn_map (const dir_info& di) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1890 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1891 dir_info::fcn_file_map_type private_file_map = di.private_file_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1892 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1893 if (! private_file_map.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1894 private_fcn_map[di.dir_name] = private_file_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1895 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1896 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1897 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1898 load_path::package_info::add_to_method_map (const dir_info& di, bool at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1899 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1900 std::string dir_name = di.dir_name; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1901 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1902 // <CLASS_NAME, CLASS_INFO> |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1903 dir_info::method_file_map_type method_file_map = di.method_file_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1904 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1905 for (const auto& cls_ci : method_file_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1906 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1907 std::string class_name = cls_ci.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1908 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1909 fcn_map_type& fm = method_map[class_name]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1910 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1911 std::string full_dir_name |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
1912 = sys::file_ops::concat (dir_name, '@' + class_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1913 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1914 const dir_info::class_info& ci = cls_ci.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1915 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1916 // <FCN_NAME, TYPES> |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1917 const dir_info::fcn_file_map_type& m = ci.method_file_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1918 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1919 for (const auto& nm_typ : m) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1920 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1921 std::string base = nm_typ.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1922 int types = nm_typ.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1923 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1924 file_info_list_type& file_info_list = fm[base]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1925 |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
1926 auto p2 = file_info_list.begin (); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1927 while (p2 != file_info_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1928 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1929 if (p2->dir_name == full_dir_name) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
1930 break; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1931 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1932 p2++; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1933 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1934 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1935 if (p2 == file_info_list.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1936 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1937 file_info fi (full_dir_name, types); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1938 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1939 if (at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1940 file_info_list.push_back (fi); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1941 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1942 file_info_list.push_front (fi); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1943 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1944 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1945 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1946 // FIXME: is this possible? |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1947 file_info& fi = *p2; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1948 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1949 fi.types = types; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1950 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1951 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1952 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1953 // <FCN_NAME, TYPES> |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1954 dir_info::fcn_file_map_type private_file_map = ci.private_file_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1955 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1956 if (! private_file_map.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1957 private_fcn_map[full_dir_name] = private_file_map; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1958 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1959 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1960 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1961 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1962 load_path::package_info::move_fcn_map (const std::string& dir_name, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1963 const string_vector& fcn_files, bool at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1964 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1965 octave_idx_type len = fcn_files.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1966 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1967 for (octave_idx_type k = 0; k < len; k++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1968 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1969 std::string fname = fcn_files[k]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1970 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1971 std::string ext; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1972 std::string base = fname; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1973 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1974 size_t pos = fname.rfind ('.'); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1975 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1976 if (pos != std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1977 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1978 base = fname.substr (0, pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1979 ext = fname.substr (pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1980 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1981 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1982 file_info_list_type& file_info_list = fcn_map[base]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1983 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1984 if (file_info_list.size () == 1) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1985 continue; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1986 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1987 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1988 for (auto fi_it = file_info_list.begin (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1989 fi_it != file_info_list.end (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1990 fi_it++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1991 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1992 if (fi_it->dir_name == dir_name) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1993 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1994 file_info fi_tmp = *fi_it; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1995 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1996 file_info_list.erase (fi_it); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1997 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1998 if (at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
1999 file_info_list.push_back (fi_tmp); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2000 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2001 file_info_list.push_front (fi_tmp); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2002 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2003 break; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2004 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2005 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2006 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2007 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2008 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2009 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2010 void |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
2011 load_path::package_info::move_method_map (const std::string& dir_name, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
2012 bool at_end) |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2013 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2014 for (auto& cls_fnmap : method_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2015 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2016 std::string class_name = cls_fnmap.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2017 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2018 fcn_map_type& fn_map = cls_fnmap.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2019 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2020 std::string full_dir_name |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
2021 = sys::file_ops::concat (dir_name, '@' + class_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2022 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2023 for (auto& nm_filst : fn_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2024 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2025 file_info_list_type& file_info_list = nm_filst.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2026 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2027 if (file_info_list.size () == 1) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2028 continue; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2029 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2030 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2031 for (auto fi_it = file_info_list.begin (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2032 fi_it != file_info_list.end (); fi_it++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2033 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2034 if (fi_it->dir_name == full_dir_name) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2035 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2036 file_info fi_tmp = *fi_it; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2037 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2038 file_info_list.erase (fi_it); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2039 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2040 if (at_end) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2041 file_info_list.push_back (fi_tmp); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2042 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2043 file_info_list.push_front (fi_tmp); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2044 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2045 break; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2046 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2047 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2048 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2049 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2050 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2051 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2052 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2053 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2054 load_path::package_info::remove_fcn_map (const std::string& dir, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2055 const string_vector& fcn_files) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2056 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2057 octave_idx_type len = fcn_files.numel (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2058 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2059 for (octave_idx_type k = 0; k < len; k++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2060 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2061 std::string fname = fcn_files[k]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2062 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2063 std::string ext; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2064 std::string base = fname; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2065 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2066 size_t pos = fname.rfind ('.'); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2067 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2068 if (pos != std::string::npos) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2069 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2070 base = fname.substr (0, pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2071 ext = fname.substr (pos); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2072 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2073 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2074 file_info_list_type& file_info_list = fcn_map[base]; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2075 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2076 for (auto fi_it = file_info_list.begin (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2077 fi_it != file_info_list.end (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2078 fi_it++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2079 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2080 if (fi_it->dir_name == dir) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2081 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2082 file_info_list.erase (fi_it); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2083 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2084 if (file_info_list.empty ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2085 fcn_map.erase (fname); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2086 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2087 break; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2088 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2089 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2090 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2091 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2092 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2093 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2094 load_path::package_info::remove_private_fcn_map (const std::string& dir) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2095 { |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
2096 auto p = private_fcn_map.find (dir); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2097 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2098 if (p != private_fcn_map.end ()) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2099 private_fcn_map.erase (p); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2100 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2101 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2102 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2103 load_path::package_info::remove_method_map (const std::string& dir) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2104 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2105 for (auto& cls_fnmap : method_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2106 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2107 std::string class_name = cls_fnmap.first; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2108 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2109 fcn_map_type& fn_map = cls_fnmap.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2110 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2111 std::string full_dir_name |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
2112 = sys::file_ops::concat (dir, '@' + class_name); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2113 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2114 for (auto& nm_filst : fn_map) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2115 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2116 file_info_list_type& file_info_list = nm_filst.second; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2117 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2118 if (file_info_list.size () == 1) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2119 continue; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2120 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2121 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2122 for (auto fi_it = file_info_list.begin (); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2123 fi_it != file_info_list.end (); fi_it++) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2124 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2125 if (fi_it->dir_name == full_dir_name) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2126 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2127 file_info_list.erase (fi_it); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2128 // FIXME: if there are no other elements, we |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2129 // should remove this element of fn_map but calling |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2130 // erase here would invalidate the iterator fi_it. |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2131 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2132 break; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2133 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2134 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2135 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2136 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2137 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2138 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2139 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2140 bool |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2141 load_path::package_info::check_file_type (std::string& fname, int type, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2142 int possible_types, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2143 const std::string& fcn, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2144 const char *who) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2145 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2146 bool retval = false; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2147 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2148 if (type == load_path::OCT_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2149 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2150 if ((type & possible_types) == load_path::OCT_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2151 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2152 fname += ".oct"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2153 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2154 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2155 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2156 else if (type == load_path::M_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2157 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2158 if ((type & possible_types) == load_path::M_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2159 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2160 fname += ".m"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2161 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2162 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2163 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2164 else if (type == load_path::MEX_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2165 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2166 if ((type & possible_types) == load_path::MEX_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2167 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2168 fname += ".mex"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2169 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2170 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2171 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2172 else if (type == (load_path::M_FILE | load_path::OCT_FILE)) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2173 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2174 if (possible_types & load_path::OCT_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2175 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2176 fname += ".oct"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2177 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2178 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2179 else if (possible_types & load_path::M_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2180 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2181 fname += ".m"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2182 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2183 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2184 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2185 else if (type == (load_path::M_FILE | load_path::MEX_FILE)) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2186 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2187 if (possible_types & load_path::MEX_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2188 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2189 fname += ".mex"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2190 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2191 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2192 else if (possible_types & load_path::M_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2193 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2194 fname += ".m"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2195 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2196 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2197 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2198 else if (type == (load_path::OCT_FILE | load_path::MEX_FILE)) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2199 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2200 if (possible_types & load_path::OCT_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2201 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2202 fname += ".oct"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2203 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2204 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2205 else if (possible_types & load_path::MEX_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2206 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2207 fname += ".mex"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2208 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2209 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2210 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2211 else if (type == (load_path::M_FILE | load_path::OCT_FILE |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2212 | load_path::MEX_FILE)) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2213 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2214 if (possible_types & load_path::OCT_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2215 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2216 fname += ".oct"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2217 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2218 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2219 else if (possible_types & load_path::MEX_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2220 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2221 fname += ".mex"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2222 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2223 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2224 else if (possible_types & load_path::M_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2225 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2226 fname += ".m"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2227 retval = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2228 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2229 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2230 else |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2231 error ("%s: %s: invalid type code = %d", who, fcn.c_str (), type); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2232 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2233 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2234 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2235 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2236 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2237 load_path::package_info::print_types (std::ostream& os, int types) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2238 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2239 bool printed_type = false; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2240 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2241 if (types & load_path::OCT_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2242 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2243 os << "oct"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2244 printed_type = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2245 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2246 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2247 if (types & load_path::MEX_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2248 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2249 if (printed_type) |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
2250 os << '|'; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2251 os << "mex"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2252 printed_type = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2253 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2254 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2255 if (types & load_path::M_FILE) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2256 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2257 if (printed_type) |
23807
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
2258 os << '|'; |
336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents:
23803
diff
changeset
|
2259 os << 'm'; |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2260 printed_type = true; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2261 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2262 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2263 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2264 void |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2265 load_path::package_info::print_fcn_list (std::ostream& os, |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2266 const load_path::dir_info::fcn_file_map_type& lst) const |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2267 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2268 for (const auto& nm_typ : lst) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2269 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2270 os << " " << nm_typ.first << " ("; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2271 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2272 print_types (os, nm_typ.second); |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2273 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2274 os << ")\n"; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2275 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2276 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2277 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2278 std::string |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2279 genpath (const std::string& dirname, const string_vector& skip) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2280 { |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2281 std::string retval; |
27606
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2282 string_vector dirlist; |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2283 std::string msg; |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2284 |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2285 if (! sys::get_dirlist (dirname, dirlist, msg)) |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2286 return retval; |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2287 |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2288 retval = dirname; |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2289 |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2290 dirlist = dirlist.sort (false); |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2291 |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2292 octave_idx_type len = dirlist.numel (); |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2293 |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2294 for (octave_idx_type i = 0; i < len; i++) |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2295 { |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2296 std::string elt = dirlist[i]; |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2297 |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2298 bool skip_p = (elt == "." || elt == ".." || elt[0] == '@' |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2299 || elt[0] == '+'); |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2300 |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2301 if (! skip_p) |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2302 { |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2303 for (octave_idx_type j = 0; j < skip.numel (); j++) |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2304 { |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2305 skip_p = (elt == skip[j]); |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2306 if (skip_p) |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2307 break; |
41a7902b99d4
* load-path.cc: Fix indentation.
Markus Mützel <markus.muetzel@gmx.de>
parents:
27497
diff
changeset
|
2308 } |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2309 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2310 if (! skip_p) |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2311 { |
25516
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
2312 std::string nm = sys::file_ops::concat (dirname, elt); |
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
2313 |
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
2314 sys::file_stat fs (nm); |
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
2315 |
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
2316 if (fs && fs.is_dir ()) |
8945a6a6c0eb
Add Unicode support for getting directory listing in Windows (bug #49118).
Markus Mützel <markus.muetzel@gmx.de>
parents:
25460
diff
changeset
|
2317 retval += directory_path::path_sep_str () + genpath (nm, skip); |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2318 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2319 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2320 } |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2321 |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2322 return retval; |
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2323 } |
5832 | 2324 } |
2325 | |
2326 DEFUN (genpath, args, , | |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2327 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2328 @deftypefn {} {} genpath (@var{dir}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2329 @deftypefnx {} {} genpath (@var{dir}, @var{skip}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2330 Return a path constructed from @var{dir} and all its subdirectories. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2331 |
24513
e61e26d1ede9
doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents:
24425
diff
changeset
|
2332 The path does not include package directories (beginning with @samp{+}), |
e61e26d1ede9
doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents:
24425
diff
changeset
|
2333 old-style class directories (beginning with @samp{@@}), @file{private} |
e61e26d1ede9
doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents:
24425
diff
changeset
|
2334 directories, or any subdirectories of these types. |
e61e26d1ede9
doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents:
24425
diff
changeset
|
2335 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2336 If additional string parameters are given, the resulting path will exclude |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2337 directories with those names. |
24513
e61e26d1ede9
doc: Improve documentation for genpath().
Rik <rik@octave.org>
parents:
24425
diff
changeset
|
2338 @seealso{path, addpath} |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2339 @end deftypefn */) |
5832 | 2340 { |
20816
b16bcd7a2a33
Use int rather than octave_idx_type for nargin data type.
Rik <rik@octave.org>
parents:
20812
diff
changeset
|
2341 int nargin = args.length (); |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2342 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2343 if (nargin == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2344 print_usage (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2345 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2346 octave_value retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2347 |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2348 if (nargin == 1) |
5832 | 2349 { |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
2350 std::string dirname = args(0).xstring_value ("genpath: DIR must be a string"); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
2351 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2352 retval = octave::genpath (dirname); |
5832 | 2353 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2354 else |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2355 { |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
2356 std::string dirname = args(0).xstring_value ("genpath: all arguments must be strings"); |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2357 |
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2358 string_vector skip (nargin - 1); |
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2359 |
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2360 for (octave_idx_type i = 1; i < nargin; i++) |
20700
68e3a747ca02
rename octave_value value extractors that accept error message args
John W. Eaton <jwe@octave.org>
parents:
20581
diff
changeset
|
2361 skip[i-1] = args(i).xstring_value ("genpath: all arguments must be strings"); |
20581
fd0efcdb3718
use new string_value method to handle value extraction errors
John W. Eaton <jwe@octave.org>
parents:
20555
diff
changeset
|
2362 |
23445
8e310ef0fa97
move load_path class to octave namespace
John W. Eaton <jwe@octave.org>
parents:
23438
diff
changeset
|
2363 retval = octave::genpath (dirname, skip); |
10971
386aa01ca84c
genpath: accept additional arguments as names of directories to skip
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
10957
diff
changeset
|
2364 } |
5832 | 2365 |
2366 return retval; | |
2367 } | |
2368 | |
2369 DEFUN (rehash, , , | |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2370 doc: /* -*- texinfo -*- |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2371 @deftypefn {} {} rehash () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2372 Reinitialize Octave's load path directory cache. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2373 @end deftypefn */) |
5832 | 2374 { |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
2375 octave::rehash_internal (); |
5832 | 2376 |
21078
49852ff04747
maint: Remove unnecessary declarations of retval.
Rik <rik@octave.org>
parents:
21021
diff
changeset
|
2377 return ovl (); |
5832 | 2378 } |
2379 | |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2380 DEFMETHOD (command_line_path, interp, args, , |
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2381 doc: /* -*- texinfo -*- |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2382 @deftypefn {} {} command_line_path () |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2383 Return the command line path variable. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2384 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2385 @seealso{path, addpath, rmpath, genpath, pathdef, savepath, pathsep} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2386 @end deftypefn */) |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2387 { |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2388 if (! args.empty ()) |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2389 print_usage (); |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2390 |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2391 octave::load_path& lp = interp.get_load_path (); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2392 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2393 return ovl (lp.get_command_line_path ()); |
8586
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2394 } |
31ab3b83bc8a
savepath: Respect cmd-line and env paths.
Ben Abbott <bpabbott@mac.com>
parents:
8511
diff
changeset
|
2395 |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2396 DEFMETHOD (restoredefaultpath, interp, args, , |
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2397 doc: /* -*- texinfo -*- |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2398 @deftypefn {} {} restoredefaultpath () |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2399 Restore Octave's path to its initial state at startup. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2400 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2401 @seealso{path, addpath, rmpath, genpath, pathdef, savepath, pathsep} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2402 @end deftypefn */) |
7391 | 2403 { |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2404 if (! args.empty ()) |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2405 print_usage (); |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2406 |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2407 octave::load_path& lp = interp.get_load_path (); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2408 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2409 lp.initialize (true); |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2410 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2411 return ovl (lp.system_path ()); |
7391 | 2412 } |
2413 | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2414 // Return Octave's original default list of directories in which to |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2415 // search for function files. This corresponds to the path that |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2416 // exists prior to running the system's octaverc file or the user's |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2417 // ~/.octaverc file |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8746
diff
changeset
|
2418 |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2419 DEFMETHOD (__pathorig__, interp, , , |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
2420 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2421 @deftypefn {} {@var{val} =} __pathorig__ () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2422 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2423 @end deftypefn */) |
5832 | 2424 { |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2425 octave::load_path& lp = interp.get_load_path (); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2426 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2427 return ovl (lp.system_path ()); |
5832 | 2428 } |
2429 | |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2430 DEFMETHOD (path, interp, args, nargout, |
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2431 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2432 @deftypefn {} {} path () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2433 @deftypefnx {} {@var{str} =} path () |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2434 @deftypefnx {} {@var{str} =} path (@var{path1}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2435 Modify or display Octave's load path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2436 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2437 If @var{nargin} and @var{nargout} are zero, display the elements of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2438 Octave's load path in an easy to read format. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2439 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2440 If @var{nargin} is zero and nargout is greater than zero, return the |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2441 current load path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2442 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2443 If @var{nargin} is greater than zero, concatenate the arguments, |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2444 separating them with @code{pathsep}. Set the internal search path |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2445 to the result and return it. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2446 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2447 No checks are made for duplicate elements. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2448 @seealso{addpath, rmpath, genpath, pathdef, savepath, pathsep} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2449 @end deftypefn */) |
5832 | 2450 { |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2451 int nargin = args.length (); |
5832 | 2452 |
2453 string_vector argv = args.make_argv ("path"); | |
2454 | |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2455 octave::load_path& lp = interp.get_load_path (); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2456 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2457 if (nargin > 0) |
5832 | 2458 { |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2459 std::string path = argv[1]; |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2460 |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2461 for (int i = 2; i <= nargin; i++) |
21745
bf1121302404
use namespace for dir_path class
John W. Eaton <jwe@octave.org>
parents:
21743
diff
changeset
|
2462 path += octave::directory_path::path_sep_str () + argv[i]; |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2463 |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2464 lp.set (path, true); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2465 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
2466 octave::rehash_internal (); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2467 } |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2468 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2469 if (nargout > 0) |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2470 return ovl (lp.path ()); |
20817
3d551b2ae928
Use variable name nargin consistently in C++ code.
Rik <rik@octave.org>
parents:
20816
diff
changeset
|
2471 else if (nargin == 0 && nargout == 0) |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2472 { |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2473 octave_stdout << |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2474 "\nOctave's search path contains the following directories:\n\n"; |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2475 |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2476 string_vector dirs = lp.dirs (); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2477 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2478 dirs.list_in_columns (octave_stdout); |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2479 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
20535
diff
changeset
|
2480 octave_stdout << "\n"; |
5832 | 2481 } |
20820
eed8ec05f1c8
always return value from DEFUN functions
John W. Eaton <jwe@octave.org>
parents:
20817
diff
changeset
|
2482 |
21125
8f76684324b5
maint: change "return octave_value ()" to "return ovl ()".
Rik <rik@octave.org>
parents:
21078
diff
changeset
|
2483 return ovl (); |
5832 | 2484 } |
2485 | |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2486 DEFMETHOD (addpath, interp, args, nargout, |
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2487 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2488 @deftypefn {} {} addpath (@var{dir1}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2489 @deftypefnx {} {} addpath (@var{dir1}, @dots{}, @var{option}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2490 Add named directories to the function search path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2491 |
27834
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2492 If @var{option} is @qcode{"-begin"} or 0 (the default), prepend the directory |
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2493 name(s) to the current path. If @var{option} is @qcode{"-end"} or 1, append |
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2494 the directory name(s) to the current path. Directories added to the path must |
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2495 exist. |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2496 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2497 In addition to accepting individual directory arguments, lists of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2498 directory names separated by @code{pathsep} are also accepted. For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2499 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2500 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2501 addpath ("dir1:/dir2:~/dir3") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2502 @end example |
22387
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2503 |
27834
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2504 The newly added paths appear in the load path in the same order that they |
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2505 appear in the arguments of @code{addpath}. When extending the load path to |
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2506 the front, the last path in the list of arguments is added first. When |
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2507 extending the load path to the end, the first path in the list of arguments |
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2508 is added first. |
ef6378f8e420
Document order in which multiple directories are processed by addpath.
Philip Nienhuis <prnienhuis@users.sf.net>
parents:
27745
diff
changeset
|
2509 |
22387
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2510 For each directory that is added, and that was not already in the path, |
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2511 @code{addpath} checks for the existence of a file named @file{PKG_ADD} |
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2512 (note lack of .m extension) and runs it if it exists. |
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2513 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2514 @seealso{path, rmpath, genpath, pathdef, savepath, pathsep} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2515 @end deftypefn */) |
5832 | 2516 { |
21953
c46e2532d421
Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents:
21745
diff
changeset
|
2517 // Originally written by Bill Denney and Etienne Grossman. |
c46e2532d421
Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents:
21745
diff
changeset
|
2518 // Heavily modified and translated to C++ by jwe. |
5832 | 2519 |
2520 int nargin = args.length (); | |
2521 | |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2522 if (nargin == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2523 print_usage (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2524 |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2525 octave::load_path& lp = interp.get_load_path (); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2526 |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2527 octave_value retval; |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2528 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2529 if (nargout > 0) |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2530 retval = lp.path (); |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2531 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2532 bool append = false; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2533 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2534 octave_value option_arg = args(nargin-1); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2535 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2536 if (option_arg.is_string ()) |
5832 | 2537 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2538 std::string option = option_arg.string_value (); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2539 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2540 if (option == "-end") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2541 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2542 append = true; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2543 nargin--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2544 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2545 else if (option == "-begin") |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2546 nargin--; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2547 } |
23586
f6c5db0a02e7
maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents:
23519
diff
changeset
|
2548 else if (option_arg.isnumeric ()) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2549 { |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2550 int val = option_arg.xint_value ("addpath: OPTION must be '-begin'/0 or '-end'/1"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2551 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2552 if (val == 0) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2553 nargin--; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2554 else if (val == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2555 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2556 append = true; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2557 nargin--; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2558 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2559 else |
20831
35241c4b696c
eliminate return statements after calls to error
John W. Eaton <jwe@octave.org>
parents:
20820
diff
changeset
|
2560 error ("addpath: OPTION must be '-begin'/0 or '-end'/1"); |
5832 | 2561 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2562 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2563 bool need_to_update = false; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2564 |
21953
c46e2532d421
Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents:
21745
diff
changeset
|
2565 octave_value_list arglist (args.slice (0, nargin)); |
c46e2532d421
Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents:
21745
diff
changeset
|
2566 if (! append) |
c46e2532d421
Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents:
21745
diff
changeset
|
2567 arglist.reverse (); |
c46e2532d421
Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents:
21745
diff
changeset
|
2568 |
c46e2532d421
Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents:
21745
diff
changeset
|
2569 for (int i = 0; i < arglist.length (); i++) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2570 { |
21953
c46e2532d421
Add directories through addpath in the correct order (bug #48247).
Rik <rik@octave.org>
parents:
21745
diff
changeset
|
2571 std::string arg = arglist(i).xstring_value ("addpath: all arguments must be strings"); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2572 |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
2573 std::list<std::string> dir_elts = octave::split_path (arg); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2574 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2575 if (! append) |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2576 std::reverse (dir_elts.begin (), dir_elts.end ()); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2577 |
22862
e365e87371a3
maint: Use C++ range feature to simplify some for loops in libinterp/corefcn.
Rik <rik@octave.org>
parents:
22755
diff
changeset
|
2578 for (auto dir : dir_elts) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2579 { |
21992
03c692adf563
maint: strip trailing whitespace from files.
John W. Eaton <jwe@octave.org>
parents:
21966
diff
changeset
|
2580 // Remove duplicate directory separators |
25337
3ff9192b676e
use auto keyword to declare iterator variables where possible
John W. Eaton <jwe@octave.org>
parents:
25103
diff
changeset
|
2581 auto it_start = dir.begin (); |
24424
ceae837bc9ea
Fix addpath for UNC paths on Windows (bug #51268).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23219
diff
changeset
|
2582 #if defined (OCTAVE_HAVE_WINDOWS_FILESYSTEM) |
ceae837bc9ea
Fix addpath for UNC paths on Windows (bug #51268).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23219
diff
changeset
|
2583 // In Windows, start check at second character (for UNC paths). |
ceae837bc9ea
Fix addpath for UNC paths on Windows (bug #51268).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23219
diff
changeset
|
2584 it_start++; |
ceae837bc9ea
Fix addpath for UNC paths on Windows (bug #51268).
Markus Mützel <markus.muetzel@gmx.de>
parents:
23219
diff
changeset
|
2585 #endif |
25951 | 2586 dir.erase (std::unique |
2587 (it_start, dir.end (), | |
2588 [] (char l, char r) | |
2589 { | |
2590 return l == r && octave::sys::file_ops::is_dir_sep (l); | |
2591 }), | |
21956
d5a58720459d
addpath: Remove duplicate directory separators before adding path.
Rik <rik@octave.org>
parents:
21953
diff
changeset
|
2592 dir.end ()); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2593 |
23994
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2594 auto pos = dir.find_last_of (octave::sys::file_ops::dir_sep_chars ()); |
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2595 if (pos == std::string::npos) |
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2596 { |
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2597 if (! dir.empty () && dir[0] == '+') |
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2598 warning_with_id ("Octave:addpath-pkg", |
27497
5a0543de1e47
Add canonical path when using addpath (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27474
diff
changeset
|
2599 "addpath: package directories should not be " |
5a0543de1e47
Add canonical path when using addpath (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27474
diff
changeset
|
2600 "added to path: %s\n", dir.c_str ()); |
23994
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2601 } |
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2602 else |
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2603 { |
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2604 if (pos + 1 < dir.length () && dir[pos+1] == '+') |
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2605 warning_with_id ("Octave:addpath-pkg", |
27497
5a0543de1e47
Add canonical path when using addpath (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27474
diff
changeset
|
2606 "addpath: package directories should not be " |
5a0543de1e47
Add canonical path when using addpath (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27474
diff
changeset
|
2607 "added to path: %s\n", dir.c_str ()); |
23994
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2608 } |
8785b3717140
Issue a warning if addpath() called for a +pkg directory (bug #45410).
Rik <rik@octave.org>
parents:
23970
diff
changeset
|
2609 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2610 if (append) |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2611 lp.append (dir, true); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2612 else |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2613 lp.prepend (dir, true); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2614 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2615 need_to_update = true; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2616 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2617 } |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2618 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2619 if (need_to_update) |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
2620 octave::rehash_internal (); |
5832 | 2621 |
2622 return retval; | |
2623 } | |
2624 | |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2625 DEFMETHOD (rmpath, interp, args, nargout, |
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2626 doc: /* -*- texinfo -*- |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2627 @deftypefn {} {} rmpath (@var{dir1}, @dots{}) |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2628 Remove @var{dir1}, @dots{} from the current function search path. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2629 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2630 In addition to accepting individual directory arguments, lists of |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2631 directory names separated by @code{pathsep} are also accepted. For example: |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2632 |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2633 @example |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2634 rmpath ("dir1:/dir2:~/dir3") |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2635 @end example |
22387
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2636 |
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2637 For each directory that is removed, @code{rmpath} checks for the |
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2638 existence of a file named @file{PKG_DEL} (note lack of .m extension) |
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2639 and runs it if it exists. |
4e97eaf021e4
doc: add note about PKG_ADD/PKG_DEL to addpath and rmpath (bug #41885)
Julien Bect <julien.bect@supelec.fr>
parents:
22327
diff
changeset
|
2640 |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2641 @seealso{path, addpath, genpath, pathdef, savepath, pathsep} |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2642 @end deftypefn */) |
5832 | 2643 { |
20812
d9ca869ca124
maint: Clean-up more instances of print_usage().
Rik <rik@octave.org>
parents:
20803
diff
changeset
|
2644 // Originally written by Etienne Grossmann. Heavily modified and translated |
5832 | 2645 // to C++ by jwe. |
2646 | |
20939
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2647 int nargin = args.length (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2648 |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2649 if (nargin == 0) |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2650 print_usage (); |
b17fda023ca6
maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents:
20853
diff
changeset
|
2651 |
5832 | 2652 octave_value retval; |
2653 | |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2654 octave::load_path& lp = interp.get_load_path (); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2655 |
5832 | 2656 if (nargout > 0) |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2657 retval = lp.path (); |
5832 | 2658 |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2659 bool need_to_update = false; |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2660 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2661 for (int i = 0; i < nargin; i++) |
5832 | 2662 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2663 std::string arg = args(i).xstring_value ("rmpath: all arguments must be strings"); |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
2664 std::list<std::string> dir_elts = octave::split_path (arg); |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2665 |
27609
51d26dd80828
Use canonical paths in list of load paths (bug #56267).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27607
diff
changeset
|
2666 for (const auto dir : dir_elts) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2667 { |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2668 //dir = regexprep (dir_elts{j}, '//+', "/"); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2669 //dir = regexprep (dir, '/$', ""); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2670 |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2671 if (! lp.remove (dir)) |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2672 warning ("rmpath: %s: not found", dir.c_str ()); |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2673 else |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2674 need_to_update = true; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10250
diff
changeset
|
2675 } |
5832 | 2676 } |
20803
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2677 |
c22206c1a88f
eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents:
20770
diff
changeset
|
2678 if (need_to_update) |
27101
097774bed4ed
move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26970
diff
changeset
|
2679 octave::rehash_internal (); |
5832 | 2680 |
2681 return retval; | |
2682 } | |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2683 |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2684 DEFMETHOD (__dump_load_path__, interp, , , |
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2685 doc: /* -*- texinfo -*- |
22299
9fc91bb2aec3
doc: grammarcheck documentation for 4.2 release.
Rik <rik@octave.org>
parents:
22094
diff
changeset
|
2686 @deftypefn {} {} __dump_load_path__ () |
21966
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2687 Undocumented internal function. |
112b20240c87
move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents:
21956
diff
changeset
|
2688 @end deftypefn */) |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2689 { |
23519
4fe410bd918d
use DEFMETHOD for some built-in functions
John W. Eaton <jwe@octave.org>
parents:
23445
diff
changeset
|
2690 octave::load_path& lp = interp.get_load_path (); |
23438
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2691 |
d24d01273bd0
eliminate load-path singleton
John W. Eaton <jwe@octave.org>
parents:
23418
diff
changeset
|
2692 lp.display (octave_stdout); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2693 |
20941
a4f5da7c5463
maint: Replace "octave_value_list ()" with "ovl ()".
Rik <rik@octave.org>
parents:
20939
diff
changeset
|
2694 return ovl (); |
16676
7368654f302f
Initial support for (classdef) packages.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
16567
diff
changeset
|
2695 } |