Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

wefts_coffee_win.h

Go to the documentation of this file.
00001 /*
00002    wefts_coffee_win.h
00003    Windows implementation for cooperative file functions enlarged enviroment
00004 
00005    $Id: wefts_coffee_win.h,v 1.1 2003/12/20 23:34:09 jonnymind Exp $
00006 ---------------------------------------------
00007    Begin      : 2003-08-15 16:30
00008    Author     : Giancarlo Niccolai
00009 
00010    Last modified because:
00011 
00012 */
00013 
00014 /**************************************************************************
00015 *   This program is free software; you can redistribute it and/or modify  *
00016 *   it under the terms of the GNU Library General Public License as       *
00017 *   published by the Free Software Foundation; either version 2.1 of the  *
00018 *   License, or (at your option) any later version.                       *
00019 ***************************************************************************/
00020 
00021 
00022 #ifndef WT_COFFEE_UNIX_H
00023 #define WT_COFFEE_UNIX_H
00024 
00025 // From MSDN, required macro to compile QueueUserAPC
00026 #define _WIN32_WINNT 0x0400 
00027 #include <windows.h>
00028 
00029 #include <wefts_coffee_base.h>
00030 #include <wefts_os_windows.h>
00031 
00032 namespace Wefts {
00033 
00067 class OSFileFuncWin : public OSFileFuncBase
00068 {
00069 protected:
00070    /* Unix file descriptor to the open field */
00071    HANDLE m_handle;
00072    HANDLE m_evtComplete;
00073    
00074    LARGE_INTEGER m_liSize;
00075    LARGE_INTEGER m_liPos;
00076    
00077    file_size_t internal_rw( void *buffer, const file_size_t len, bool rw, bool bFile );
00078    bool m_bOvlFiles;
00079 
00080 public:
00081    OSFileFuncWin( void *descriptor = 0 );
00082 
00083    ~OSFileFuncWin() { CloseHandle( m_evtComplete ); }
00084    
00085    virtual CffStatus open(
00086       std::string filespec,             // the file name
00087       OpenMode openMode = OM_RO,        // open mode
00088       LockMode lockMode = LM_SHARED   // the file lock mode
00089       );
00090 
00091    virtual CffStatus create(
00092       std::string filespec,               // the file name
00093       CreateMode cMode = CM_ARCHIVE,            // system atrribute
00094       LockMode lockMode = LM_EXCLUSIVE  // the file lock mode
00095       );
00096 
00097 
00101    inline virtual void getDescriptor( void *data ) const
00102    {
00103       *static_cast<HANDLE *>(data) = m_handle;
00104    }
00105 
00108    inline virtual void setDescriptor( void *data )
00109    {
00110       m_handle = *static_cast<HANDLE *>(data);
00111    }
00112 
00113    virtual file_size_t read( void *buffer, const file_size_t len ) {
00114       return OSFileFuncWin::internal_rw( buffer, len, true, true );
00115    }
00116 
00117    virtual file_size_t write( void *buffer, const file_size_t len )
00118    {
00119       return OSFileFuncWin::internal_rw( buffer, len, false, true );
00120    }
00121    
00122    virtual file_size_t seek(
00123       const file_size_t position,
00124       const SeekWhence swFrom= SW_FROM_BEGIN
00125       );
00126    
00127    virtual CffStatus close();
00128 
00130    inline virtual void setStdIn() { 
00131       m_handle = GetStdHandle( STD_INPUT_HANDLE ); 
00132       // Consoles are unoverlayable also in XP
00133       if ( GetFileType( m_handle ) == FILE_TYPE_CHAR )
00134          m_bOvlFiles = false;
00135    }
00136       
00138    inline virtual void setStdOut(){ 
00139       m_handle = GetStdHandle( STD_OUTPUT_HANDLE ); 
00140      // Consoles are unoverlayable also in XP
00141       if ( GetFileType( m_handle ) == FILE_TYPE_CHAR )
00142          m_bOvlFiles = false;
00143    }
00144 
00146    inline virtual void setStdErr(){ 
00147       m_handle = GetStdHandle( STD_ERROR_HANDLE );
00148       // Consoles are unoverlayable also in XP
00149       if ( GetFileType( m_handle ) == FILE_TYPE_CHAR )
00150          m_bOvlFiles = false;
00151    }
00152 };
00153 
00155 typedef OSFileFuncWin OSFileFunc;
00156 
00158 } // namespace
00159 
00160 #endif
00161 
00162 /* end of wefts_coffee_unix.h */

Generated on Mon Dec 22 04:12:30 2003 for Wefts by doxygen1.2.18