GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
dir-ops.h
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 (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 (0), fail (false), errmsg ()
44  {
45  if (! name.empty ())
46  open ();
47  }
48 
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.
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.
96  };
97  }
98 }
99 
100 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS)
101 
102 OCTAVE_DEPRECATED ("use 'octave::sys::dir_entry' instead")
103 typedef octave::sys::dir_entry dir_entry;
104 
105 #endif
106 
107 #endif
Octave interface to the compression and uncompression libraries.
Definition: aepbalance.cc:47
dir_entry(const std::string &n="")
Definition: dir-ops.h:42
void * dir
Definition: dir-ops.h:89
Definition: dir-ops.h:36
bool ok(void) const
Definition: dir-ops.h:73
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
bool fail
Definition: dir-ops.h:92
is false
Definition: cellfun.cc:398
dir_entry(const dir_entry &d)
Definition: dir-ops.h:49
bool empty(void) const
Definition: ovl.h:98
~dir_entry(void)
Definition: dir-ops.h:65
std::string errmsg
Definition: dir-ops.h:95
std::string error(void) const
Definition: dir-ops.h:77
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
std::string name
Definition: dir-ops.h:84