00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_dir_ops_h)
00024 #define octave_dir_ops_h 1
00025
00026 #include <string>
00027
00028 #include "str-vec.h"
00029
00030 class
00031 dir_entry
00032 {
00033 public:
00034
00035 dir_entry (const std::string& n = std::string ()) : name (n), dir (0)
00036 {
00037 if (! name.empty ())
00038 open ();
00039 }
00040
00041 dir_entry (const dir_entry& d) { copy (d); }
00042
00043 dir_entry& operator = (const dir_entry& d)
00044 {
00045 if (this != &d)
00046 copy (d);
00047
00048 return *this;
00049 }
00050
00051 ~dir_entry (void) { close (); }
00052
00053 bool open (const std::string& = std::string ());
00054
00055 string_vector read (void);
00056
00057 void close (void);
00058
00059 bool ok (void) const { return dir && ! fail; }
00060
00061 operator bool () const { return ok (); }
00062
00063 std::string error (void) const { return ok () ? std::string () : errmsg; }
00064
00065 private:
00066
00067
00068 std::string name;
00069
00070
00071
00072
00073 void *dir;
00074
00075
00076 bool fail;
00077
00078
00079 std::string errmsg;
00080
00081 void copy (const dir_entry&);
00082 };
00083
00084 #endif
00085
00086
00087
00088
00089
00090