ScummVM API documentation
base_file_manager.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This file is based on WME Lite.
24  * http://dead-code.org/redir.php?target=wmelite
25  * Copyright (c) 2011 Jan Nedoma
26  */
27 
28 #ifndef WINTERMUTE_BASE_FILE_MANAGER_H
29 #define WINTERMUTE_BASE_FILE_MANAGER_H
30 
31 #include "common/archive.h"
32 #include "common/str.h"
33 #include "common/str-array.h"
34 #include "common/fs.h"
35 #include "common/file.h"
36 #include "common/language.h"
37 
38 namespace Wintermute {
40 public:
41  bool cleanup();
42 
43  bool closeFile(Common::SeekableReadStream *File);
44  bool hasFile(const Common::String &filename);
45  int listMatchingPackageMembers(Common::ArchiveMemberList &list, const Common::String &pattern);
46  int listMatchingFiles(Common::StringArray &list, const Common::String &pattern);
47  Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true);
48  Common::WriteStream *openFileForWrite(const Common::String &filename);
49  byte *readWholeFile(const Common::String &filename, uint32 *size = nullptr, bool mustExist = true);
50  uint32 getPackageVersion(const Common::String &filename);
51 
52  BaseFileManager(Common::Language lang, bool detectionMode = false);
53  virtual ~BaseFileManager();
54  // Used only for detection
55  bool registerPackages(const Common::FSList &fslist);
56  static BaseFileManager *getEngineInstance();
57 private:
58  typedef enum {
59  PATH_PACKAGE,
60  PATH_SINGLE
61  } TPathType;
62  bool reloadPaths();
63  bool initPaths();
64  bool addPath(TPathType type, const Common::FSNode &path);
65  bool registerPackages();
66  void initResources();
67  Common::SeekableReadStream *openFileRaw(const Common::String &filename);
68  Common::WriteStream *openFileForWriteRaw(const Common::String &filename);
69  Common::SeekableReadStream *openPkgFile(const Common::String &filename);
70  Common::FSList _packagePaths;
71  bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false);
72  bool _detectionMode;
73  Common::SearchSet _packages;
75  Common::Language _language;
76  Common::Archive *_resources;
78 
79  // This class is intentionally not a subclass of Base, as it needs to be used by
80  // the detector too, without launching the entire engine:
81 };
82 
83 } // End of namespace Wintermute
84 
85 #endif
Definition: str.h:59
Definition: stream.h:77
Definition: list.h:44
Definition: stream.h:745
Definition: base_file_manager.h:39
Definition: archive.h:141
Definition: archive.h:312
Definition: fs.h:69
Definition: fs.h:57
Definition: achievements_tables.h:27
Language
Definition: language.h:45