GNU Octave
4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
liboctave
system
dir-ops.cc
Go to the documentation of this file.
1
/*
2
3
Copyright (C) 1996-2017 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 the
9
Free Software Foundation; either version 3 of the License, or (at your
10
option) any later version.
11
12
Octave is distributed in the hope that it will be useful, but WITHOUT
13
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15
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
<http://www.gnu.org/licenses/>.
20
21
*/
22
23
#if defined (HAVE_CONFIG_H)
24
# include "config.h"
25
#endif
26
27
#include <cerrno>
28
#include <cstdlib>
29
#include <cstring>
30
31
#include <list>
32
#include <string>
33
34
#include "
dirent-wrappers.h
"
35
36
#include "
dir-ops.h
"
37
#include "
file-ops.h
"
38
#include "
lo-error.h
"
39
#include "
lo-sysdep.h
"
40
#include "
str-vec.h
"
41
42
namespace
octave
43
{
44
namespace
sys
45
{
46
bool
47
dir_entry::open
(
const
std::string
& n)
48
{
49
if
(! n.empty ())
50
name
= n;
51
52
if
(!
name
.empty ())
53
{
54
close
();
55
56
std::string
fullname =
octave::sys::file_ops::tilde_expand
(
name
);
57
58
dir
=
octave_opendir_wrapper
(fullname.c_str ());
59
60
if
(!
dir
)
61
errmsg
= std::strerror (errno);
62
}
63
else
64
errmsg
=
"dir_entry::open: empty filename"
;
65
66
return
dir
!= 0;
67
}
68
69
string_vector
70
dir_entry::read
(
void
)
71
{
72
string_vector
retval
;
73
74
if
(
ok
())
75
{
76
std::list<std::string> dirlist;
77
78
char
*
fname
;
79
80
while
((fname =
octave_readdir_wrapper
(
dir
)))
81
dirlist.push_back (fname);
82
83
retval =
string_vector
(dirlist);
84
}
85
86
return
retval
;
87
}
88
89
bool
90
dir_entry::close
(
void
)
91
{
92
bool
retval
=
true
;
93
94
if
(
dir
)
95
{
96
retval = (
octave_closedir_wrapper
(
dir
) == 0);
97
98
dir
= 0;
99
}
100
101
return
retval
;
102
}
103
104
unsigned
int
105
dir_entry::max_name_length
(
void
)
106
{
107
return
octave_name_max_wrapper
();
108
}
109
}
110
}
file-ops.h
octave_name_max_wrapper
unsigned int octave_name_max_wrapper(void)
Definition:
dirent-wrappers.c:80
lo-sysdep.h
octave
Octave interface to the compression and uncompression libraries.
Definition:
aepbalance.cc:47
fname
fname
Definition:
load-save.cc:754
octave::sys::dir_entry::dir
void * dir
Definition:
dir-ops.h:89
str-vec.h
octave::sys::file_ops::tilde_expand
static std::string tilde_expand(const std::string &)
Definition:
file-ops.cc:301
octave::sys::dir_entry::ok
bool ok(void) const
Definition:
dir-ops.h:73
octave::sys::dir_entry::read
string_vector read(void)
Definition:
dir-ops.cc:70
octave_closedir_wrapper
int octave_closedir_wrapper(void *dir)
Definition:
dirent-wrappers.c:57
lo-error.h
retval
octave_value retval
Definition:
data.cc:6294
dir-ops.h
octave_opendir_wrapper
void * octave_opendir_wrapper(const char *dname)
Definition:
dirent-wrappers.c:37
octave::sys::dir_entry::errmsg
std::string errmsg
Definition:
dir-ops.h:95
octave::sys::dir_entry::open
bool open(const std::string &="")
Definition:
dir-ops.cc:47
octave_readdir_wrapper
char * octave_readdir_wrapper(void *dir)
Definition:
dirent-wrappers.c:43
dirent-wrappers.h
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:854
octave::sys::dir_entry::max_name_length
static unsigned int max_name_length(void)
Definition:
dir-ops.cc:105
octave::sys::dir_entry::name
std::string name
Definition:
dir-ops.h:84
string_vector
Definition:
str-vec.h:34
octave::sys::dir_entry::close
bool close(void)
Definition:
dir-ops.cc:90
Generated on Wed May 10 2017 15:43:00 for GNU Octave by
1.8.8