foobar2000 SDK  2015-08-03
Public Member Functions | Static Public Member Functions | Protected Attributes
file_win32_wrapper_overlapped_t< p_writeable >

#include <file_win32_wrapper.h>

+ Inheritance diagram for file_win32_wrapper_overlapped_t< p_writeable >:

Public Member Functions

 file_win32_wrapper_overlapped_t (HANDLE file)
 
 ~file_win32_wrapper_overlapped_t ()
 
bool can_seek ()
 
bool get_content_type (pfc::string_base &out)
 
t_filesize get_position (abort_callback &p_abort)
 
t_filesize get_size (abort_callback &p_abort)
 
t_filetimestamp get_timestamp (abort_callback &p_abort)
 
bool is_in_memory ()
 
bool is_remote ()
 
void on_idle (abort_callback &p_abort)
 
t_size read (void *p_buffer, t_size p_bytes, abort_callback &p_abort)
 
void reopen (abort_callback &p_abort)
 
void resize (t_filesize p_size, abort_callback &p_abort)
 
void seek (t_filesize p_position, abort_callback &p_abort)
 
void write (const void *p_buffer, t_size p_bytes, abort_callback &p_abort)
 

Static Public Member Functions

static file::ptr g_create_from_handle (HANDLE p_handle)
 
static file::ptr g_CreateFile (const char *p_path, DWORD p_access, DWORD p_sharemode, LPSECURITY_ATTRIBUTES p_security_attributes, DWORD p_createmode, DWORD p_flags, HANDLE p_template)
 

Protected Attributes

HANDLE m_event
 
HANDLE m_handle
 
t_filesize m_position
 

Detailed Description

template<bool p_writeable>
class file_win32_wrapper_overlapped_t< p_writeable >

Definition at line 154 of file file_win32_wrapper.h.

Constructor & Destructor Documentation

template<bool p_writeable>
file_win32_wrapper_overlapped_t< p_writeable >::file_win32_wrapper_overlapped_t ( HANDLE  file)
inline

Definition at line 156 of file file_win32_wrapper.h.

156  : m_handle(file), m_position() {
157  WIN32_OP( (m_event = CreateEvent(NULL, TRUE, FALSE, NULL)) != NULL );
158  }
HANDLE CreateEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, BOOL bManualReset, BOOL bInitialState, LPCTSTR lpName)
Definition: pp-winapi.h:8
template<bool p_writeable>
file_win32_wrapper_overlapped_t< p_writeable >::~file_win32_wrapper_overlapped_t ( )
inline

Definition at line 159 of file file_win32_wrapper.h.

Member Function Documentation

template<bool p_writeable>
bool file_win32_wrapper_overlapped_t< p_writeable >::can_seek ( )
inline

Definition at line 201 of file file_win32_wrapper.h.

201 {return true;}
template<bool p_writeable>
static file::ptr file_win32_wrapper_overlapped_t< p_writeable >::g_create_from_handle ( HANDLE  p_handle)
inlinestatic

Definition at line 232 of file file_win32_wrapper.h.

232  {
234  }
Template implementing reference-counting features of service_base. Intended for dynamic instantiation...
Definition: service_impl.h:4
template<bool p_writeable>
static file::ptr file_win32_wrapper_overlapped_t< p_writeable >::g_CreateFile ( const char *  p_path,
DWORD  p_access,
DWORD  p_sharemode,
LPSECURITY_ATTRIBUTES  p_security_attributes,
DWORD  p_createmode,
DWORD  p_flags,
HANDLE  p_template 
)
inlinestatic

Definition at line 218 of file file_win32_wrapper.h.

218  {
219  p_flags |= FILE_FLAG_OVERLAPPED;
220  SetLastError(NO_ERROR);
221  HANDLE handle = uCreateFile(p_path,p_access,p_sharemode,p_security_attributes,p_createmode,p_flags,p_template);
222  if (handle == INVALID_HANDLE_VALUE) {
223  const DWORD code = GetLastError();
224  if (p_access & GENERIC_WRITE) win32_file_write_failure(code, p_path);
225  else exception_io_from_win32(code);
226  }
227  try {
228  return g_create_from_handle(handle);
229  } catch(...) {CloseHandle(handle); throw;}
230  }
PFC_NORETURN void win32_file_write_failure(DWORD p_code, const char *path)
Definition: filesystem.cpp:765
PFC_NORETURN void exception_io_from_win32(DWORD p_code)
Definition: filesystem.cpp:773
HANDLE SHARED_EXPORT uCreateFile(const char *p_path, DWORD p_access, DWORD p_sharemode, LPSECURITY_ATTRIBUTES p_security_attributes, DWORD p_createmode, DWORD p_flags, HANDLE p_template)
typedef HANDLE(WINAPI *pPowerCreateRequest_t)(__in void *Context)
static file::ptr g_create_from_handle(HANDLE p_handle)
template<bool p_writeable>
bool file_win32_wrapper_overlapped_t< p_writeable >::get_content_type ( pfc::string_base out)
inline

Definition at line 202 of file file_win32_wrapper.h.

202 {return false;}
template<bool p_writeable>
t_filesize file_win32_wrapper_overlapped_t< p_writeable >::get_position ( abort_callback p_abort)
inline

