Mercurial > octave
annotate liboctave/system/dir-ops.h @ 21752:949cb46e6bdb
use consistent style for deprecated function/class messages
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 20 May 2016 10:47:33 -0400 |
parents | 60212efcd9cb |
children | 24215a16f3b2 |
rev | line source |
---|---|
1782 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17769
diff
changeset
|
3 Copyright (C) 1996-2015 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 | |
20791
f7084eae3318
maint: Use Octave coding conventions for #if statements.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
23 #if ! defined (octave_dir_ops_h) |
1782 | 24 #define octave_dir_ops_h 1 |
25 | |
21244
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
26 #include "octave-config.h" |
1473547f50f5
include octave-config.h in public header files
John W. Eaton <jwe@octave.org>
parents:
21017
diff
changeset
|
27 |
1782 | 28 #include <string> |
29 | |
30 #include "str-vec.h" | |
31 | |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
32 namespace octave |
1782 | 33 { |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
34 namespace sys |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
35 { |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
36 class |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
37 OCTAVE_API |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
38 dir_entry |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
39 { |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
40 public: |
1782 | 41 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
42 dir_entry (const std::string& n = "") |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
43 : name (n), dir (0), fail (false), errmsg () |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
44 { |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
45 if (! name.empty ()) |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
46 open (); |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
47 } |
1782 | 48 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
49 dir_entry (const dir_entry& d) |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
50 : name (d.name), dir (d.dir), fail (d.fail), errmsg (d.errmsg) { } |
1782 | 51 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
52 dir_entry& operator = (const dir_entry& d) |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
53 { |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
54 if (this != &d) |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
55 { |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
56 name = d.name; |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
57 dir = d.dir; |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
58 fail = d.fail; |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
59 errmsg = d.errmsg; |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
60 } |
1929 | 61 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
62 return *this; |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
63 } |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
64 |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
65 ~dir_entry (void) { close (); } |
1782 | 66 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
67 bool open (const std::string& = ""); |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
68 |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
69 string_vector read (void); |
1782 | 70 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
71 void close (void); |
1782 | 72 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
73 bool ok (void) const { return dir && ! fail; } |
1782 | 74 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
75 operator bool () const { return ok (); } |
1782 | 76 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
77 std::string error (void) const { return ok () ? "" : errmsg; } |
1782 | 78 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
79 private: |
1782 | 80 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
81 // Name of the directory. |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
82 std::string name; |
1782 | 83 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
84 // A pointer to the contents of the directory. We use void here to |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
85 // avoid possible conflicts with the way some systems declare the |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
86 // type DIR. |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
87 void *dir; |
1782 | 88 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
89 // TRUE means the open for this directory failed. |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
90 bool fail; |
1782 | 91 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
92 // If a failure occurs, this contains the system error text. |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
93 std::string errmsg; |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
94 }; |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
95 } |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
96 } |
1782 | 97 |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
98 #if defined (OCTAVE_USE_DEPRECATED_FUNCTIONS) |
1782 | 99 |
21752
949cb46e6bdb
use consistent style for deprecated function/class messages
John W. Eaton <jwe@octave.org>
parents:
21735
diff
changeset
|
100 OCTAVE_DEPRECATED ("use 'octave::sys::dir_entry' instead") |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
101 typedef octave::sys::dir_entry dir_entry; |
1782 | 102 |
103 #endif | |
21735
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
104 |
60212efcd9cb
use namespace for dir_entry class
John W. Eaton <jwe@octave.org>
parents:
21244
diff
changeset
|
105 #endif |