#ifndef __OOL_XFILE_H__
#define __OOL_XFILE_H__

/*===========================================================================*/
/* OOL ------------------- the Open Object Library ------------- OS/2 Beta 1 */
/*===========================================================================*/
/*                              class: XFile                                 */
/*                       derived from: XIO                                   */
/*                        last update: 9/96                                  */
/*                      programmed by: Stefan von Brauk (sbrauk@gwdg.de)     */
/*===========================================================================*/

#include "xio.h"


#ifdef OOL_FOR_OS2_X86
   //modeForOpen, can be or-ed
   #define XFILE_FAIL_IF_NEW             OPEN_ACTION_FAIL_IF_NEW
   #define XFILE_CREATE_IF_NEW           OPEN_ACTION_CREATE_IF_NEW
   #define XFILE_REPLACE_EXISTING        OPEN_ACTION_REPLACE_IF_EXISTS
   #define XFILE_OPEN_EXISTING           OPEN_ACTION_OPEN_IF_EXISTS
   #define XFILE_FAIL_EXISTING           OPEN_ACTION_FAIL_IF_EXISTS

   //modeForAccess, can be or-ed
   #define XFILE_SHARE_DENYREAD          OPEN_SHARE_DENYREAD
   #define XFILE_SHARE_DENYWRITE         OPEN_SHARE_DENYWRITE
   #define XFILE_SHARE_DENYREADWRITE     OPEN_SHARE_DENYREADWRITE
   #define XFILE_SHARE_DENYNONE          OPEN_SHARE_DENYNONE
   #define XFILE_READONLY                OPEN_ACCESS_READONLY
   #define XFILE_WRITEONLY               OPEN_ACCESS_WRITEONLY
   #define XFILE_READWRITE               OPEN_ACCESS_READWRITE

#endif

class XFileInfo;


class _export_ XFile: public XIO
{
   public:
      XFile() { };
      ~XFile( ) { if(handle) Close(); }
      static ULONG Copy( const char* from, const char * to) { return DosCopy( (PSZ) from, (PSZ) to, 0); }
      static ULONG CreateDirectory( const char * path);
      static ULONG DeleteDirectory( const char * path);
      static BOOL IsDriveAvaible( const char );
      static ULONG Move( const char* from, const char * to) { return DosMove( (PSZ) from, (PSZ) to); }
      ULONG Open( const char * filename, const ULONG modeForOpen = OPEN_ACTION_FAIL_IF_NEW|OPEN_ACTION_OPEN_IF_EXISTS, const ULONG modeForAcces = XFILE_READWRITE | XFILE_SHARE_DENYREADWRITE, const ULONG size=0, const EAOP2 * ealist=NULL);
      static void GetCurrentDirectory( XString * buffer);
      static void GetCurrentDisk( char& buffer);
      LONG GetFileInfo( XFileInfo *);
      static BOOL Remove( const char* path) { return DosDelete((PSZ) path); }
      LONG ResetBuffer( void ) const { return DosResetBuffer(handle); }
      static BOOL SetCurrentDirectory( const char * path) { if( DosSetCurrentDir( (PSZ) path) != 0) return FALSE; else return TRUE; }
      static BOOL SetDefaultDisk( const char );
};


#endif
