~ubuntu-branches/ubuntu/precise/pingus/precise

« back to all changes in this revision

Viewing changes to src/system.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-02-28 19:44:25 UTC
  • mfrom: (4.1.4 hardy)
  • Revision ID: james.westby@ubuntu.com-20080228194425-e8ilohlijv02kgcf
Tags: 0.7.2-2
* Fix FTBFS with gcc-4.3 by adding the missing include in
  src/input/evdev_device.cpp (Closes: #462238):
   + debian/patches/20_fix_FTBFS_with_gcc-4.3.
* Rename former patch so that the filename reflects the order in which
  the patches are applied:
   - debian/patches/data_dir.patch
   + debian/patches/10_fix_data_directory.
* Bump Standards-Version from 3.7.2 to 3.7.3, no changes needed.
* Add a dh_desktop call in the arch-dep part of debian/rules.
* Adjust the “missing-dep-for-interpreter guile” override since lintian
  now lists an alternative for that dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//  $Id: system.hpp 3340 2007-10-27 07:08:51Z grumbel $
 
2
//
 
3
//  Pingus - A free Lemmings clone
 
4
//  Copyright (C) 1999 Ingo Ruhnke <grumbel@gmx.de>
 
5
//
 
6
//  This program is free software; you can redistribute it and/or
 
7
//  modify it under the terms of the GNU General Public License
 
8
//  as published by the Free Software Foundation; either version 2
 
9
//  of the License, or (at your option) any later version.
 
10
//
 
11
//  This program is distributed in the hope that it will be useful,
 
12
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//  GNU General Public License for more details.
 
15
//
 
16
//  You should have received a copy of the GNU General Public License
 
17
//  along with this program; if not, write to the Free Software
 
18
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
19
//  02111-1307, USA.
 
20
 
 
21
#ifndef HEADER_PINGUS_SYSTEM_HXX
 
22
#define HEADER_PINGUS_SYSTEM_HXX
 
23
 
 
24
#include "pingus.hpp"
 
25
#include <string>
 
26
#include <vector>
 
27
#include <map>
 
28
#include "SDL.h"
 
29
 
 
30
 
 
31
/** A wrapper class around some system dependend functions (mostly
 
32
    POSIX stuff) */
 
33
class System
 
34
{
 
35
private:
 
36
  static int verbose;
 
37
  static std::string default_email;
 
38
  static std::string default_username;
 
39
 
 
40
public:
 
41
  enum FileType { DE_DIRECTORY, DE_FILE };
 
42
 
 
43
  struct DirectoryEntry
 
44
  {
 
45
    FileType type;
 
46
    std::string name;
 
47
 
 
48
    DirectoryEntry(const std::string&, FileType t = DE_FILE);
 
49
  };
 
50
 
 
51
  ///
 
52
  typedef std::vector<DirectoryEntry> Directory;
 
53
  typedef Directory::iterator DirectoryIter;
 
54
 
 
55
  ///
 
56
  static Directory opendir(const std::string& pathname, const std::string& pattern = "*");
 
57
 
 
58
  /** Check if a file is avaiblable (no checking for permissens is currently performed)
 
59
      @param filename The name of the file
 
60
      @return True, if the file exist, false otherwise */
 
61
  static bool exist(std::string filename);
 
62
 
 
63
  /** Creates directory if it does not already exist.
 
64
      @param dir The name of the directory */
 
65
  static void create_dir(std::string dir);
 
66
 
 
67
  /** Change into the directory named dir, on error throw an PingusError */
 
68
  static void change_dir (std::string dir);
 
69
 
 
70
  /** Check if all needed directories are available, if not then create
 
71
      them. */
 
72
  static void init_directories();
 
73
 
 
74
  /** Strips directory from filenames
 
75
      @param filename The complete filename */
 
76
  static std::string basename(std::string filename);
 
77
 
 
78
  /** Strips basename from pathnames (see dirname(3))
 
79
      @param filename The complete filename */
 
80
  static std::string dirname(std::string filename);
 
81
 
 
82
  /** Return the extension of the given filename:
 
83
 
 
84
      System::extension ("foobar.jpg")    => "jpg"
 
85
      System::extension ("/bla/bla.blub/") => ""
 
86
      System::extension ("/bla/blabl") => ""
 
87
  */
 
88
  static std::string extension (std::string filename);
 
89
  static std::string cut_ext (std::string filename);
 
90
 
 
91
  /** Returns the directory where Pingus can store its user specific
 
92
      state and config data (savegames, config files, demos, etc.) */
 
93
  static std::string get_statdir();
 
94
 
 
95
  /** Returns the directory where Pingus can store things that needs
 
96
      to be cached, for example thumbnails */
 
97
  static std::string get_cachedir();
 
98
 
 
99
  /** Returns the directory were Pingus can store its system wide
 
100
      variable game data (highscores, cache images, ...) */
 
101
  static std::string get_vardir();
 
102
 
 
103
  /** Asks different variables to check were the directory for
 
104
      temporary files is located
 
105
      @return The location of the tmp directory */
 
106
  static std::string get_tmpdir();
 
107
 
 
108
  /** Returns the Username how the current user or an empty string */
 
109
  static std::string get_username();
 
110
 
 
111
  /** Returns the EMail of the user or an empty string */
 
112
  static std::string get_email();
 
113
 
 
114
  /** Get the currently country code, in a two letter ISO 639 syntax */
 
115
  static std::string get_language();
 
116
 
 
117
  /** Return the modification time of a file */
 
118
  static uint64_t get_mtime(const std::string& filename);
 
119
 
 
120
  /** Choose the correct translation out of the map, if there is none
 
121
      present, fall back to the default language */
 
122
  static std::string translate(const std::map<std::string, std::string>& strs);
 
123
 
 
124
  static std::string translate(const std::string& str);
 
125
 
 
126
  /** Translate to 'en' */
 
127
  static std::string translate_default(const std::map<std::string, std::string>& strs);
 
128
 
 
129
  /** Removes all .., double slashes and such from a pathname */
 
130
  static std::string realpath(const std::string& pathname);
 
131
 
 
132
  /** Read a file and generate a checksum and return it. The checksum
 
133
   generation is very primitiv and should probably be replaced by CRC
 
134
   or md5. */
 
135
  static std::string checksum (std::string filename);
 
136
 
 
137
private:
 
138
  System (const System&);
 
139
  System& operator= (const System&);
 
140
};
 
141
 
 
142
 
 
143
#endif
 
144
 
 
145
/* EOF */