Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class 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.4 2004/03/13 16:46:27 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 #ifndef _WIN32_WINNT 
00027 #define _WIN32_WINNT 0x0400 
00028 #endif
00029 #include <windows.h>
00030 
00031 // Some versions of VC are missing this defines
00032 #ifndef ULONG_PTR
00033         typedef unsigned long ULONG_PTR;
00034 #endif
00035 
00036 #ifndef INVALID_SET_FILE_POINTER
00037         #define INVALID_SET_FILE_POINTER ((DWORD)-1) 
00038 #endif
00039 
00040 #ifdef _MSC_VER
00041         #pragma warning ( disable:4355 )
00042 #endif
00043 
00044 
00045 #include <wefts_coffee_base.h>
00046 #include <wefts_os_windows.h>
00047 
00048 namespace Wefts {
00049 
00088 class OSFileFuncWin : public OSFileFuncBase
00089 {
00090 protected:
00091    /* Unix file descriptor to the open field */
00092    HANDLE m_handle;
00093    HANDLE m_evtComplete;
00094    
00095    LARGE_INTEGER m_liSize;
00096    LARGE_INTEGER m_liPos;
00097    
00098    file_size_t internal_rw( void *buffer, const file_size_t len, bool rw, bool bFile );
00099    bool m_bOvlFiles;
00100 
00101 public:
00102    OSFileFuncWin( void *descriptor = 0 );
00103 
00104    ~OSFileFuncWin() { CloseHandle( m_evtComplete ); }
00105    
00106    virtual CffStatus open(
00107       std::string filespec,             // the file name
00108       OpenMode openMode = OM_RO,        // open mode
00109       LockMode lockMode = LM_SHARED   // the file lock mode
00110       );
00111 
00112    virtual CffStatus create(
00113       std::string filespec,               // the file name
00114       CreateMode cMode = CM_ARCHIVE,            // system atrribute
00115       LockMode lockMode = LM_EXCLUSIVE  // the file lock mode
00116       );
00117 
00118 
00122    inline virtual void getDescriptor( void *data ) const
00123    {
00124       *static_cast<HANDLE *>(data) = m_handle;
00125    }
00126 
00129    inline virtual void setDescriptor( void *data )
00130    {
00131       m_handle = *static_cast<HANDLE *>(data);
00132    }
00133 
00134    virtual file_size_t read( void *buffer, const file_size_t len ) {
00135       return OSFileFuncWin::internal_rw( buffer, len, true, true );
00136    }
00137 
00138    virtual file_size_t write( void *buffer, const file_size_t len )
00139    {
00140       return OSFileFuncWin::internal_rw( buffer, len, false, true );
00141    }
00142    
00143    virtual file_size_t seek(
00144       const file_size_t position,
00145       const SeekWhence swFrom= SW_FROM_BEGIN
00146       );
00147    
00148    virtual CffStatus close();
00149 
00151    inline virtual void setStdIn() { 
00152       m_handle = GetStdHandle( STD_INPUT_HANDLE ); 
00153       // Consoles are unoverlayable also in XP
00154       if ( GetFileType( m_handle ) == FILE_TYPE_CHAR )
00155          m_bOvlFiles = false;
00156    }
00157       
00159    inline virtual void setStdOut(){ 
00160       m_handle = GetStdHandle( STD_OUTPUT_HANDLE ); 
00161      // Consoles are unoverlayable also in XP
00162       if ( GetFileType( m_handle ) == FILE_TYPE_CHAR )
00163          m_bOvlFiles = false;
00164    }
00165 
00167    inline virtual void setStdErr(){ 
00168       m_handle = GetStdHandle( STD_ERROR_HANDLE );
00169       // Consoles are unoverlayable also in XP
00170       if ( GetFileType( m_handle ) == FILE_TYPE_CHAR )
00171          m_bOvlFiles = false;
00172    }
00173 };
00174 
00176 typedef OSFileFuncWin OSFileFunc;
00177 
00179 } // namespace
00180 
00181 #endif
00182 
00183 /* end of wefts_coffee_unix.h */

Generated on Sat Mar 13 21:05:43 2004 for Wefts by doxygen 1.3.5