GNU Octave
7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
dir-ops.h
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright (C) 1996-2022 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
namespace
octave
36
{
37
namespace
sys
38
{
39
class
40
OCTAVE_API
41
dir_entry
42
{
43
44
// NOTE: This class cannot be used safely cross-platform (Windows) with
45
// non-ASCII characters in paths.
46
// Consider replacing the implementation using std::filesystem (C++ 17).
47
// In the meantime, consider using sys::get_dirlist instead.
48
49
public
:
50
51
dir_entry
(
const
std::string& n =
""
)
52
: m_name (n), m_dir (nullptr), m_fail (false), m_errmsg ()
53
{
54
if
(! m_name.empty ())
55
open ();
56
}
57
58
dir_entry
(
const
dir_entry
&
d
)
59
: m_name (
d
.m_name), m_dir (
d
.m_dir), m_fail (
d
.m_fail),
60
m_errmsg (
d
.m_errmsg)
61
{ }
62
63
dir_entry
& operator = (
const
dir_entry
&
d
)
64
{
65
if
(
this
!= &
d
)
66
{
67
m_name =
d
.m_name;
68
m_dir =
d
.m_dir;
69
m_fail =
d
.m_fail;
70
m_errmsg =
d
.m_errmsg;
71
}
72
73
return
*
this
;
74
}
75
76
~dir_entry
(
void
) { close (); }
77
78
bool
open (
const
std::string& =
""
);
79
80
string_vector
read (
void
);
81
82
bool
close (
void
);
83
84
bool
ok
(
void
)
const
{
return
m_dir && ! m_fail; }
85
86
operator
bool
()
const
{
return
ok (); }
87
88
std::string
error
(
void
)
const
{
return
ok () ?
""
: m_errmsg; }
89
90
static
unsigned
int
max_name_length (
void
);
91
92
private
:
93
94
// Name of the directory.
95
std::string
m_name
;
96
97
// A pointer to the contents of the directory. We use void here to
98
// avoid possible conflicts with the way some systems declare the
99
// type DIR.
100
void
*
m_dir
;
101
102
// TRUE means the open for this directory failed.
103
bool
m_fail
;
104
105
// If a failure occurs, this contains the system error text.
106
std::string
m_errmsg
;
107
};
108
}
109
}
110
111
#endif
bool
octave::sys::dir_entry
Definition:
dir-ops.h:42
octave::sys::dir_entry::m_errmsg
std::string m_errmsg
Definition:
dir-ops.h:106
octave::sys::dir_entry::dir_entry
dir_entry(const std::string &n="")
Definition:
dir-ops.h:51
octave::sys::dir_entry::m_name
std::string m_name
Definition:
dir-ops.h:95
octave::sys::dir_entry::m_fail
bool m_fail
Definition:
dir-ops.h:103
octave::sys::dir_entry::~dir_entry
~dir_entry(void)
Definition:
dir-ops.h:76
octave::sys::dir_entry::error
std::string error(void) const
Definition:
dir-ops.h:88
octave::sys::dir_entry::ok
bool ok(void) const
Definition:
dir-ops.h:84
octave::sys::dir_entry::dir_entry
dir_entry(const dir_entry &d)
Definition:
dir-ops.h:58
octave::sys::dir_entry::m_dir
void * m_dir
Definition:
dir-ops.h:100
string_vector
Definition:
str-vec.h:40
d
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
Definition:
lo-slatec-proto.h:39
OCTAVE_API
#define OCTAVE_API
Definition:
main.in.cc:55
octave
Definition:
idx-vector.cc:46
str-vec.h
liboctave
system
dir-ops.h
Generated on Sun Jun 26 2022 01:28:02 for GNU Octave by
1.9.4