winstd::file helper class introduced

This commit is contained in:
Simon Rozman 2017-04-24 21:06:37 +02:00
parent 0910917126
commit e9abc0e7b6

View File

@ -35,6 +35,7 @@ namespace winstd
class WINSTD_API win_handle;
class WINSTD_API library;
class WINSTD_API process;
class WINSTD_API file;
class WINSTD_API heap;
template <class _Ty> class heap_allocator;
class WINSTD_API actctx_activator;
@ -382,6 +383,33 @@ namespace winstd
};
///
/// File handle wrapper
///
class WINSTD_API file : public win_handle
{
public:
///
/// Opens file handle.
///
/// \sa [CreateFile function](https://msdn.microsoft.com/en-us/library/windows/desktop/aa363858.aspx)
///
/// \return
/// - \c true when succeeds;
/// - \c false when fails. Use `GetLastError()` for failure reason.
///
inline bool create(_In_ LPCTSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_ DWORD dwCreationDisposition, _In_opt_ DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL, _In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes = NULL, _In_opt_ HANDLE hTemplateFile = NULL)
{
handle_type h = CreateFile(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
if (h) {
attach(h);
return true;
} else
return false;
}
};
///
/// Heap handle wrapper
///