00001 /* 00002 Copyright 2003 by Marc J. Rochkind. All rights reserved. 00003 May be copied only for purposes and under conditions described 00004 on the Web page www.basepath.com/aup/copyright.htm. 00005 00006 The Example Files are provided "as is," without any warranty; 00007 without even the implied warranty of merchantability or fitness 00008 for a particular purpose. The author and his publisher are not 00009 responsible for any damages, direct or incidental, resulting 00010 from the use or non-use of these Example Files. 00011 00012 The Example Files may contain defects, and some contain deliberate 00013 coding mistakes that were included for educational reasons. 00014 You are responsible for determining if and how the Example Files 00015 are to be used. 00016 00017 */ 00018 #ifndef _UXDIRSTREAM_HPP_ 00019 #define _UXDIRSTREAM_HPP_ 00020 00021 #include <dirent.h> 00022 00023 namespace Ux { 00024 00025 /** 00026 \ingroup Ux 00027 */ 00028 class DirStream : public Base { 00029 protected: 00030 DIR *dirstream; 00031 struct dirent *entry; 00032 00033 public: 00034 DirStream(void) 00035 : dirstream(NULL), entry(NULL) 00036 { } 00037 struct dirent *get_entry(void) 00038 { return entry; } 00039 const char *get_name(void) 00040 { return entry == NULL ? NULL : entry->d_name; } 00041 void alloc(const char *path = "/"); 00042 void free(void); 00043 size_t get_max_name(const char *path = "/"); 00044 00045 void open(const char *path); 00046 void open_alloc(const char *path); 00047 void close(void); 00048 bool read(void); 00049 void rewind(void); 00050 void seek(long loc); 00051 long tell(void); 00052 }; 00053 00054 } // namespace 00055 00056 #endif // _UXDIRSTREAM_HPP_