#ifndef _DISKOBJECT_H_
#define _DISKOBJECT_H_
/*  Project Biblio-Tec

	 SUBSYSTEM:    TEC30r.dll Library (TecLib)
	 FILE:         diskobj.h
	 AUTHOR:       Alcindo Ferreira Filho, based on CDiskObject
                  published by Johan Rosengren, Abstrakt Mekanik
                  AB, on CodeProject site, for beeing used on MFC.

	 OVERVIEW:
	 ALFFDiskObject Class definition, the class for handling any
    disk directory or file operations. It hides S.O. API.

    COPYRIGHT:    © 2005
                  Alcindo Ferreira Filho
                  <alcindo@inttec.com.br>

    LICENSE:      Biblio-Tec license (BiblTec.txt)
*/

// This class is available only for WIN32 targets
#ifdef _WIN32

#define EF_ONLY_FILENAMES	0
#define EF_FULLY_QUALIFIED	1

#include "alffobj.h"
#include <owl\owlall.h>

class _TECLIBCLASS ALFFDiskObject : public ALFFObject
{
public:
	// ctor(s)
	ALFFDiskObject();
	ALFFDiskObject( TWindow* feedbackWindow );

   char far* GetClassName() {return "ALFFDiskObject";}

	// dtor
	~ALFFDiskObject();

	// - - -
	// Operations

   // Application
   BOOL GetApplicationDirectory(string& directory);
   
	// Files

	BOOL FileExists( const string& file );
	BOOL CreateFile( const string& file );
	BOOL CopyFile( const string& sourceFile, const string& destDirectory );
	BOOL RemoveFile( const string& sourceFile );

	BOOL CopyFiles( const string& sourceDirectory, const string& destDirectory );
	BOOL CopyFiles( TStringArray& files, const string& destDirectory );

	void	QualifyFile( string& str );

	// Directories

   void	QualifyPath( string& str );

	BOOL CreateDirectory( const string& directory );
	BOOL CopyDirectory( const string& sourceDirectory, const string& destDirectory );
	BOOL EmptyDirectory( const string& directory );
	BOOL RemoveDirectory( const string& directory );

	BOOL CopyDirectories( const string& sourceDirectory, const string& destDirectory );
	BOOL EmptyDirectories( const string& directory );
	BOOL RemoveDirectories( const string& directory );

	BOOL EnumFilesInDirectoryWithFilter( const string& filter, const string& sourceDirectory, TStringArray& files, int mode = EF_ONLY_FILENAMES );
	BOOL EnumAllDirectories( const string& sourceDirectory, TStringArray& directories );
	BOOL EnumDirectories( const string& sourceDirectory, TStringArray& directories );
	BOOL EnumFilesInDirectory( const string& sourceDirectory, TStringArray& files, int mode = EF_ONLY_FILENAMES );
	BOOL EnumAllFiles( const string& sourceDirectory, TStringArray& files );
	BOOL EnumAllFilesWithFilter( const string& filter, const string& sourceDirectory, TStringArray& files );

	// Error handling
	string GetErrorMessage();	

private:
	// Error handling
	string m_errorMessage;

	void	ClearError();
	void	SetInternalErrorMessage();
	void	SetSystemErrorMessage( int error, const string& elements);

	// Helpers

	TWindow*	m_feedbackWindow;
	string GetFileName( const string& str );
	string GetDirectoryName( const string& str );

};

#endif  // _WIN32

#endif // _DISKOBJECT_H_
