GNU Octave
11.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Loading...
Searching...
No Matches
dir-ops.h
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright (C) 1996-2026 The Octave Project Developers
4
//
5
// See the file COPYRIGHT.md in the top-level directory of this
6
// distribution or <https://octave.org/copyright/>.
7
//
8
// This file is part of Octave.
9
//
10
// Octave is free software: you can redistribute it and/or modify it
11
// under the terms of the GNU General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
14
//
15
// Octave is distributed in the hope that it will be useful, but
16
// WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU General Public License for more details.
19
//
20
// You should have received a copy of the GNU General Public License
21
// along with Octave; see the file COPYING. If not, see
22
// <https://www.gnu.org/licenses/>.
23
//
24
////////////////////////////////////////////////////////////////////////
25
26
#if ! defined (octave_dir_ops_h)
27
#define octave_dir_ops_h 1
28
29
#include "octave-config.h"
30
31
#include <string>
32
33
#include "
str-vec.h
"
34
35
OCTAVE_BEGIN_NAMESPACE
(octave)
36
OCTAVE_BEGIN_NAMESPACE
(sys)
37
38
class
OCTAVE_API
dir_entry
39
{
40
41
// NOTE: This class cannot be used safely cross-platform (Windows) with
42
// non-ASCII characters in paths.
43
// Consider replacing the implementation using std::filesystem (C++ 17).
44
// In the meantime, consider using sys::get_dirlist instead.
45
46
public
:
47
48
dir_entry
(
const
std::string& n =
""
)
49
: m_name (n), m_dir (nullptr), m_fail (false), m_errmsg ()
50
{
51
if
(! m_name.empty ())
52
open ();
53
}
54
55
dir_entry
(
const
dir_entry
&
d
)
56
: m_name (
d
.m_name), m_dir (
d
.m_dir), m_fail (
d
.m_fail),
57
m_errmsg (
d
.m_errmsg)
58
{ }
59
60
dir_entry
& operator = (
const
dir_entry
&
d
)
61
{
62
if
(
this
!= &
d
)
63
{
64
m_name =
d
.m_name;
65
m_dir =
d
.m_dir;
66
m_fail =
d
.m_fail;
67
m_errmsg =
d
.m_errmsg;
68
}
69
70
return
*
this
;
71
}
72
73
~dir_entry
() { close (); }
74
75
bool
open (
const
std::string& =
""
);
76
77
string_vector
read ();
78
79
bool
close ();
80
81
bool
ok
()
const
{
return
m_dir && ! m_fail; }
82
83
operator
bool
()
const
{
return
ok (); }
84
85
std::string
error
()
const
{
return
ok () ?
""
: m_errmsg; }
86
87
static
unsigned
int
max_name_length ();
88
89
private
:
90
91
// Name of the directory.
92
std::string m_name;
93
94
// A pointer to the contents of the directory. We use void here to
95
// avoid possible conflicts with the way some systems declare the
96
// type DIR.
97
void
*m_dir;
98
99
// TRUE means the open for this directory failed.
100
bool
m_fail;
101
102
// If a failure occurs, this contains the system error text.
103
std::string m_errmsg;
104
};
105
106
OCTAVE_END_NAMESPACE(sys)
107
OCTAVE_END_NAMESPACE(octave)
108
109
#endif
bool
dir_entry
Definition
dir-ops.h:39
dir_entry::~dir_entry
~dir_entry()
Definition
dir-ops.h:73
dir_entry::dir_entry
dir_entry(const std::string &n="")
Definition
dir-ops.h:48
dir_entry::ok
bool ok() const
Definition
dir-ops.h:81
dir_entry::error
std::string error() const
Definition
dir-ops.h:85
dir_entry::dir_entry
dir_entry(const dir_entry &d)
Definition
dir-ops.h:55
string_vector
Definition
str-vec.h:38
OCTAVE_BEGIN_NAMESPACE
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
OCTAVE_API
#define OCTAVE_API
Definition
main.in.cc:55
d
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
Definition
slatec-proto.h:39
str-vec.h
liboctave
system
dir-ops.h
Generated on Tue Feb 24 2026 04:49:07 for GNU Octave by
1.9.8