
#ifndef BROWSE_HH_
#define BROWSE_HH_

#if defined (WIN32)
#define OS_WINDOWS
#else
#define OS_UNIX
#endif

#if defined (OS_UNIX)
#include <sys/stat.h>
#include <dirent.h>
#elif defined (OS_WINDOWS)
#include <windows.h>
#else
#error Unknown OS
#endif

#include <list>
#include <string>

class	Browse
{
	public:
		/**///				Browse ();
		/**/				~Browse ();

		bool				Open (const std::string&);
		bool				Close ();

		const std::string&	GetFile () const;
		const std::string	GetFull () const;
		const std::string	GetPath () const;

		bool				IsDir (bool = true) const;

		bool				Next ();

	private:
#if defined (OS_UNIX)
		typedef std::pair<std::string, DIR*>			StackItem;
#elif defined (OS_WINDOWS)
		struct	StackItemData
		{
			WIN32_FIND_DATA	find_data;
			HANDLE			handle;
			bool			first;
		};

		typedef std::pair<std::string, StackItemData>	StackItem;
#endif
		typedef std::list<StackItem>	Stack;

		std::string			file;
		Stack				stack;
		bool				is_dir;
};

#endif
