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

Generated on Tue Oct 5 14:57:00 2004 for Wefts by doxygen 1.3.7