annotate liboctave/system/dir-ops.h @ 19697:4197fc428c7d

maint: Update copyright notices for 2015.
author John W. Eaton <jwe@octave.org>
date Wed, 11 Feb 2015 14:19:08 -0500
parents 49a5a4be04a1
children f7084eae3318
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
1 /*
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
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
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
4
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
6
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
10 option) any later version.
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
11
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
15 for more details.
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
16
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6108
diff changeset
19 <http://www.gnu.org/licenses/>.
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
20
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
21 */
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
22
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
23 #if !defined (octave_dir_ops_h)
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
24 #define octave_dir_ops_h 1
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
25
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
26 #include <string>
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
27
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
28 #include "str-vec.h"
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
29
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
30 class
6108
143b556ce725 [project @ 2006-10-27 01:45:54 by jwe]
jwe
parents: 5307
diff changeset
31 OCTAVE_API
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
32 dir_entry
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
33 {
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
34 public:
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
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 ()
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
38 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
39 if (! name.empty ())
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
40 open ();
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
41 }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
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
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
45
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
46 dir_entry& operator = (const dir_entry& d)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
47 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
48 if (this != &d)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
49 {
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
50 name = d.name;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
51 dir = d.dir;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
52 fail = d.fail;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
53 errmsg = d.errmsg;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
54 }
1929
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
55
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
56 return *this;
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
57 }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
58
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
59 ~dir_entry (void) { close (); }
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
60
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3145
diff changeset
61 bool open (const std::string& = std::string ());
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
62
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
63 string_vector read (void);
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
64
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
65 void close (void);
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
66
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
67 bool ok (void) const { return dir && ! fail; }
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
68
3145
0d640dc625c7 [project @ 1998-02-05 08:44:59 by jwe]
jwe
parents: 2847
diff changeset
69 operator bool () const { return ok (); }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
70
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3145
diff changeset
71 std::string error (void) const { return ok () ? std::string () : errmsg; }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
72
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
73 private:
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
74
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
75 // Name of the directory.
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3145
diff changeset
76 std::string name;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
77
1929
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
78 // A pointer to the contents of the directory. We use void here to
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
79 // avoid possible conflicts with the way some systems declare the
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
80 // type DIR.
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
81 void *dir;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
82
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
83 // TRUE means the open for this directory failed.
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
84 bool fail;
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
85
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
86 // If a failure occurs, this contains the system error text.
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3145
diff changeset
87 std::string errmsg;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
88 };
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
89
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
90 #endif