/*  $Id: directory_scanner_win32.h,v 1.12 2004/01/07 18:36:53 sphair Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
**
*/

#ifndef header_directory_scanner_win32
#define header_directory_scanner_win32

#if _MSC_VER > 1000
#pragma once
#endif

#include "../Generic/directory_scanner_generic.h"

#include <io.h>
#include <direct.h>

class CL_DirectoryScanner_Win32: public CL_DirectoryScanner_Generic
{
//! Construction:
public:
	//: Construct initial directory scanner.
	CL_DirectoryScanner_Win32();

	//: Copy constructor.
	CL_DirectoryScanner_Win32(const CL_DirectoryScanner_Win32 &copy);

	virtual ~CL_DirectoryScanner_Win32();

//! Attributes:
public:
	//: Scan for files in a directory.
	virtual bool scan (const std::string &pathname);

	//: Scan for files matching a pattern.
	virtual bool scan (const std::string &pathname, const std::string &pattern);

	//: Returns the path of the directory being scanned.
	virtual std::string get_directory_path();

	//: Returns the size of the current found file.
	virtual int get_size();

	//: Returns the name of the current found file.
	virtual std::string get_name();
	
	//: Returns the name of the current found file, including the directory path.
	virtual std::string get_pathname();
	
	//: Returns true if filename is a directory.
	virtual bool is_directory();

	//: Returns true if filename is hidden.
	virtual bool is_hidden();

	//: Returns true if filename is readable.
	virtual bool is_readable();

	//: Returns true if filename is writable.
	virtual bool is_writable();

//! Operations:
public:
	//: Find next file in directory scan. Returns false if no more files was found.
	virtual bool next();

//! Implementation
private:
	std::string path_with_ending_slash(const std::string &path);

	WIN32_FIND_DATA fileinfo;

	HANDLE handle;

	bool first_next;

	std::string scan_exp;

	std::string directory_path;
};

#endif
