Mercurial > hg > octave-nkf
annotate liboctave/dir-ops.h @ 13504:13e3d60aff2d
Replaced Quint with OctaveGUI.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Sun, 17 Jul 2011 20:27:03 +0200 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
rev | line source |
---|---|
1782 | 1 /* |
2 | |
11523 | 3 Copyright (C) 1996-2011 John W. Eaton |
1782 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1782 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1782 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_dir_ops_h) | |
24 #define octave_dir_ops_h 1 | |
25 | |
26 #include <string> | |
27 | |
28 #include "str-vec.h" | |
29 | |
30 class | |
6108 | 31 OCTAVE_API |
1782 | 32 dir_entry |
33 { | |
34 public: | |
35 | |
11501
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
36 dir_entry (const std::string& n = std::string ()) |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
37 : name (n), dir (0), fail (false), errmsg () |
1879 | 38 { |
39 if (! name.empty ()) | |
40 open (); | |
41 } | |
1782 | 42 |
11501
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
43 dir_entry (const dir_entry& d) |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
44 : name (d.name), dir (d.dir), fail (d.fail), errmsg (d.errmsg) { } |
1782 | 45 |
46 dir_entry& operator = (const dir_entry& d) | |
47 { | |
1929 | 48 if (this != &d) |
11501
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
49 { |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
50 name = d.name; |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
51 dir = d.dir; |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
52 fail = d.fail; |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
53 errmsg = d.errmsg; |
331fcc41ca23
data member initialization fixes
John W. Eaton <jwe@octave.org>
parents:
10312
diff
changeset
|
54 } |
1929 | 55 |
1782 | 56 return *this; |
57 } | |
58 | |
59 ~dir_entry (void) { close (); } | |
60 | |
3504 | 61 bool open (const std::string& = std::string ()); |
1782 | 62 |
63 string_vector read (void); | |
64 | |
65 void close (void); | |
66 | |
67 bool ok (void) const { return dir && ! fail; } | |
68 | |
3145 | 69 operator bool () const { return ok (); } |
1782 | 70 |
3504 | 71 std::string error (void) const { return ok () ? std::string () : errmsg; } |
1782 | 72 |
73 private: | |
74 | |
75 // Name of the directory. | |
3504 | 76 std::string name; |
1782 | 77 |
1929 | 78 // A pointer to the contents of the directory. We use void here to |
79 // avoid possible conflicts with the way some systems declare the | |
80 // type DIR. | |
81 void *dir; | |
1782 | 82 |
83 // TRUE means the open for this directory failed. | |
84 bool fail; | |
85 | |
86 // If a failure occurs, this contains the system error text. | |
3504 | 87 std::string errmsg; |
1782 | 88 }; |
89 | |
90 #endif |