Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ufs_file_base.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/io/ufs_file_base.hpp
3  *
4  * UNIX file system file base
5  *
6  * Part of FOXXLL. See http://foxxll.org
7  *
8  * Copyright (C) 2002 Roman Dementiev <[email protected]>
9  * Copyright (C) 2008 Andreas Beckmann <[email protected]>
10  * Copyright (C) 2009 Johannes Singler <[email protected]>
11  * Copyright (C) 2013 Timo Bingmann <[email protected]a.net>
12  *
13  * Distributed under the Boost Software License, Version 1.0.
14  * (See accompanying file LICENSE_1_0.txt or copy at
15  * http://www.boost.org/LICENSE_1_0.txt)
16  **************************************************************************/
17 
18 #ifndef FOXXLL_IO_UFS_FILE_BASE_HEADER
19 #define FOXXLL_IO_UFS_FILE_BASE_HEADER
20 
21 #include <mutex>
22 #include <string>
23 
24 #include <foxxll/io/file.hpp>
25 
26 namespace foxxll {
27 
28 //! \addtogroup foxxll_fileimpl
29 //! \{
30 
31 //! Base for UNIX file system implementations.
32 class ufs_file_base : public virtual file
33 {
34 protected:
35  std::mutex fd_mutex_; // sequentialize function calls involving file_des_
36  int file_des_; // file descriptor
37  int mode_; // open mode
39  bool is_device_; //!< is special device node
40  ufs_file_base(const std::string& filename, int mode);
41  void _after_open();
43  void _set_size(offset_type newsize);
44  void close();
45 
46 public:
48  offset_type size() final;
49  void set_size(offset_type newsize) final;
50  void lock() final;
51  const char * io_type() const override;
52  void close_remove() final;
53  //! unlink file without closing it.
54  void unlink();
55  //! return true if file is special device node
56  bool is_device() const;
57 };
58 
59 //! \}
60 
61 } // namespace foxxll
62 
63 #endif // !FOXXLL_IO_UFS_FILE_BASE_HEADER
64 
65 /**************************************************************************/
Base for UNIX file system implementations.
bool is_device() const
return true if file is special device node
void close_remove() final
close and remove file
request::offset_type offset_type
the offset of a request, also the size of the file
Definition: file.hpp:58
bool is_device_
is special device node
void set_size(offset_type newsize) final
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
Definition: allocator.hpp:220
offset_type size() final
ufs_file_base(const std::string &filename, int mode)
const char * io_type() const override
void lock() final
Locks file for reading and writing (acquires a lock in the file system).
const std::string filename_
void _set_size(offset_type newsize)
void unlink()
unlink file without closing it.