Fission FSN
Loading...
Searching...
No Matches
fsIResourceNamePathAdjuster.h
Go to the documentation of this file.
1/********************************************************************
2*
3* Created: 19/2/2014 17:08
4*
5* File: fsIResourceNamePathAdjuster.h
6*
7* Author: Mick Waites
8*
9* Purpose: Interface for platform specific file path adjuster.
10*
11*********************************************************************/
12
13#ifndef fsIResourceNamePathAdjusterhdr
14#define fsIResourceNamePathAdjusterhdr
15
16#include <set>
17#include <fsCore/fsBaseTypes.h>
19
20class fsCAppSettings;
21class fsIHardware;
22
24{
25public:
26
27 static const fsStr mPathSeparator;
28 static const fsStr mLayersFolder;
29
34
35 static void cacheFlush();
37
38 // Registers pOverlayFolder (an absolute, writable directory -- typically
39 // somewhere under savedDataFolderGet()/appDataFolderGet()) as an
40 // additional place the platform's own asset loader should look when a
41 // relative asset path isn't found in the read-only assets bundle. This
42 // is what lets a caller that extracted a file (e.g. from a fallback
43 // zip archive) to that writable directory have it found transparently
44 // by ordinary path-based loads (images, textures, ...) with no change
45 // to those load call sites at all.
46 //
47 // Default is a no-op: only a backend whose platform loader actually has
48 // a search-path concept (currently just axmol, via
49 // ax::FileUtils::addSearchPath) needs to override
50 // writableOverlaySearchPathAddDo(). Backends without such a concept
51 // simply never resolve the overlay -- callers must treat that as
52 // "fallback unavailable on this platform" rather than assume success.
53 void writableOverlaySearchPathAdd(fsStr const& pOverlayFolder);
54
56
58 void chapterAdapterAdd(std::function<void(fsStr&, fsCResourceName::eResourceLocation)> pAdaptar);
60
62 void modify(fsStr& pPath, fsCResourceName::eResourceLocation pLocation, fsStr pTestDeviceStr);
63 void modify(fsStr& pPath, fsCResourceName::eResourceLocation pLocation);
64 void testModeTagetDeviceSet(const fsStr& pTargetTestDevice);
65
66 void init(fsCAppSettings* const pAppSettings, fsIHardware* const pHardware);
67
69
70protected:
71
72 virtual void initDo() {}
73 virtual void pathAdjustDo(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const{}
74 virtual void audioExtensionAdjustDo(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const {}
75 virtual void savedDataPathAdjustDo(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const {}
76 virtual void savedDataFolderCreateDo() const = 0;
77 virtual void writableOverlaySearchPathAddDo(fsStr const& pOverlayFolder) const {}
78
80
84
85private:
86
87 void pathAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const;
88
89 static fsBool isUnadjustedSettingsFile(const fsStr& pPath);
90 void audioExtensionAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const;
91 void savedDataPathAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const;
92
93 static void publisherFilenameAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation);
94 static void platformFilenameAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation);
95 static fsStr platformFilenameGet();
96
97 void buildFlavourFilenameAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const;
98 void wideScreenMobileDevicePathAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const;
99 void chapterFilenameAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation) const;
100 static void legacyFolderAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation);
101
102
103 static void languageFilenameAdjust(fsStr& pPath, fsCResourceName::eResourceLocation pLocation);
104
105
106 static const fsStr mLayoutFileExt;
107
108 // Asset folders that have moved: { current prefix, legacy prefix }
109 static const std::pair<fsStr, fsStr> mLegacyFolders[];
110
111 std::function<void(fsStr&, fsCResourceName::eResourceLocation)> mChapterAdapter;
112
113 void filenameCache(const fsStr& pFilename);
114
115#if !defined(fsRelease)
116 static std::set<fsStr> mFileCache;
117#endif
118};
119
120#endif
Definition fsCAppSettings.h:22
eResourceLocation
Definition fsCResourceName.h:36
Definition fsIHardware.h:26
virtual void audioExtensionAdjustDo(fsStr &pPath, fsCResourceName::eResourceLocation pLocation) const
Definition fsIResourceNamePathAdjuster.h:74
void chapterAdapterClear()
Definition fsIResourceNamePathAdjuster.cpp:68
virtual ~fsIResourceNamePathAdjuster()
Definition fsIResourceNamePathAdjuster.cpp:378
static fsStr localisedLevelLayersFolderGet()
Definition fsIResourceNamePathAdjuster.cpp:45
void savedDataFolderCreate()
Definition fsIResourceNamePathAdjuster.cpp:363
static const fsStr mLocaleFolderName
Definition fsIResourceNamePathAdjuster.h:33
static fsCAppSettings * mAppSettings
Definition fsIResourceNamePathAdjuster.h:83
static fsStr savedDataFolderGet()
Definition fsIResourceNamePathAdjuster.cpp:109
fsIResourceNamePathAdjuster()
Definition fsIResourceNamePathAdjuster.cpp:373
void testModeTagetDeviceSet(const fsStr &pTargetTestDevice)
Definition fsIResourceNamePathAdjuster.cpp:265
void writableOverlaySearchPathAdd(fsStr const &pOverlayFolder)
Definition fsIResourceNamePathAdjuster.cpp:368
virtual void pathAdjustDo(fsStr &pPath, fsCResourceName::eResourceLocation pLocation) const
Definition fsIResourceNamePathAdjuster.h:73
static const fsStr mLayersFolder
Definition fsIResourceNamePathAdjuster.h:28
static void cacheFlush()
Definition fsIResourceNamePathAdjuster.cpp:383
virtual void initDo()
Definition fsIResourceNamePathAdjuster.h:72
void chapterAdapterAdd(std::function< void(fsStr &, fsCResourceName::eResourceLocation)> pAdaptar)
Definition fsIResourceNamePathAdjuster.cpp:63
static fsStr mTestMode
Definition fsIResourceNamePathAdjuster.h:81
static fsStr buildFlavourFilenameGet()
Definition fsIResourceNamePathAdjuster.cpp:104
static const fsStr mMacFileNameModifier
Definition fsIResourceNamePathAdjuster.h:30
void modify(fsStr &pPath, fsCResourceName::eResourceLocation pLocation, fsStr pTestDeviceStr)
Definition fsIResourceNamePathAdjuster.cpp:334
void init(fsCAppSettings *const pAppSettings, fsIHardware *const pHardware)
Definition fsIResourceNamePathAdjuster.cpp:55
virtual void savedDataFolderCreateDo() const =0
static const fsStr mPathSeparator
Definition fsIResourceNamePathAdjuster.h:27
static const fsStr mMobileFileNameModifier
Definition fsIResourceNamePathAdjuster.h:31
static fsIHardware * mHardware
Definition fsIResourceNamePathAdjuster.h:82
virtual void writableOverlaySearchPathAddDo(fsStr const &pOverlayFolder) const
Definition fsIResourceNamePathAdjuster.h:77
static const fsStr mPhoneWideScreenFileNameModifier
Definition fsIResourceNamePathAdjuster.h:32
virtual void savedDataPathAdjustDo(fsStr &pPath, fsCResourceName::eResourceLocation pLocation) const
Definition fsIResourceNamePathAdjuster.h:75
Definition fsStr.h:23
bool fsBool
Definition fsBaseTypes.h:26