Thrill  0.1
wfs_file_base.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/io/wfs_file_base.hpp
3  *
4  * Windows file system file base
5  *
6  * Part of FOXXLL. See http://foxxll.org
7  *
8  * Copyright (C) 2005 Roman Dementiev <[email protected]>
9  * Copyright (C) 2008, 2010 Andreas Beckmann <[email protected]>
10  * Copyright (C) 2009, 2010 Johannes Singler <[email protected]>
11  *
12  * Distributed under the Boost Software License, Version 1.0.
13  * (See accompanying file LICENSE_1_0.txt or copy at
14  * http://www.boost.org/LICENSE_1_0.txt)
15  **************************************************************************/
16 
17 #ifndef FOXXLL_IO_WFS_FILE_BASE_HEADER
18 #define FOXXLL_IO_WFS_FILE_BASE_HEADER
19 
20 #include <foxxll/config.hpp>
21 
22 #if FOXXLL_WINDOWS
23 
24 #include <mutex>
25 #include <string>
26 
27 #include <foxxll/io/file.hpp>
28 #include <foxxll/io/request.hpp>
29 
30 namespace foxxll {
31 
32 //! \addtogroup foxxll_fileimpl
33 //! \{
34 
35 //! Base for Windows file system implementations.
36 class wfs_file_base : public virtual file
37 {
38 protected:
39  using HANDLE = void*;
40 
41  std::mutex fd_mutex_; // sequentialize function calls involving file_des_
42  HANDLE file_des_; // file descriptor
43  int mode_; // open mode
44  const std::string filename_;
45  offset_type bytes_per_sector_;
46  bool locked_;
47  wfs_file_base(const std::string& filename, int mode);
48  offset_type _size();
49  void close();
50 
51 public:
52  ~wfs_file_base();
53  offset_type size();
54  void set_size(offset_type newsize);
55  void lock();
56  const char * io_type() const;
57  void close_remove();
58 };
59 
60 //! \}
61 
62 } // namespace foxxll
63 
64 #endif // FOXXLL_WINDOWS
65 
66 #endif // !FOXXLL_IO_WFS_FILE_BASE_HEADER
67 
68 /**************************************************************************/
FOXXLL library namespace
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220