TPIE

2362a60
win32.h
Go to the documentation of this file.
1 // -*- mode: c++; tab-width: 4; indent-tabs-mode: t; c-file-style: "stroustrup"; -*-
2 // vi:set ts=4 sts=4 sw=4 noet :
3 // Copyright 2009, 2010, The TPIE development team
4 //
5 // This file is part of TPIE.
6 //
7 // TPIE is free software: you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // TPIE is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with TPIE. If not, see <http://www.gnu.org/licenses/>
19 
23 
24 #ifndef _TPIE_FILE_ACCESSOR_WIN32_H
25 #define _TPIE_FILE_ACCESSOR_WIN32_H
26 
27 #include <tpie/config.h>
28 
29 #include <io.h>
30 #include <windows.h>
31 #include <IntSafe.h>
32 #include <string>
33 #undef NO_ERROR
34 
36 namespace tpie {
37 namespace file_accessor {
38 
42 
43 class win32 {
44 private:
45  HANDLE m_fd;
46  DWORD m_creationFlag;
47 
48 public:
49  inline win32();
50  inline ~win32() {close_i();}
51 
52  inline void open_wo(const std::string & path);
53  inline void open_ro(const std::string & path);
54  inline bool try_open_rw(const std::string & path);
55  inline void open_rw_new(const std::string & path);
56 
57  inline void read_i(void * data, memory_size_type size);
58  inline void write_i(const void * data, memory_size_type size);
59  inline void seek_i(stream_size_type offset);
60  inline stream_size_type file_size_i();
61  inline void close_i();
62  inline void truncate_i(stream_size_type bytes);
63  inline bool is_open() const;
64 
65  inline void set_cache_hint(cache_hint cacheHint);
66 
67 private:
68  inline void _open(const std::string & path, DWORD access, DWORD create_mode);
69 };
70 
71 }
72 }
73 
74 #include <tpie/file_accessor/win32.inl>
75 
76 #endif //_TPIE_FILE_ACCESSOR_WIN32_H
cache_hint
Definition: cache_hint.h:28
Reads and writes stream headers, user data and blocks from TPIE streams.
Win32 file accessor.
Definition: win32.h:43