annotate liboctave/system/dir-ops.h @ 28857:43ad651cf5a0

eliminate unnecessary uses of octave:: namespace qualifier Affected files: graphics-init.cc, octave-qscintilla.cc, octave-qobject.h, qt-application.h, workspace-view.cc, call-stack.cc, dynamic-ld.cc, error.cc, error.h, event-manager.h, fcn-info.cc, ft-text-renderer.cc, gl-render.cc, gl2ps-print.cc, graphics-toolkit.cc, input.cc, load-path.cc, oct-hist.cc, oct-stream.cc, pager.cc, stack-frame.cc, symscope.cc, sysdep.cc, __ode15__.cc, cdef-class.cc, ov-fcn-handle.cc, ov.cc, ov.h, oct-parse.yy, pt-classdef.h, pt-eval.cc, Range.cc, Range.h, dir-ops.h, file-stat.cc, lo-sysdep.cc, lo-utils.cc, oct-glob.cc, and url-transfer.cc.
author John W. Eaton <jwe@octave.org>
date Mon, 05 Oct 2020 15:19:15 -0400
parents bd51beb6205e
children 7854d5752dd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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) 1996-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 ////////////////////////////////////////////////////////////////////////
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
25
20791
f7084eae3318 maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents: 19697
diff changeset
26 #if ! defined (octave_dir_ops_h)
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
27 #define octave_dir_ops_h 1
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
28
21244
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21017
diff changeset
29 #include "octave-config.h"
1473547f50f5 include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents: 21017
diff changeset
30
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
31 #include <string>
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
32
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
33 #include "str-vec.h"
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
34
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
35 namespace octave
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
36 {
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
37 namespace sys
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
38 {
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
39 class
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
40 OCTAVE_API
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
41 dir_entry
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
42 {
27703
12a53552db92 Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
43
12a53552db92 Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
44 // NOTE: This class cannot be used safely cross-platform (Windows) with
12a53552db92 Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
45 // non-ASCII characters in paths.
12a53552db92 Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
46 // Consider replacing the implementation using std::filesystem (C++ 17).
28857
43ad651cf5a0 eliminate unnecessary uses of octave:: namespace qualifier
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
47 // In the meantime, consider using sys::get_dirlist instead.
27703
12a53552db92 Use Unicode-aware functions when initializing load-path (bug #57235).
Markus Mützel <markus.muetzel@gmx.de>
parents: 26376
diff changeset
48
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
49 public:
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
50
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
51 dir_entry (const std::string& n = "")
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23615
diff changeset
52 : name (n), dir (nullptr), fail (false), errmsg ()
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
53 {
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
54 if (! name.empty ())
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
55 open ();
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
56 }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
57
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
58 dir_entry (const dir_entry& d)
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
59 : name (d.name), dir (d.dir), fail (d.fail), errmsg (d.errmsg) { }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
60
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
61 dir_entry& operator = (const dir_entry& d)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
62 {
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
63 if (this != &d)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
64 {
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
65 name = d.name;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
66 dir = d.dir;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
67 fail = d.fail;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
68 errmsg = d.errmsg;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
69 }
1929
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
70
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
71 return *this;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
72 }
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
73
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
74 ~dir_entry (void) { close (); }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
75
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
76 bool open (const std::string& = "");
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
77
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
78 string_vector read (void);
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
79
21926
24215a16f3b2 hide dirent.h header
John W. Eaton <jwe@octave.org>
parents: 21752
diff changeset
80 bool close (void);
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
81
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
82 bool ok (void) const { return dir && ! fail; }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
83
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
84 operator bool () const { return ok (); }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
85
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
86 std::string error (void) const { return ok () ? "" : errmsg; }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
87
21926
24215a16f3b2 hide dirent.h header
John W. Eaton <jwe@octave.org>
parents: 21752
diff changeset
88 static unsigned int max_name_length (void);
24215a16f3b2 hide dirent.h header
John W. Eaton <jwe@octave.org>
parents: 21752
diff changeset
89
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
90 private:
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
91
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
92 // Name of the directory.
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
93 std::string name;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
94
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
95 // A pointer to the contents of the directory. We use void here to
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
96 // avoid possible conflicts with the way some systems declare the
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
97 // type DIR.
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
98 void *dir;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
99
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
100 // TRUE means the open for this directory failed.
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
101 bool fail;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
102
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
103 // If a failure occurs, this contains the system error text.
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
104 std::string errmsg;
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
105 };
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
106 }
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
107 }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
108
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
109 #endif