annotate liboctave/system/dir-ops.h @ 30564:796f54d4ddbf stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021. In all .txi and .texi files except gpl.txi and gpl.texi in the doc/liboctave and doc/interpreter directories, change the copyright to "Octave Project Developers", the same as used for other source files. Update copyright notices for 2022 (not done since 2019). For gpl.txi and gpl.texi, change the copyright notice to be "Free Software Foundation, Inc." and leave the date at 2007 only because this file only contains the text of the GPL, not anything created by the Octave Project Developers. Add Paul Thomas to contributors.in.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Dec 2021 18:22:40 -0500
parents dbbf3d44535d
children e88a07dec498
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30080
diff changeset
3 // Copyright (C) 1996-2022 The Octave Project Developers
27923
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 = "")
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
52 : m_name (n), m_dir (nullptr), m_fail (false), m_errmsg ()
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
53 {
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
54 if (! m_name.empty ())
22402
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)
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
59 : m_name (d.m_name), m_dir (d.m_dir), m_fail (d.m_fail),
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
60 m_errmsg (d.m_errmsg)
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
61 { }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
62
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
63 dir_entry& operator = (const dir_entry& d)
22402
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 if (this != &d)
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
66 {
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
67 m_name = d.m_name;
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
68 m_dir = d.m_dir;
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
69 m_fail = d.m_fail;
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
70 m_errmsg = d.m_errmsg;
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
71 }
1929
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
72
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
73 return *this;
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22323
diff changeset
74 }
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
75
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
76 ~dir_entry (void) { close (); }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
77
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
78 bool open (const std::string& = "");
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
79
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
80 string_vector read (void);
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
81
21926
24215a16f3b2 hide dirent.h header
John W. Eaton <jwe@octave.org>
parents: 21752
diff changeset
82 bool close (void);
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
83
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
84 bool ok (void) const { return m_dir && ! m_fail; }
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 operator bool () const { return ok (); }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
87
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
88 std::string error (void) const { return ok () ? "" : m_errmsg; }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
89
21926
24215a16f3b2 hide dirent.h header
John W. Eaton <jwe@octave.org>
parents: 21752
diff changeset
90 static unsigned int max_name_length (void);
24215a16f3b2 hide dirent.h header
John W. Eaton <jwe@octave.org>
parents: 21752
diff changeset
91
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
92 private:
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
93
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
94 // Name of the directory.
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
95 std::string m_name;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
96
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
97 // 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
98 // 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
99 // type DIR.
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
100 void *m_dir;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
101
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
102 // TRUE means the open for this directory failed.
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
103 bool m_fail;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
104
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
105 // If a failure occurs, this contains the system error text.
30080
dbbf3d44535d maint: use "m_" prefix for member variables in class dir_entry.
Rik <rik@octave.org>
parents: 29359
diff changeset
106 std::string m_errmsg;
21735
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
107 };
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
108 }
60212efcd9cb use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents: 21244
diff changeset
109 }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
110
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
111 #endif