Definition at line 176 of file file_win32_wrapper.h.

176  {
177  p_abort.check_e();
178  return m_position;
179  }
template<bool p_writeable>
t_filesize file_win32_wrapper_overlapped_t< p_writeable >::get_size ( abort_callback p_abort)
inline

Definition at line 171 of file file_win32_wrapper.h.

171  {
172  p_abort.check_e();
174  }
t_filesize get_size(HANDLE p_handle)
template<bool p_writeable>
t_filetimestamp file_win32_wrapper_overlapped_t< p_writeable >::get_timestamp ( abort_callback p_abort)
inline

Definition at line 206 of file file_win32_wrapper.h.

206  {
207  p_abort.check_e();
208  FlushFileBuffers(m_handle);
209  SetLastError(ERROR_SUCCESS);
210  t_filetimestamp temp;
211  if (!GetFileTime(m_handle,0,0,(FILETIME*)&temp)) exception_io_from_win32(GetLastError());
212  return temp;
213  }
PFC_NORETURN void exception_io_from_win32(DWORD p_code)
Definition: filesystem.cpp:773
t_uint64 t_filetimestamp
Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecon...
Definition: filesystem.h:12
template<bool p_writeable>
bool file_win32_wrapper_overlapped_t< p_writeable >::is_in_memory ( )
inline

Definition at line 203 of file file_win32_wrapper.h.

203 {return false;}
template<bool p_writeable>
bool file_win32_wrapper_overlapped_t< p_writeable >::is_remote ( )
inline

Definition at line 215 of file file_win32_wrapper.h.

215 {return false;}
template<bool p_writeable>
void file_win32_wrapper_overlapped_t< p_writeable >::on_idle ( abort_callback p_abort)
inline

Definition at line 204 of file file_win32_wrapper.h.

204 {p_abort.check_e();}
template<bool p_writeable>
t_size file_win32_wrapper_overlapped_t< p_writeable >::read ( void *  p_buffer,
t_size  p_bytes,
abort_callback p_abort 
)
inline

Definition at line 164 of file file_win32_wrapper.h.

164  {
165  return file_win32_helpers::readOverlapped(m_handle, m_event, m_position, p_buffer, p_bytes, p_abort);
166  }
size_t readOverlapped(HANDLE handle, HANDLE myEvent, t_filesize &position, void *out, size_t outBytes, abort_callback &abort)
template<bool p_writeable>
void file_win32_wrapper_overlapped_t< p_writeable >::reopen ( abort_callback p_abort)
inline

Definition at line 168 of file file_win32_wrapper.h.

168 {seek(0,p_abort);}
void seek(t_filesize p_position, abort_callback &p_abort)
template<bool p_writeable>
void file_win32_wrapper_overlapped_t< p_writeable >::resize ( t_filesize  p_size,
abort_callback p_abort 
)
inline

Definition at line 181 of file file_win32_wrapper.h.

181  {
182  if (!p_writeable) throw exception_io_denied();
183  p_abort.check_e();
184  file_win32_helpers::seek(m_handle,p_size,file::seek_from_beginning);
185  SetLastError(ERROR_SUCCESS);
186  if (!SetEndOfFile(m_handle)) {
187  DWORD code = GetLastError();
189  }
190  if (m_position > p_size) m_position = p_size;
191  }
void seek(HANDLE p_handle, t_sfilesize p_position, file::t_seek_mode p_mode)
PFC_NORETURN void exception_io_from_win32(DWORD p_code)
Definition: filesystem.cpp:773
template<bool p_writeable>
void file_win32_wrapper_overlapped_t< p_writeable >::seek ( t_filesize  p_position,
abort_callback p_abort 
)
inline

Definition at line 194 of file file_win32_wrapper.h.

194  {
195  p_abort.check_e();
196  if (p_position > file_win32_helpers::get_size(m_handle)) throw exception_io_seek_out_of_range();
197  // file_win32_helpers::seek(m_handle,p_position,file::seek_from_beginning);
198  m_position = p_position;
199  }
t_filesize get_size(HANDLE p_handle)
template<bool p_writeable>
void file_win32_wrapper_overlapped_t< p_writeable >::write ( const void *  p_buffer,
t_size  p_bytes,
abort_callback p_abort 
)
inline

Definition at line 160 of file file_win32_wrapper.h.

160  {
161  if (!p_writeable) throw exception_io_denied();
162  return file_win32_helpers::writeOverlapped(m_handle, m_event, m_position, p_buffer, p_bytes, p_abort);
163  }
void writeOverlapped(HANDLE handle, HANDLE myEvent, t_filesize &position, const void *in, size_t inBytes, abort_callback &abort)

Field Documentation

template<bool p_writeable>
HANDLE file_win32_wrapper_overlapped_t< p_writeable >::m_event
protected

Definition at line 237 of file file_win32_wrapper.h.

template<bool p_writeable>
HANDLE file_win32_wrapper_overlapped_t< p_writeable >::m_handle
protected

Definition at line 237 of file file_win32_wrapper.h.

template<bool p_writeable>
t_filesize file_win32_wrapper_overlapped_t< p_writeable >::m_position
protected

Definition at line 238 of file file_win32_wrapper.h.


The documentation for this class was generated from the following file: