GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
ResourcesMergingHelper.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #ifndef RESOURCESMERGINGHELPER_H
7 #define RESOURCESMERGINGHELPER_H
8 
9 #include <map>
10 #include <memory>
11 #include <vector>
12 #include "GDCore/IDE/Project/ArbitraryResourceWorker.h"
13 #include "GDCore/String.h"
14 namespace gd {
15 class AbstractFileSystem;
16 }
17 
18 namespace gd {
19 
30 class GD_CORE_API ResourcesMergingHelper : public ArbitraryResourceWorker {
31 public:
33  gd::AbstractFileSystem &fileSystem)
34  : ArbitraryResourceWorker(resourcesManager),
35  preserveDirectoriesStructure(false), preserveAbsoluteFilenames(false),
36  fs(fileSystem){};
37  virtual ~ResourcesMergingHelper(){};
38 
43  void SetBaseDirectory(const gd::String& baseDirectory);
44 
50  void PreserveDirectoriesStructure(bool preserveDirectoriesStructure_ = true) {
51  preserveDirectoriesStructure = preserveDirectoriesStructure_;
52  };
53 
57  void PreserveAbsoluteFilenames(bool preserveAbsoluteFilenames_ = true) {
58  preserveAbsoluteFilenames = preserveAbsoluteFilenames_;
59  };
60 
66  std::map<gd::String, gd::String>& GetAllResourcesOldAndNewFilename() {
67  return newFilenames;
68  };
69 
74  void ExposeFile(gd::String& resource) override;
75 
76  protected:
77  void SetNewFilename(gd::String oldFilename, gd::String newFilename);
78 
82  std::map<gd::String, gd::String> oldFilenames;
86  std::map<gd::String, gd::String> newFilenames;
87  gd::String baseDirectory;
97  fs;
98 };
99 
100 } // namespace gd
101 
102 #endif // RESOURCESMERGINGHELPER_H
An interface to manipulate files in a platform agnostic way. This allow exporters to work on files wi...
Definition: AbstractFileSystem.h:24
ArbitraryResourceWorker is used so as to inventory resources and sometimes update them.
Definition: ArbitraryResourceWorker.h:44
Inventory all resources used by a project.
Definition: ResourcesManager.h:556
ResourcesMergingHelper is used (mainly during export) to list resources and generate new filenames,...
Definition: ResourcesMergingHelper.h:30
bool preserveAbsoluteFilenames
Definition: ResourcesMergingHelper.h:92
void PreserveDirectoriesStructure(bool preserveDirectoriesStructure_=true)
Set if the directories structure, starting from the base directory, must be preserved....
Definition: ResourcesMergingHelper.h:50
std::map< gd::String, gd::String > & GetAllResourcesOldAndNewFilename()
Return a map containing the resources old absolute filename as key, and the resources new filenames a...
Definition: ResourcesMergingHelper.h:66
gd::AbstractFileSystem & fs
The gd::AbstractFileSystem used to manipulate files.
Definition: ResourcesMergingHelper.h:97
std::map< gd::String, gd::String > newFilenames
Definition: ResourcesMergingHelper.h:86
std::map< gd::String, gd::String > oldFilenames
Definition: ResourcesMergingHelper.h:82
void PreserveAbsoluteFilenames(bool preserveAbsoluteFilenames_=true)
Set if the absolute filenames must be preserved.
Definition: ResourcesMergingHelper.h:57
bool preserveDirectoriesStructure
Definition: ResourcesMergingHelper.h:88
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24