~gunchleoc/widelands/bug-1818494-ingame-zoom-freezes

« back to all changes in this revision

Viewing changes to src/fileloc.h

  • Committer: sirver
  • Date: 2002-02-05 20:54:08 UTC
  • Revision ID: git-v1:df384fd3a5e53be1f37803d1c0381fa993844bf5
Initial revision


git-svn-id: https://widelands.svn.sourceforge.net/svnroot/widelands/trunk@2 37b2a8de-5219-0410-9f54-a31bc463ab9c

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2001 by Holger Rapp 
 
3
 * 
 
4
 * This program is free software; you can redistribute it and/or
 
5
 * modify it under the terms of the GNU General Public License
 
6
 * as published by the Free Software Foundation; either version 2
 
7
 * of the License, or (at your option) any later version.
 
8
 * 
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 * 
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
17
 *
 
18
 */
 
19
 
 
20
#ifndef __S__FILE_LOCATOR
 
21
#define __S__FILE_LOCATOR
 
22
 
 
23
#include <dirent.h>
 
24
 
 
25
#include "singleton.h"
 
26
 
 
27
/** class File_Locator 
 
28
 *
 
29
 * This class is responsible for locating files in several directorys
 
30
 * and to list them in a easy to use manner.
 
31
 */
 
32
class File_Locator : public Singleton<File_Locator> {
 
33
                  // Forbidden functions
 
34
                  File_Locator(const File_Locator&);
 
35
                  File_Locator& operator=(const File_Locator&);
 
36
 
 
37
                  public:
 
38
#ifdef MAX_PATH
 
39
                                         static const unsigned int MAX_PATHL=MAX_PATH;
 
40
#else 
 
41
                                         static const unsigned int MAX_PATHL=256;
 
42
#endif
 
43
                                         static const unsigned int MAX_DIRS=5; 
 
44
                                         static const unsigned int MAX_SUBDIRL=20;
 
45
                                         static const unsigned int MAX_SUBDIRS=10;
 
46
                  
 
47
#ifdef WINDOWS
 
48
                                         static const unsigned char SEP[]="\\";
 
49
                                         static const unsigned char CSEP='\\';
 
50
#else
 
51
                                         static const unsigned char SEP[]="/";
 
52
                                         static const unsigned char CSEP='/';
 
53
#endif
 
54
 
 
55
                                         enum Last_action {
 
56
                                                                LA_SUCCESS,
 
57
                                                                LA_NOTEXISTING,
 
58
                                                                LA_NOTALLOWED,
 
59
                                                                LA_TOOMUCH,
 
60
                                                                LA_NOTSET,
 
61
                                                                LA_NOMOREFILES
 
62
                                         };
 
63
                                         
 
64
                                         File_Locator(void);
 
65
                                         ~File_Locator(void);
 
66
 
 
67
                                         void  add_searchdir(const char*, const unsigned int);
 
68
                                         const char* locate_file(const char*, const int=-1);
 
69
                                         Last_action get_state(void) const;
 
70
                                         void register_subdir(const unsigned int, const char*);
 
71
                                        
 
72
                                         const char* get_new_filename(const char*, const int=-1);
 
73
                                         void set_def_writedir(const unsigned int id); 
 
74
 
 
75
                                         // Listings of all available files
 
76
                                         void init_filelisting( const int, const char[5] );
 
77
                                         const char* get_next_file(void);
 
78
                                         void end_filelisting(void);
 
79
                                         
 
80
                  private:
 
81
                                         char dirs[MAX_DIRS][MAX_PATHL];
 
82
                                         char subdirs[MAX_SUBDIRL][MAX_SUBDIRS];
 
83
                                         char retval[MAX_PATHL+MAX_SUBDIRL];
 
84
                                         char suf[5];
 
85
                                         int def_writedir;
 
86
                                         Last_action la;
 
87
                                         
 
88
                                         DIR* curdir;
 
89
                                         int ncurdir;
 
90
                                         int nlisttype;
 
91
                                         int ndirstrlen;
 
92
 
 
93
                                         void open_next_dir(void);
 
94
 
 
95
};
 
96
 
 
97
#define g_fileloc File_Locator::get_singleton()
 
98
 
 
99
#define TYPE_TEXT 0
 
100
#define TYPE_PIC  1
 
101
#define TYPE_BOB  2
 
102
#define TYPE_TRIBE 3
 
103
#define TYPE_WORLD 4
 
104
#define TYPE_CAMPAIGN 5
 
105
#define TYPE_MAP 6
 
106
#define TYPE_MUSIC 7
 
107
#define TYPE_EFFECT 8
 
108
 
 
109
#endif /* __S__FILE_LOCATOR */