diff --git a/include/WinStd/Win.h b/include/WinStd/Win.h index 872587f3..82680785 100644 --- a/include/WinStd/Win.h +++ b/include/WinStd/Win.h @@ -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 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 ///