annotate liboctave/dir-ops.h @ 5540:cda6a105ae9a before-ov-branch

[project @ 2005-11-17 05:47:13 by jwe]
author jwe
date Thu, 17 Nov 2005 05:47:13 +0000
parents 4c8a2e4e0717
children 143b556ce725
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
2847
8b262e771614 [project @ 1997-03-27 16:18:26 by jwe]
jwe
parents: 1993
diff changeset
3 Copyright (C) 1996, 1997 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
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
10 later version.
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
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 3504
diff changeset
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 3504
diff changeset
20 02110-1301, USA.
1782
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
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
24 #if !defined (octave_dir_ops_h)
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
25 #define octave_dir_ops_h 1
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
26
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
27 #include <string>
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
28
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
29 #include "str-vec.h"
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
30
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
31 class
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
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3145
diff changeset
36 dir_entry (const std::string& n = std::string ()) : name (n), dir (0)
1879
1b43d3c06c04 [project @ 1996-02-05 16:24:56 by jwe]
jwe
parents: 1782
diff changeset
37 {
1b43d3c06c04 [project @ 1996-02-05 16:24:56 by jwe]
jwe
parents: 1782
diff changeset
38 if (! name.empty ())
1b43d3c06c04 [project @ 1996-02-05 16:24:56 by jwe]
jwe
parents: 1782
diff changeset
39 open ();
1b43d3c06c04 [project @ 1996-02-05 16:24:56 by jwe]
jwe
parents: 1782
diff changeset
40 }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
41
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
42 dir_entry (const dir_entry& d) { copy (d); }
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
43
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
44 dir_entry& operator = (const dir_entry& d)
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
45 {
1929
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
46 if (this != &d)
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
47 copy (d);
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
48
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
49 return *this;
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
50 }
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
51
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
52 ~dir_entry (void) { close (); }
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
53
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3145
diff changeset
54 bool open (const std::string& = std::string ());
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
55
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
56 string_vector read (void);
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
57
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
58 void close (void);
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
59
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
60 bool ok (void) const { return dir && ! fail; }
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
61
3145
0d640dc625c7 [project @ 1998-02-05 08:44:59 by jwe]
jwe
parents: 2847
diff changeset
62 operator bool () const { return ok (); }
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
63
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3145
diff changeset
64 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
65
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
66 private:
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
67
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
68 // Name of the directory.
3504
5eef8a2294bd [project @ 2000-02-01 10:06:51 by jwe]
jwe
parents: 3145
diff changeset
69 std::string name;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
70
1929
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
71 // 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
72 // 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
73 // type DIR.
908f5b6676d7 [project @ 1996-02-11 22:05:08 by jwe]
jwe
parents: 1879
diff changeset
74 void *dir;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
75
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
76 // TRUE means the open for this directory failed.
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
77 bool fail;
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
78
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
79 // 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
80 std::string errmsg;
1782
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
81
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
82 void copy (const dir_entry&);
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
83 };
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
84
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
85 #endif
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
86
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
87 /*
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
88 ;;; Local Variables: ***
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
89 ;;; mode: C++ ***
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
90 ;;; End: ***
b17d014b6926 [project @ 1996-01-24 08:09:17 by jwe]
jwe
parents:
diff changeset
91 */