GNU Octave
4.4.1
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-2018 John W. Eaton
4
5
This file is part of Octave.
6
7
Octave is free software: you can redistribute it and/or modify it
8
under the terms of the GNU General Public License as published by
9
the Free Software Foundation, either version 3 of the License, or
10
(at your option) any later version.
11
12
Octave is distributed in the hope that it will be useful, but
13
WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with Octave; see the file COPYING. If not, see
19
<https://www.gnu.org/licenses/>.
20
21
*/
22
23
#if ! defined (octave_dir_ops_h)
24
#define octave_dir_ops_h 1
25
26
#include "octave-config.h"
27
28
#include <string>
29
30
#include "
str-vec.h
"
31
32
namespace
octave
33
{
34
namespace
sys
35
{
36
class
37
OCTAVE_API
38
dir_entry
39
{
40
public
:
41
42
dir_entry
(
const
std::string
& n =
""
)
43
:
name
(n), dir (nullptr), fail (
false
), errmsg ()
44
{
45
if
(!
name
.empty ())
46
open ();
47
}
48
49
dir_entry
(
const
dir_entry
&
d
)
50
:
name
(
d
.
name
), dir (
d
.dir), fail (
d
.fail), errmsg (
d
.errmsg) { }
51
52
dir_entry
& operator = (
const
dir_entry
&
d
)
53
{
54
if
(
this
!= &
d
)
55
{
56
name
=
d
.name;
57
dir =
d
.dir;
58
fail =
d
.fail;
59
errmsg =
d
.errmsg;
60
}
61
62
return
*
this
;
63
}
64
65
~dir_entry
(
void
) { close (); }
66
67
bool
open (
const
std::string
& =
""
);
68
69
string_vector
read (
void
);
70
71
bool
close (
void
);
72
73
bool
ok
(
void
)
const
{
return
dir && ! fail; }
74
75
operator
bool
()
const
{
return
ok (); }
76
77
std::string
error
(
void
)
const
{
return
ok () ?
""
: errmsg; }
78
79
static
unsigned
int
max_name_length (
void
);
80
81
private
:
82
83
// Name of the directory.
84
std::string
name
;
85
86
// A pointer to the contents of the directory. We use void here to
87
// avoid possible conflicts with the way some systems declare the
88
// type DIR.
89
void
*
dir
;
90
91
// TRUE means the open for this directory failed.
92
bool
fail
;
93
94
// If a failure occurs, this contains the system error text.
95
std::string
errmsg
;
96
};
97
}
98
}
99
100
#if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
101
102
OCTAVE_DEPRECATED (4.2,
"use 'octave::sys::dir_entry' instead"
)
103
typedef
octave
::sys::dir_entry dir_entry;
104
105
#endif
106
107
#endif
octave
Definition:
aepbalance.cc:44
octave::sys::dir_entry::dir_entry
dir_entry(const std::string &n="")
Definition:
dir-ops.h:42
octave::sys::dir_entry::dir
void * dir
Definition:
dir-ops.h:89
str-vec.h
octave::sys::dir_entry
Definition:
dir-ops.h:36
d
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
Definition:
lo-slatec-proto.h:55
name
nd deftypefn *std::string name
Definition:
sysdep.cc:647
octave::sys::dir_entry::fail
bool fail
Definition:
dir-ops.h:92
octave::sys::dir_entry::ok
bool ok(void) const
Definition:
dir-ops.h:73
false
is false
Definition:
cellfun.cc:400
octave::sys::dir_entry::dir_entry
dir_entry(const dir_entry &d)
Definition:
dir-ops.h:49
octave::sys::dir_entry::~dir_entry
~dir_entry(void)
Definition:
dir-ops.h:65
octave::sys::dir_entry::errmsg
std::string errmsg
Definition:
dir-ops.h:95
bool
octave::sys::dir_entry::error
std::string error(void) const
Definition:
dir-ops.h:77
string
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition:
utils.cc:888
octave::sys::dir_entry::name
std::string name
Definition:
dir-ops.h:84
string_vector
Definition:
str-vec.h:34
liboctave
system
dir-ops.h
Generated on Sat Sep 1 2018 14:01:46 for GNU Octave by
1.8.14