Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
dotdir.hpp
1 //////////////////////////////
2 //
3 // File: lxs/system/dotdir.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Feb 24 2013
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __HLP_DOTDIR_
15 #define __HLP_DOTDIR_
16 #include <string>
17 #include <map>
18 #include "lxs/system/global_config_definitions.hpp"
19 #include "lxs/system/servicethread.hpp"
20 #ifdef __APPLE__
21 int openat(int dirfd, const char *pathname, int flags, mode_t mode);
22 int mkdirat(int dirfd, const char *pathname, mode_t mode);
23 #endif
24 
25 
26 namespace LxS
27 {
28  namespace System
29  {
30  //!@brief Class representing directory for configuration files, user settings, saved games etc.
31  //!
32  //! This class represents permanently opened directory for settings.
33  //! in Android it is /data/data/pl.maciejkaminski.PRODUCTNAME
34  //! in iOS it's APPDIR/Documents/
35  //! in Unix it's $HOME/.PRODUCTNAME
36  //! BTW. class is implemented in configuration.cpp file.
37  class DotDir
38  {
39  static std::string product_name;
40  static DotDir * instance;
41  int fd;
42  void OpenDotDir();
43  DotDir();
44  ~DotDir();
45  static DotDir * GetInstance();
46  public:
47  //! must same as in AndroidManifest
48  static void SetProductName(const std::string & name);
49  //! returns file descriptor. Opens directory befor if it wasn't already open
50  static int GetFD();
51  };
52  }
53 }
54 
55 #endif