GNU Octave
6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
dir-ops.cc
Go to the documentation of this file.
1
////////////////////////////////////////////////////////////////////////
2
//
3
// Copyright (C) 1996-2021 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 (HAVE_CONFIG_H)
27
# include "config.h"
28
#endif
29
30
#include <cerrno>
31
#include <cstdlib>
32
#include <cstring>
33
34
#include <list>
35
#include <string>
36
37
#include "
dirent-wrappers.h
"
38
39
#include "
dir-ops.h
"
40
#include "
file-ops.h
"
41
#include "
lo-error.h
"
42
#include "
lo-sysdep.h
"
43
#include "
str-vec.h
"
44
45
namespace
octave
46
{
47
namespace
sys
48
{
49
bool
50
dir_entry::open
(
const
std::string&
n
)
51
{
52
if
(!
n
.empty ())
53
name
=
n
;
54
55
if
(!
name
.empty ())
56
{
57
close
();
58
59
std::string fullname =
sys::file_ops::tilde_expand
(
name
);
60
61
dir
=
octave_opendir_wrapper
(fullname.c_str ());
62
63
if
(!
dir
)
64
errmsg
= std::strerror (errno);
65
}
66
else
67
errmsg
=
"dir_entry::open: empty filename"
;
68
69
return
dir
!=
nullptr
;
70
}
71
72
string_vector
73
dir_entry::read
(
void
)
74
{
75
string_vector
retval
;
76
77
if
(
ok
())
78
{
79
std::list<std::string> dirlist;
80
81
char
*fname;
82
83
while
((fname =
octave_readdir_wrapper
(
dir
)))
84
dirlist.push_back (fname);
85
86
retval
=
string_vector
(dirlist);
87
}
88
89
return
retval
;
90
}
91
92
bool
93
dir_entry::close
(
void
)
94
{
95
bool
retval
=
true
;
96
97
if
(
dir
)
98
{
99
retval
= (
octave_closedir_wrapper
(
dir
) == 0);
100
101
dir
=
nullptr
;
102
}
103
104
return
retval
;
105
}
106
107
unsigned
int
108
dir_entry::max_name_length
(
void
)
109
{
110
return
octave_name_max_wrapper
();
111
}
112
}
113
}
octave::sys::dir_entry::dir
void * dir
Definition:
dir-ops.h:98
octave::sys::dir_entry::close
bool close(void)
Definition:
dir-ops.cc:93
octave::sys::dir_entry::open
bool open(const std::string &="")
Definition:
dir-ops.cc:50
octave::sys::dir_entry::read
string_vector read(void)
Definition:
dir-ops.cc:73
octave::sys::dir_entry::errmsg
std::string errmsg
Definition:
dir-ops.h:104
octave::sys::dir_entry::name
std::string name
Definition:
dir-ops.h:93
octave::sys::dir_entry::max_name_length
static unsigned int max_name_length(void)
Definition:
dir-ops.cc:108
octave::sys::dir_entry::ok
bool ok(void) const
Definition:
dir-ops.h:82
string_vector
Definition:
str-vec.h:40
dir-ops.h
octave_name_max_wrapper
unsigned int octave_name_max_wrapper(void)
Definition:
dirent-wrappers.c:83
octave_readdir_wrapper
char * octave_readdir_wrapper(void *dir)
Definition:
dirent-wrappers.c:46
octave_opendir_wrapper
void * octave_opendir_wrapper(const char *dname)
Definition:
dirent-wrappers.c:40
octave_closedir_wrapper
int octave_closedir_wrapper(void *dir)
Definition:
dirent-wrappers.c:60
dirent-wrappers.h
file-ops.h
lo-error.h
lo-sysdep.h
n
octave_idx_type n
Definition:
mx-inlines.cc:753
octave::sys::file_ops::tilde_expand
std::string tilde_expand(const std::string &name)
Definition:
file-ops.cc:286
octave
Definition:
aepbalance.cc:41
retval
octave_value::octave_value(const Array< char > &chm, char type) return retval
Definition:
ov.cc:811
str-vec.h
liboctave
system
dir-ops.cc
Generated on Tue Apr 13 2021 15:27:51 for GNU Octave by
1.9.1