forked from TheSuperHackers/GeneralsGameCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileSystem.h
More file actions
153 lines (127 loc) · 6.24 KB
/
FileSystem.h
File metadata and controls
153 lines (127 loc) · 6.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
** Command & Conquer Generals(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
////////////////////////////////////////////////////////////////////////////////
// //
// (c) 2001-2003 Electronic Arts Inc. //
// //
////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------=
//
// Westwood Studios Pacific.
//
// Confidential Information
// Copyright(C) 2001 - All Rights Reserved
//
//----------------------------------------------------------------------------
//
// Project: GameEngine
//
// Module: IO
//
// File name: FileSystem.h
//
// Created:
//
//----------------------------------------------------------------------------
#pragma once
#ifndef __FILESYSTEM_H
#define __FILESYSTEM_H
//----------------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------------
//#include "Common/File.h"
#include "Common/STLTypedefs.h"
#include "Common/SubsystemInterface.h"
//----------------------------------------------------------------------------
// Forward References
//----------------------------------------------------------------------------
class File;
//----------------------------------------------------------------------------
// Type Defines
//----------------------------------------------------------------------------
typedef std::set<AsciiString, rts::less_than_nocase<AsciiString> > FilenameList;
typedef FilenameList::iterator FilenameListIter;
//----------------------------------------------------------------------------
// Type Defines
//----------------------------------------------------------------------------
//#define W3D_DIR_PATH "../FinalArt/W3D/" ///< .w3d files live here
//#define TGA_DIR_PATH "../FinalArt/Textures/" ///< .tga texture files live here
//#define TERRAIN_TGA_DIR_PATH "../FinalArt/Terrain/" ///< terrain .tga texture files live here
#define W3D_DIR_PATH "Art/W3D/" ///< .w3d files live here
#define TGA_DIR_PATH "Art/Textures/" ///< .tga texture files live here
#define TERRAIN_TGA_DIR_PATH "Art/Terrain/" ///< terrain .tga texture files live here
#define MAP_PREVIEW_DIR_PATH "%sMapPreviews/" ///< We need a common place we can copy the map previews to at runtime.
#define USER_W3D_DIR_PATH "%sW3D/" ///< .w3d files live here
#define USER_TGA_DIR_PATH "%sTextures/" ///< User .tga texture files live here
// the following defines are only to be used while maintaining legacy compatability
// with old files until they are completely gone and in the regular art set
#ifdef MAINTAIN_LEGACY_FILES
#define LEGACY_W3D_DIR_PATH "../LegacyArt/W3D/" ///< .w3d files live here
#define LEGACY_TGA_DIR_PATH "../LegacyArt/Textures/" ///< .tga texture files live here
#endif // MAINTAIN_LEGACY_FILES
// LOAD_TEST_ASSETS automatically loads w3d assets from the TEST_W3D_DIR_PATH
// without having to add an INI entry.
///@todo this allows us to use the test art directory, it should be removed for FINAL release
#define LOAD_TEST_ASSETS 1
#ifdef LOAD_TEST_ASSETS
#define ROAD_DIRECTORY "../TestArt/TestRoad/"
#define TEST_STRING "***TESTING"
// the following directories will be used to look for test art
#define LOOK_FOR_TEST_ART
#define TEST_W3D_DIR_PATH "../TestArt/" ///< .w3d files live here
#define TEST_TGA_DIR_PATH "../TestArt/" ///< .tga texture files live here
#endif
struct FileInfo {
Int sizeHigh;
Int sizeLow;
Int timestampHigh;
Int timestampLow;
};
//===============================
// FileSystem
//===============================
/**
* FileSystem is an interface class for creating specific FileSystem objects.
*
* A FileSystem object's implemenation decides what derivative of File object needs to be
* created when FileSystem::Open() gets called.
*/
//===============================
class FileSystem : public SubsystemInterface
{
public:
FileSystem();
virtual ~FileSystem();
void init();
void reset();
void update();
File* openFile( const Char *filename, Int access = 0 ); ///< opens a File interface to the specified file
Bool doesFileExist(const Char *filename) const; ///< returns TRUE if the file exists. filename should have no directory.
void getFileListInDirectory(const AsciiString& directory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories.
Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const; ///< fills in the FileInfo struct for the file given. returns TRUE if successful.
Bool createDirectory(AsciiString directory); ///< create a directory of the given name.
Bool areMusicFilesOnCD();
void loadMusicFilesFromCD();
void unloadMusicFilesFromCD();
protected:
};
extern FileSystem* TheFileSystem;
//----------------------------------------------------------------------------
// Inlining
//----------------------------------------------------------------------------
#endif // __WSYS_FILESYSTEM_H