Scopira 20080306

diriterator.h

00001 
00002 /*
00003  *  Copyright (c) 2003-2008    National Research Council
00004  *
00005  *  All rights reserved.
00006  *
00007  *  This material is confidential and proprietary information of
00008  *  National Research Council Canada ("Confidential Information").
00009  *  This Confidential Information may only be used and reproduced
00010  *  in accordance with the terms of the license agreement.
00011  *
00012  */
00013 
00014 #ifndef __INCLUDED__SCOPIRA_TOOL_DIRITERATOR_HPP__
00015 #define __INCLUDED__SCOPIRA_TOOL_DIRITERATOR_HPP__
00016 
00017 #include <scopira/tool/platform.h>
00018 #include <scopira/tool/export.h>
00019 
00020 #ifdef PLATFORM_win32
00021 #include <windows.h>
00022 #else
00023 #include <dirent.h>
00024 #endif
00025 
00026 #include <string>
00027 
00028 // THIS FILE HAS BEEN FULLY DOCUMENTED
00029 
00030 namespace scopira
00031 {
00032   namespace tool
00033   {
00034     class dir_iterator;
00035   }
00036 }
00037 
00055 class scopira::tool::dir_iterator
00056 {
00057   private:
00058     bool dm_failed;                  // currently failed?
00059 #ifdef PLATFORM_win32
00060     HANDLE dm_dir;
00061     WIN32_FIND_DATA dm_dirdata;
00062     bool dm_haveprime;
00063 #else
00064     DIR *dm_dir;                     // DIR handle
00065 #endif
00066 
00067   public:
00072     SCOPIRA_EXPORT dir_iterator(void);
00073     SCOPIRA_EXPORT ~dir_iterator();
00074 
00080     bool failed(void) const { return dm_failed; }
00081 
00089     SCOPIRA_EXPORT bool open(const std::string& dirname);
00099     SCOPIRA_EXPORT void close(void);
00100 
00112     SCOPIRA_EXPORT bool next(std::string& out);
00113 };
00114 
00115 #endif
00116